pymif.microscope_manager.zarr_manager

Classes

ZarrManager

A manager class for reading and handling OME-Zarr datasets.

Module Contents

class pymif.microscope_manager.zarr_manager.ZarrManager(path, chunks: Tuple[int, Ellipsis] = None, mode: str = 'r', metadata: dict[str, Any] = None, ngff_version: str | None = None, zarr_format: int | None = None)[source]

Bases: pymif.microscope_manager.microscope_manager.MicroscopeManager

A manager class for reading and handling OME-Zarr datasets.

Supports both: - NGFF / OME-Zarr v0.4 -> metadata in root/group attrs directly - NGFF / OME-Zarr v0.5 -> metadata in attrs[“ome”]

path[source]
chunks = None[source]
mode = 'r'[source]
metadata = None[source]
ngff_version: str | None = None[source]
ngff_version_override = None[source]
zarr_format_override = None[source]
_get_image_meta(group: zarr.Group) dict[str, Any][source]

Return the image metadata dictionary for either NGFF v0.4 or v0.5.

v0.5 -> group.attrs[“ome”] v0.4 -> group.attrs

_get_multiscales(group: zarr.Group) list[dict[str, Any]][source]

Return the NGFF multiscales block for group regardless of version.

_get_omero(group: zarr.Group) dict[str, Any][source]

Return the OMERO-style channel metadata stored on group.

_extract_metadata(data_levels: List[dask.array.Array], datasets: list[dict[str, Any]], multiscales: dict[str, Any], omero: dict[str, Any]) Dict[str, Any][source]

Translate NGFF metadata blocks into the normalized PyMIF metadata schema.

_read_multiscale_group(group: zarr.Group) tuple[List[dask.array.Array], List[Any], Dict[str, Any]][source]

Load one multiscale image group as dask arrays plus normalized metadata.

read() Tuple[List[dask.array.Array], Dict[str, Any]][source]

Read the root image plus discover additional image groups and labels.

The root image is exposed through self.data and self.metadata. Additional multiscale subgroups are indexed in self.groups and label pyramids in self.labels.

_load_group(name)[source]

Attempt to load a named subgroup if it contains NGFF image metadata.

_load_labels() Dict[str, List[dask.array.Array]][source]

Discover label pyramids stored below the root labels group.

add_label(label_levels: List[dask.array.Array], label_name: str = 'new_label', compressor: Any = None, compressor_level: Any = 3, parallelize: Any = False) None[source]

Register a new multiscale label pyramid in the current zarr store.

visualize_zarr(viewer: napari.Viewer | None = None) napari.Viewer | None[source]

Open the root image and all multiscale subgroups in napari.

create_empty_group(group_name: str, metadata: Dict[str, Any], is_label: bool = False)[source]

Create an empty image subgroup or label subgroup below the current root.

write_image_region(data, t: int | slice = slice(None), c: int | slice = slice(None), z: int | slice = slice(None), y: int | slice = slice(None), x: int | slice = slice(None), level: int = 0, group: str | None = None)[source]

Write an image patch into a root or subgroup pyramid and refresh lower levels.

write_label_region(data, t: int | slice = slice(None), z: int | slice = slice(None), y: int | slice = slice(None), x: int | slice = slice(None), level: int = 0, group: str = None)[source]

Write a label patch into a label pyramid and regenerate coarser levels.