pymif.microscope_manager.zarr_manager
Classes
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)[source]
Bases:
pymif.microscope_manager.microscope_manager.MicroscopeManager
A manager class for reading and handling OME-Zarr datasets.
This class reads NGFF-compliant multiscale image data along with metadata and optional label layers from a Zarr directory. It supports lazy loading with Dask, label layer detection, and integration with Napari for visualization.
Parameters
- pathstr or Path
Path to the root directory of the OME-Zarr dataset.
- chunksTuple[int, …], optional
Chunk size to apply when reading arrays. If None, native chunking in the Zarr arrays is used.
- read() Tuple[List[dask.array.Array], Dict[str, Any]] [source]
Read an OME-Zarr dataset and extract both image data and metadata.
This method lazily loads the multiscale image pyramid and metadata from the root of the Zarr dataset. If /labels/ groups exist, they are also read into the self.labels attribute.
Returns
- data_levelsList[dask.array.Array]
List of Dask arrays, one for each resolution level.
- metadataDict[str, Any]
Dictionary containing image metadata such as axes, scales, sizes, channels, time increments, and units.
Raises
- ValueError
If the dataset structure is invalid or lacks required metadata.
- _load_labels() Dict[str, List[dask.array.Array]] [source]
Load label layers from the /labels/ group in the Zarr dataset.
Each label is stored as a multiscale pyramid similar to image data.
Returns
- labelsDict[str, List[dask.array.Array]]
Dictionary mapping each label name to its list of pyramid levels.
- 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]
Add a label layer to the Zarr dataset.
Parameters
- label_levelsList[dask.array.Array]
A list of arrays representing a label image pyramid.
- label_namestr, optional
Name of the label group (default is “new_label”).
- compressorAny, optional
Compression method to use when writing labels.
- compressor_levelAny, optional
Compression level to apply (default: 3).
- parallelizebool, optional
If True, label data is written in parallel.
- visualize_zarr(viewer: napari.Viewer | None = None) napari.Viewer [source]
Visualize the OME-Zarr dataset using Napari’s napari-ome-zarr plugin.
Parameters
- viewernapari.Viewer, optional
An existing viewer instance. If None, a new one will be created.
Returns
- viewernapari.Viewer
A Napari viewer instance with the image loaded.