diff --git a/CHANGELOG.md b/CHANGELOG.md index efdd7fc3..cef81dfc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [v0.4.3] + +### Bug Fixes + +- Fix bug in deriving labels and image from OME-Zarr with non standard path names. +- Add missing pillow dependency. +- Update pixi workspace config. + ## [v0.4.2] ### API Changes diff --git a/pyproject.toml b/pyproject.toml index b25baf3c..086c8f7a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,6 +48,7 @@ dependencies = [ "pooch", "polars", "pyarrow", + "pillow", ] # https://peps.python.org/pep-0621/#dependencies-optional-dependencies @@ -186,7 +187,7 @@ source = ["ngio"] [tool.check-manifest] ignore = [".pre-commit-config.yaml", ".ruff_cache/**/*", "tests/**/*"] -[tool.pixi.project] +[tool.pixi.workspace] channels = ["conda-forge"] platforms = ["osx-arm64", "linux-64", "win-64"] diff --git a/src/ngio/images/_image.py b/src/ngio/images/_image.py index 2e21c875..ba6aea78 100644 --- a/src/ngio/images/_image.py +++ b/src/ngio/images/_image.py @@ -801,7 +801,7 @@ def derive_image_container( pixelsize=pixel_size.x, z_spacing=pixel_size.z, time_spacing=pixel_size.t, - levels=ref_meta.levels, + levels=ref_meta.paths, yx_scaling_factor=ref_meta.yx_scaling(), z_scaling_factor=ref_meta.z_scaling(), time_unit=pixel_size.time_unit, diff --git a/src/ngio/images/_label.py b/src/ngio/images/_label.py index 1f2d58d1..427d356b 100644 --- a/src/ngio/images/_label.py +++ b/src/ngio/images/_label.py @@ -318,7 +318,7 @@ def derive_label( pixelsize=ref_image.pixel_size.x, z_spacing=ref_image.pixel_size.z, time_spacing=ref_image.pixel_size.t, - levels=ref_meta.levels, + levels=ref_meta.paths, yx_scaling_factor=ref_meta.yx_scaling(), z_scaling_factor=ref_meta.z_scaling(), time_unit=ref_image.pixel_size.time_unit, diff --git a/tests/unit/images/test_images.py b/tests/unit/images/test_images.py index 92a649df..50988c9c 100644 --- a/tests/unit/images/test_images.py +++ b/tests/unit/images/test_images.py @@ -220,3 +220,24 @@ def test_zoom_virtual_axes( # Roi data should match exactly except for virtual axis assert img1_data.shape[1:] == img2_roi_data.shape[1:] img2.set_roi(roi=roi, patch=img2_roi_data, transforms=[zoom], axes_order="czyx") + + +def test_derive_image_consistency( + tmp_path: Path, +): + path1 = tmp_path / "image1.zarr" + ome_zarr = create_empty_ome_zarr( + store=path1, + shape=(3, 16, 16, 16), + axes_names="czyx", + xy_pixelsize=1.0, + levels=["s0", "s1", "s2"], + ) + ome_zarr_der = ome_zarr.derive_image(tmp_path / "derived_image.zarr") + assert ome_zarr.channel_labels == ome_zarr_der.channel_labels + assert ome_zarr.levels_paths == ome_zarr_der.levels_paths + assert ome_zarr.space_unit == ome_zarr_der.space_unit + assert ome_zarr.time_unit == ome_zarr_der.time_unit + + label = ome_zarr.derive_label("derived_label") + assert label.path == "s0" diff --git a/tests/unit/images/test_omezarr_container.py b/tests/unit/images/test_omezarr_container.py index 44226382..3ca9eeaf 100644 --- a/tests/unit/images/test_omezarr_container.py +++ b/tests/unit/images/test_omezarr_container.py @@ -296,3 +296,18 @@ def test_get_and_squeeze(tmp_path: Path): image.get_as_dask( channel_selection=ChannelSelectionModel(identifier="0", mode="index") ) + + +def test_derive_image_and_labels(tmp_path: Path): + # Testing for #116 + store = tmp_path / "ome_zarr.zarr" + ome_zarr = create_empty_ome_zarr( + store, + shape=(3, 20, 30), + xy_pixelsize=0.5, + levels=1, + axes_names=["c", "y", "x"], + dtype="uint8", + ) + derived_ome_zarr = ome_zarr.derive_image(tmp_path / "derived.zarr") + _ = derived_ome_zarr.derive_label("derived_label")