diff --git a/src/ngio/ngff_meta/fractal_image_meta.py b/src/ngio/ngff_meta/fractal_image_meta.py index 2ec156c..0f1a75f 100644 --- a/src/ngio/ngff_meta/fractal_image_meta.py +++ b/src/ngio/ngff_meta/fractal_image_meta.py @@ -652,10 +652,10 @@ def get_dataset( else: raise ValueError("get_dataset has no valid arguments.") - def get_highest_resolution(self) -> Dataset: + def get_highest_resolution_dataset(self) -> Dataset: """Get the dataset with the highest resolution.""" return self._get_dataset_by_pixel_size( - PixelSize(0.0, 0.0, 0.0, SpaceUnits.um), strict=False + pixel_size=PixelSize(x=0.0, y=0.0, z=0.0, unit=SpaceUnits.um), strict=False ) def scale(self, path: str | None = None, idx: int | None = None) -> list[float]: @@ -750,7 +750,11 @@ class ImageMeta(BaseMeta): """Image metadata model.""" def __init__( - self, version: str, name: str, datasets: list[Dataset], omero: Omero | None + self, + version: str, + name: str, + datasets: list[Dataset], + omero: Omero | None = None, ) -> None: """Initialize the ImageMeta object.""" super().__init__(version=version, name=name, datasets=datasets) diff --git a/src/ngio/ngff_meta/utils.py b/src/ngio/ngff_meta/utils.py index d26b3d9..78d8204 100644 --- a/src/ngio/ngff_meta/utils.py +++ b/src/ngio/ngff_meta/utils.py @@ -193,16 +193,14 @@ def remove_axis_from_metadata( metadata: ImageMeta, *, axis_name: str | None = None, - idx: int | None = None, ) -> ImageMeta: """Remove an axis from the metadata. Args: - metadata: A FractalImageMeta object. + metadata: A ImageMeta object. axis_name: The name of the axis to remove. - idx: The index of the axis to remove. """ - return metadata.remove_axis(axis_name=axis_name, idx=idx) + return metadata.remove_axis(axis_name=axis_name) def add_axis_to_metadata( @@ -210,10 +208,10 @@ def add_axis_to_metadata( axis_name: str, scale: float = 1.0, ) -> ImageMeta | LabelMeta: - """Add an axis to the FractalImageMeta or FractalLabelMeta object. + """Add an axis to the ImageMeta or LabelMeta object. Args: - metadata: A FractalImageMeta or FractalLabelMeta object. + metadata: A ImageMeta or LabelMeta object. axis_name: The name of the axis to add. scale: The scale of the axis """ diff --git a/tests/ngff_meta/test_fractal_image_meta.py b/tests/ngff_meta/test_fractal_image_meta.py index cc14ee8..94b51fe 100644 --- a/tests/ngff_meta/test_fractal_image_meta.py +++ b/tests/ngff_meta/test_fractal_image_meta.py @@ -11,19 +11,17 @@ def test_basic_workflow(self, ome_zarr_image_v04_path): fractal_meta = handler.load_meta() np.testing.assert_array_equal( - fractal_meta.pixel_size(level_path=0).zyx, + fractal_meta.pixel_size(idx=0).zyx, [1.0, 0.1625, 0.1625], ) np.testing.assert_array_equal( - fractal_meta.scale(level_path=0), [1.0, 1.0, 0.1625, 0.1625] + fractal_meta.scale(idx=0), [1.0, 1.0, 0.1625, 0.1625] ) assert fractal_meta.num_levels == 5 assert fractal_meta.levels_paths == ["0", "1", "2", "3", "4"] - assert fractal_meta.axes == fractal_meta.multiscale.axes - assert fractal_meta.datasets == fractal_meta.multiscale.datasets - assert fractal_meta.channel_names == ["DAPI", "nanog", "Lamin B1"] - assert fractal_meta.get_channel_idx_by_label("DAPI") == 0 - assert fractal_meta.get_channel_idx_by_wavelength_id("A01_C01") == 0 + assert fractal_meta.channel_labels == ["DAPI", "nanog", "Lamin B1"] + assert fractal_meta.get_channel_idx(label="DAPI") == 0 + assert fractal_meta.get_channel_idx(wavelength_id="A01_C01") == 0 assert fractal_meta.axes_names == ["c", "z", "y", "x"] assert fractal_meta.space_axes_names == ["z", "y", "x"] assert fractal_meta.get_highest_resolution_dataset().path == "0" @@ -43,7 +41,7 @@ def test_modify_axis_from_metadata(self, ome_zarr_image_v04_path): assert meta_no_channel.axes_names == ["z", "y", "x"] meta_add_channel = add_axis_to_metadata( - metadata=meta_no_channel, idx=0, axis_name="c", units=None + metadata=meta_no_channel, axis_name="c", scale=1.0 ) assert meta_add_channel.axes_names == fractal_meta.axes_names @@ -54,7 +52,7 @@ def test_pixel_size(self, ome_zarr_image_v04_path): store=ome_zarr_image_v04_path, meta_mode="image" ) - pixel_size = handler.load_meta().pixel_size(level_path=0) + pixel_size = handler.load_meta().pixel_size(idx=0) assert pixel_size.zyx == (1.0, 0.1625, 0.1625) def test_modify_axis_from_label_metadata(self, ome_zarr_label_v04_path): @@ -69,7 +67,5 @@ def test_modify_axis_from_label_metadata(self, ome_zarr_label_v04_path): meta_no_channel = fractal_meta.remove_axis(axis_name="z") assert meta_no_channel.axes_names == ["y", "x"] - meta_add_channel = meta_no_channel.add_axis( - idx=0, axis_name="z", units="micrometer", axis_type="space" - ) + meta_add_channel = meta_no_channel.add_axis(axis_name="z", scale=1.0) assert meta_add_channel.axes_names == fractal_meta.axes_names