From 3b5317b0d1106a4da0edbdc8a27abe99ecd18bec Mon Sep 17 00:00:00 2001 From: David Manthey Date: Tue, 5 Dec 2023 08:49:24 -0500 Subject: [PATCH] Fix an issue when tifffile reports no key frame --- CHANGELOG.md | 6 ++++++ .../tifffile/large_image_source_tifffile/__init__.py | 4 ++-- test/datastore.py | 2 ++ test/test_source_base.py | 11 +++++++++-- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab7785557..4c6a89503 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 1.26.3 + +### Bug Fixes +- Fix an issue when tifffile reports no key frame ([#1396](../../pull/1396)) + ## 1.26.2 ### Improvements @@ -436,6 +441,7 @@ ### Bug Fixes - Use open.read rather than download to access files in Girder ([#989](../../pull/989)) - Fix nd2 source scale ([#990](../../pull/990)) +- Do not raise a login request when checking if the user can write annotations ([#991](../../pull/991)) ## 1.17.3 diff --git a/sources/tifffile/large_image_source_tifffile/__init__.py b/sources/tifffile/large_image_source_tifffile/__init__.py index ab4d36bd3..0ce7aeb84 100644 --- a/sources/tifffile/large_image_source_tifffile/__init__.py +++ b/sources/tifffile/large_image_source_tifffile/__init__.py @@ -238,10 +238,10 @@ def _findAssociatedImages(self): Find associated images from unused pages and series. """ pagesInSeries = [p for s in self._tf.series for ll in s.pages.levels for p in ll.pages] - hashes = [p.hash for p in pagesInSeries if p.keyframe is not None] + hashes = [p.hash for p in pagesInSeries if getattr(p, 'keyframe', None) is not None] self._associatedImages = {} for p in self._tf.pages: - if (p not in pagesInSeries and p.keyframe is not None and + if (p not in pagesInSeries and getattr(p, 'keyframe', None) is not None and p.hash not in hashes and not len(set(p.axes) - set('YXS'))): id = 'image_%s' % p.index entry = {'page': p.index} diff --git a/test/datastore.py b/test/datastore.py index 0f0f4ab41..1e64d0b19 100644 --- a/test/datastore.py +++ b/test/datastore.py @@ -106,6 +106,8 @@ 'synthetic_multiaxis.zarr.zip': 'sha512:95da53061bd09deaf4357e745404780d78a0949935f82c10ee75237e775345caace18fad3f05c3452ba36efca6b3ed58d815d041f33197497ab53d2c80b9e2ac', # noqa # Single flat array zarr 'flat2.zarr.zip': 'sha512:c49ff5fbfa73615da4c2a7c8602723297d604892b848860a068ab200245eec6c4f638f35d0b40cde0233c55faa6dc4e46351a841b481211f36dc5fb43765d818', # noqa + # OME tiff where tifffile reports no keyframe + 'test_nokeyframe.ome.tiff': 'sha512:e810420ece0688bf4e1c347ef7e172a303a9cb3f0d56efc3d0068ec40decf05d2588b01a3f5ac9857ccf8f3d088819e532148488f30ad693d6d79c1aa66115d7', # noqa } diff --git a/test/test_source_base.py b/test/test_source_base.py index b19fb0906..f2d45065c 100644 --- a/test/test_source_base.py +++ b/test/test_source_base.py @@ -38,11 +38,13 @@ 'gdal': { 'read': r'\.(jpg|jpeg|jp2|ptif|scn|svs|tif.*|qptiff)$', 'noread': r'(huron\.image2_jpeg2k|sample_jp2k_33003|TCGA-DU-6399|\.(ome.tiff|nc)$)', + 'skip': r'nokeyframe\.ome\.tiff$', 'skipTiles': r'\.*nc$', }, 'mapnik': { 'read': r'\.(jpg|jpeg|jp2|ptif|nc|scn|svs|tif.*|qptiff)$', 'noread': r'(huron\.image2_jpeg2k|sample_jp2k_33003|TCGA-DU-6399|\.(ome.tiff)$)', + 'skip': r'nokeyframe\.ome\.tiff$', # we should only test this with a projection 'skipTiles': r'', }, @@ -53,11 +55,15 @@ 'nd2': { 'read': r'\.(nd2)$', }, - 'ometiff': {'read': r'\.(ome\.tif.*)$'}, + 'ometiff': { + 'read': r'\.(ome\.tif.*)$', + 'noread': r'nokeyframe\.ome\.tiff$', + }, 'openjpeg': {'read': r'\.(jp2)$'}, 'openslide': { 'read': r'\.(ptif|svs|tif.*|qptiff|dcm)$', 'noread': r'(oahu|DDX58_AXL|huron\.image2_jpeg2k|landcover_sample|d042-353\.crop|US_Geo\.|extraoverview|imagej|bad_axes)', # noqa + 'skip': r'nokeyframe\.ome\.tiff$', 'skipTiles': r'one_layer_missing', }, 'pil': { @@ -67,13 +73,14 @@ 'rasterio': { 'read': r'\.(jpg|jpeg|jp2|ptif|scn|svs|tif.*|qptiff)$', 'noread': r'(huron\.image2_jpeg2k|sample_jp2k_33003|TCGA-DU-6399|\.(ome.tiff|nc)$)', + 'skip': r'nokeyframe\.ome\.tiff$', }, 'test': {'any': True, 'skipTiles': r''}, 'tiff': { 'read': r'\.(ptif|scn|svs|tif.*|qptiff)$', 'noread': r'(oahu|DDX58_AXL|G10-3_pelvis_crop|' r'd042-353\.crop\.small\.float|landcover_sample|US_Geo\.|' - r'imagej|bad_axes)', + r'imagej|bad_axes|nokeyframe\.ome\.tiff$)', 'skipTiles': r'(sample_image\.ptif|one_layer_missing_tiles)'}, 'tifffile': { 'read': r'',