simplezarr.utils.multiscale

Support for multiscale images, most notably ome-zarr.

The purpose of this utility is to examine the metadata of a Zarr file and produce typed structures to easily process the data further.

OME-Zarr, a.k.a. next-generation file format (NGFF) builds on Zarr version 3, to define hierarchical datasets. This module implements the “multiscales” metadata, ignoring the transitional “bioformats2raw.layout” and “omero” metadata. In its current form, the “labels”, “plate” and “well” metadata are also ignored.

class simplezarr.utils.multiscale.MultiscaleInfo(name: str, axes_names: tuple[str, ...], unit: str, unit_factor: float, scales: list[ScaleInfo])

Bases: object

Represents a single multiscale image.

name: str

the name of this multiscale image

axes_names: tuple[str, ...]

the names of the axes/dimensions of the array

unit: str

the unit for the spatial dimension

unit_factor: float

the factor to map the unit to meters

scales: list[ScaleInfo]

more info per scale

classmethod from_zarr_node(zarr_node: ZarrGroup) list[MultiscaleInfo]

Given a zarr node, produce a list of MultiscaleInfo objects (one per multiscale dict in the metadata).

This information is geared for use by the simplezarr.chunkpool.ChunkPool.

class simplezarr.utils.multiscale.ScaleInfo(array: ZarrArray, level: int, mean_scale: float, spatial_shape: tuple[int, ...], spatial_scale: tuple[float, ...], spatial_offset: tuple[float, ...], spatial_chunk_shape: tuple[float, ...], nchannels: int, ntimes: int)

Bases: object

Information that represents a single scale in a multiscale image.

array: ZarrArray

the ZarrArray object

level: int

the integer level in the multiscale stack, 0 being the highest-resolution

mean_scale: float

the reference scale for this scale layer in world units (the average of the spatial scales)

spatial_shape: tuple[int, ...]

The shape of the spatial dimensions

spatial_scale: tuple[float, ...]

the scale factor for the spatial dimensions

spatial_offset: tuple[float, ...]

the offset for the spatial dimensions

nchannels: int

the number of channels for this image

ntimes: int

the number of time-frames for this image