From 6cc66832e1d1e07403ac2c7638d90708f1d21eab Mon Sep 17 00:00:00 2001 From: Ziwen Liu <67518483+ziw-liu@users.noreply.github.com> Date: Tue, 20 Jun 2023 11:32:19 -0700 Subject: [PATCH] Update NDTIFF reader (#145) use new ndtiff and stop sorting axes --- iohub/ndtiff.py | 27 ++++++++------------------- setup.cfg | 2 +- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/iohub/ndtiff.py b/iohub/ndtiff.py index 7955b063..86c83465 100644 --- a/iohub/ndtiff.py +++ b/iohub/ndtiff.py @@ -140,24 +140,13 @@ def get_zarr(self, position: int) -> zarr.array: # TODO: try casting the dask array into a zarr array # using `dask.array.to_zarr()`. # Currently this call brings the data into memory - - ax = [ - ax_ - for ax_ in ["position", "time", "channel", "z"] - if ax_ in self._axes - ] - - if "position" in self._axes.keys(): - # da is Dask array - da = self.dataset.as_array(axes=ax, position=position) - else: - if position not in (0, None): - warnings.warn( - f"Position index {position} is not part of this dataset." - f" Returning data at default position." - ) - da = self.dataset.as_array(axes=ax) - + if "position" not in self._axes.keys() and position not in (0, None): + warnings.warn( + f"Position index {position} is not part of this dataset. " + "Returning data at the default position." + ) + position = None + da = self.dataset.as_array(position=position) shape = ( self.frames, self.channels, @@ -165,7 +154,7 @@ def get_zarr(self, position: int) -> zarr.array: self.height, self.width, ) - + # add singleton axes so output is 5D return da.reshape(shape) def get_array(self, position: int) -> np.ndarray: diff --git a/setup.cfg b/setup.cfg index a1e570f0..073f37ac 100644 --- a/setup.cfg +++ b/setup.cfg @@ -33,7 +33,7 @@ install_requires = pydantic>=1.10.2 tifffile>=2023.2.3, <2023.3.15 natsort>=7.1.1 - ndtiff>=1.9.0 + ndtiff>=2.1.0 zarr>=2.13 tqdm pillow>=9.4.0