From 2e4d2eb3790f9852bd961b9f2dca6244234dbcd4 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Wed, 15 Nov 2023 18:29:02 -0500 Subject: [PATCH] Fix an issue with apply a frame style to ome tiffs --- CHANGELOG.md | 1 + sources/ometiff/large_image_source_ometiff/__init__.py | 5 +++-- test/test_source_ometiff.py | 4 +++- tox.ini | 5 +++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fb47c329..03ad30258 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ - Default to "None" for the DICOM assetstore limit ([#1359](../../pull/1359)) - Fix series detection for some bioformats files ([#1365](../../pull/1365), [#1367](../../pull/1367)) - Fix time comparison in annotation history check ([#1369](../../pull/1369)) +- Fix an issue with apply a frame style to ome tiffs ([#1374](../../pull/1374)) ## 1.26.0 diff --git a/sources/ometiff/large_image_source_ometiff/__init__.py b/sources/ometiff/large_image_source_ometiff/__init__.py index c37983964..77fb35d43 100644 --- a/sources/ometiff/large_image_source_ometiff/__init__.py +++ b/sources/ometiff/large_image_source_ometiff/__init__.py @@ -318,8 +318,9 @@ def getNativeMagnification(self): @methodcache() def getTile(self, x, y, z, pilImageAllowed=False, numpyAllowed=False, sparseFallback=False, **kwargs): - if (z < 0 or z >= len(self._omeLevels) or ( - self._omeLevels[z] is not None and kwargs.get('frame') in (None, 0, '0', ''))): + if ((z < 0 or z >= len(self._omeLevels) or ( + self._omeLevels[z] is not None and kwargs.get('frame') in (None, 0, '0', ''))) and + not getattr(self, '_style', None)): return super().getTile( x, y, z, pilImageAllowed=pilImageAllowed, numpyAllowed=numpyAllowed, sparseFallback=sparseFallback, diff --git a/test/test_source_ometiff.py b/test/test_source_ometiff.py index b947fc3ab..d84797a76 100644 --- a/test/test_source_ometiff.py +++ b/test/test_source_ometiff.py @@ -204,4 +204,6 @@ def testXMLParsing(): def testFrameStyleOMETiff(): imagePath = datastore.fetch('DDX58_AXL_EGFR_well2_XY01.ome.tif') source = large_image_source_ometiff.open(imagePath, style={'bands': [{'frame': 4}]}) - assert source.getTile(0, 0, 2) + tile1 = source.getTile(0, 0, 2) + tile2 = source.getTile(0, 0, 2, frame=1) + assert tile1 == tile2 diff --git a/tox.ini b/tox.ini index 4faa86e2c..584583e92 100644 --- a/tox.ini +++ b/tox.ini @@ -254,7 +254,8 @@ exclude = ignore = D100,D101,D102,D103,D104,D105,D106,D107,D200,D205,D400,D401,E741,W504,B017 [pytest] -addopts = --verbose --strict-markers --showlocals --cov-report="term" --cov-report="xml" --cov-report="html" --cov --ignore test/utils --cov-context=test +addopts = --verbose --strict-markers --showlocals --cov-report="term" --cov-report="xml" --cov-report="html" --cov --ignore test/utils +# --cov-context=test cache_dir = build/pytest_cache testpaths = test @@ -322,7 +323,7 @@ parallel = True [coverage:html] directory = build/test/artifacts/python_coverage title = Large image Coverage Report -show_contexts = True +# show_contexts = True [coverage:xml] output = build/test/coverage/py_coverage.xml