Skip to content

Commit

Permalink
Revert to pre-2023.3.15 tifffile to avoid mm_stack issue
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanLeRoy committed Aug 16, 2023
1 parent 04a92f7 commit c457dd7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 20 deletions.
6 changes: 3 additions & 3 deletions aicsimageio/readers/ome_tiff_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down
16 changes: 5 additions & 11 deletions aicsimageio/readers/tiff_glob_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
9 changes: 4 additions & 5 deletions aicsimageio/readers/tiff_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit c457dd7

Please sign in to comment.