From c457dd773c52d5b281819354d5ca99b8119681ac Mon Sep 17 00:00:00 2001 From: sean meharry Date: Wed, 16 Aug 2023 13:56:33 -0700 Subject: [PATCH] Revert to pre-2023.3.15 tifffile to avoid mm_stack issue --- aicsimageio/readers/ome_tiff_reader.py | 6 +++--- aicsimageio/readers/tiff_glob_reader.py | 16 +++++----------- aicsimageio/readers/tiff_reader.py | 9 ++++----- setup.py | 2 +- 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/aicsimageio/readers/ome_tiff_reader.py b/aicsimageio/readers/ome_tiff_reader.py index d6b6dc5a0..1f879db4f 100644 --- a/aicsimageio/readers/ome_tiff_reader.py +++ b/aicsimageio/readers/ome_tiff_reader.py @@ -185,7 +185,7 @@ def __init__( # Get ome-types object and warn of other behaviors with self._fs.open(self._path) as open_resource: - with TiffFile(open_resource, is_mmstack=False) as tiff: + with TiffFile(open_resource) as tiff: # Get and store OME self._ome = self._get_ome( tiff.pages[0].description, self.clean_metadata @@ -308,7 +308,7 @@ def _read_delayed(self) -> xr.DataArray: The file could not be read or is not supported. """ with self._fs.open(self._path) as open_resource: - with TiffFile(open_resource, is_mmstack=False) as tiff: + with TiffFile(open_resource) as tiff: # Get unprocessed metadata from tags tiff_tags = self._get_tiff_tags(tiff) @@ -353,7 +353,7 @@ def _read_immediate(self) -> xr.DataArray: The file could not be read or is not supported. """ with self._fs.open(self._path) as open_resource: - with TiffFile(open_resource, is_mmstack=False) as tiff: + with TiffFile(open_resource) as tiff: # Get unprocessed metadata from tags tiff_tags = self._get_tiff_tags(tiff) diff --git a/aicsimageio/readers/tiff_glob_reader.py b/aicsimageio/readers/tiff_glob_reader.py index 3386f46a5..249706ab3 100644 --- a/aicsimageio/readers/tiff_glob_reader.py +++ b/aicsimageio/readers/tiff_glob_reader.py @@ -117,7 +117,7 @@ def _is_supported_image( ) -> bool: try: with fs.open(path) as open_resource: - with TiffFile(open_resource, is_mmstack=False): + with TiffFile(open_resource): return True except (TiffFileError, TypeError): @@ -256,7 +256,7 @@ def indexer(x: str) -> pd.Series: if single_file_shape is None: with self._fs.open(self._path) as open_resource: - with TiffFile(open_resource, is_mmstack=False) as tiff: + with TiffFile(open_resource) as tiff: self._single_file_shape = tiff.series[0].shape else: @@ -299,9 +299,7 @@ def _read_delayed(self) -> xr.DataArray: scene_files = scene_files.drop(self.scene_glob_character, axis=1) scene_nunique = scene_files.nunique() - tiff_tags = self._get_tiff_tags( - TiffFile(scene_files.filename.iloc[0], is_mmstack=False) - ) + tiff_tags = self._get_tiff_tags(TiffFile(scene_files.filename.iloc[0])) group_dims = [ x for x in scene_files.columns if x not in ["filename", *self.chunk_dims] @@ -366,9 +364,7 @@ def _read_delayed(self) -> xr.DataArray: dims = list(expanded_blocks_sizes.keys()) else: # assemble array in a single chunk - zarr_im = imread( - scene_files.filename.tolist(), aszarr=True, level=0, is_mmstack=False - ) + zarr_im = imread(scene_files.filename.tolist(), aszarr=True, level=0) darr = da.from_zarr(zarr_im).rechunk(-1) darr = darr.reshape(reshape_sizes) darr = darr.transpose(axes_order) @@ -407,9 +403,7 @@ def _read_immediate(self) -> xr.DataArray: scene_files = scene_files.drop(self.scene_glob_character, axis=1) scene_nunique = scene_files.nunique() - tiff_tags = self._get_tiff_tags( - TiffFile(scene_files.filename.iloc[0], is_mmstack=False) - ) + tiff_tags = self._get_tiff_tags(TiffFile(scene_files.filename.iloc[0])) chunk_sizes = self._get_chunk_sizes(scene_nunique) diff --git a/aicsimageio/readers/tiff_reader.py b/aicsimageio/readers/tiff_reader.py index 44a6fefd8..ca5d79e88 100644 --- a/aicsimageio/readers/tiff_reader.py +++ b/aicsimageio/readers/tiff_reader.py @@ -126,7 +126,7 @@ def __init__( def scenes(self) -> Tuple[str, ...]: if self._scenes is None: with self._fs.open(self._path) as open_resource: - with TiffFile(open_resource, is_mmstack=False) as tiff: + with TiffFile(open_resource) as tiff: # This is non-metadata tiff, just use available series indices self._scenes = tuple( metadata_utils.generate_ome_image_id(i) @@ -186,7 +186,6 @@ def _get_image_data( series=scene, level=0, chunkmode="page", - is_mmstack=False, ) as store: arr = da.from_zarr(store) arr = arr.transpose(transpose_indices) @@ -456,7 +455,7 @@ def _read_delayed(self) -> xr.DataArray: The file could not be read or is not supported. """ with self._fs.open(self._path) as open_resource: - with TiffFile(open_resource, is_mmstack=False) as tiff: + with TiffFile(open_resource) as tiff: # Get dims from provided or guess dims = self._get_dims_for_scene(tiff) @@ -509,7 +508,7 @@ def _read_immediate(self) -> xr.DataArray: The file could not be read or is not supported. """ with self._fs.open(self._path) as open_resource: - with TiffFile(open_resource, is_mmstack=False) as tiff: + with TiffFile(open_resource) as tiff: # Get dims from provided or guess dims = self._get_dims_for_scene(tiff) @@ -577,7 +576,7 @@ def _get_pixel_size( ) -> Tuple[Optional[float], Optional[float], Optional[float]]: """Return the pixel size in microns (z,y,x) for the given series in a tiff path.""" - with TiffFile(path_or_file, is_mmstack=False) as tiff: + with TiffFile(path_or_file) as tiff: tags = tiff.series[series_index].pages[0].tags if tiff.is_imagej: diff --git a/setup.py b/setup.py index c0ee4289c..3bc44d0cd 100644 --- a/setup.py +++ b/setup.py @@ -110,7 +110,7 @@ def run(self): "PyYAML>=6.0", "wrapt>=1.12", "resource-backed-dask-array>=0.1.0", - "tifffile>=2021.8.30", + "tifffile>=2021.8.30,<2023.3.15", "xarray>=0.16.1,<2023.02.0", "xmlschema", # no pin because it's pulled in from OME types "zarr>=2.6,<3",