Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update NDTIFF reader #145

Merged
merged 1 commit into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Comment on lines 140 to 142
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe now as_array returns a dask array without bring the data into memory, I think you can test and remove this comment

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this means that dask.array.to_zarr() brings data to memory if the store is a MemoryStore so this method cannot be consistent with other get_zarr() methods.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully this won't be a problem anymore after #132 and we refactor this.


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