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

Modify warning #220

Merged
merged 3 commits into from
Jun 12, 2024
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
35 changes: 20 additions & 15 deletions iohub/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from dask.array import to_zarr
from tqdm import tqdm
from tqdm.contrib.itertools import product
from tqdm.contrib.logging import logging_redirect_tqdm

from iohub._version import version as iohub_version
from iohub.ngff import Position, TransformationMeta, open_ome_zarr
Expand Down Expand Up @@ -336,14 +337,17 @@ def _convert_image_plane_metadata(self, fov, zarr_name: str):
if self.reader.str_channel_axis
else c_idx
)
missing_data_warning_issued = False
for z_idx in range(self.z):
metadata = fov.frame_metadata(t=t_idx, c=c_key, z=z_idx)
if metadata is None:
_logger.warning(
f"Cannot load data at timepoint {t_idx}, channel "
f"{c_idx}, filling with zeros. Raw data may be "
"incomplete."
)
if not missing_data_warning_issued:
missing_data_warning_issued = True
_logger.warning(
f"Cannot load data at P: {zarr_name}, T: {t_idx}, "
f"C: {c_idx}, filling with zeros. Raw data may be "
"incomplete."
)
continue
if not sorted_keys:
# Sort keys, ordering keys without dashes first
Expand Down Expand Up @@ -375,16 +379,17 @@ def __call__(self) -> None:
self._init_zarr_arrays()
# Run through every coordinate and convert in acquisition order
_logger.debug("Converting images.")
for zarr_pos_name, (_, fov) in tqdm(
zip(self.zarr_position_names, self.reader, strict=True),
total=len(self.reader),
desc="Converting images",
unit="FOV",
ncols=80,
):
zarr_img = self.writer[zarr_pos_name]["0"]
to_zarr(fov.xdata.data.rechunk(self.chunks), zarr_img)
self._convert_image_plane_metadata(fov, zarr_img.path)
with logging_redirect_tqdm():
for zarr_pos_name, (_, fov) in tqdm(
zip(self.zarr_position_names, self.reader, strict=True),
total=len(self.reader),
desc="Converting images",
unit="FOV",
ncols=80,
):
zarr_img = self.writer[zarr_pos_name]["0"]
to_zarr(fov.xdata.data.rechunk(self.chunks), zarr_img)
self._convert_image_plane_metadata(fov, zarr_img.path)
self.writer.zgroup.attrs.update(self.metadata)
self.writer.close()
self.reader.close()
2 changes: 1 addition & 1 deletion tests/ngff/test_ngff.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def test_write_ome_zarr(channels_and_random_5d, arr_name):
# round-trip test with the offical reader implementation
ext_reader = Reader(parse_url(dataset.zgroup.store.path))
node = list(ext_reader())[0]
assert node.metadata["name"] == channel_names
assert node.metadata["channel_names"] == channel_names
assert node.specs[0].datasets == [arr_name]
assert node.data[0].shape == random_5d.shape
assert node.data[0].dtype == random_5d.dtype
Expand Down
Loading