Skip to content

Commit

Permalink
Update NDTIFF reader (#145)
Browse files Browse the repository at this point in the history
use new ndtiff and stop sorting axes
  • Loading branch information
ziw-liu authored Jun 20, 2023
1 parent aabfd2f commit 6cc6683
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
27 changes: 8 additions & 19 deletions iohub/ndtiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,32 +140,21 @@ 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,
self.slices,
self.height,
self.width,
)

# add singleton axes so output is 5D
return da.reshape(shape)

def get_array(self, position: int) -> np.ndarray:
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6cc6683

Please sign in to comment.