Skip to content
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ dependencies = [
"pooch",
"polars",
"pyarrow",
"pillow",
]

# https://peps.python.org/pep-0621/#dependencies-optional-dependencies
Expand Down Expand Up @@ -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"]

Expand Down
2 changes: 1 addition & 1 deletion src/ngio/images/_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/ngio/images/_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
21 changes: 21 additions & 0 deletions tests/unit/images/test_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
15 changes: 15 additions & 0 deletions tests/unit/images/test_omezarr_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")