Reader

Reads an OME-Zarr 0.5 image. For a plate, open one of its fields.

class ome_zarr_io.Reader(path)

Reads and validates an OME-Zarr 0.5 image (a Zarr group with multiscales).

Open an existing OME-Zarr image for reading.

Parameters:

path (str | Path) – Path to the image group (the directory containing zarr.json). For a plate, pass one of its fields, e.g. plate.zarr/A/1/0.

Raises:

FileNotFoundError – If no zarr group exists at path.

validate(strict=False)

Validate the image (and any attached labels) against the OME-Zarr 0.5 schema.

Parameters:

strict (bool) – If True, validate against the strict_image/strict_label schemas instead of the permissive image/label schemas.

Returns:

True if the image is valid.

Raises:

jsonschema.exceptions.ValidationError – If validation fails.

Return type:

bool

get_validation_errors(strict=False)

Return a list of validation error messages instead of raising.

Parameters:

strict (bool)

Return type:

List[str]

report(strict=False)

Return a structured FilesetReport (validity plus a summary of the image).

Unlike validate(), this never raises for invalid metadata; see ome_zarr_io.validate for details.

Parameters:

strict (bool)

Return type:

FilesetReport

property channel_names: List[str]

Names of channels defined in the OMERO metadata, in axis order.

get_channel(name, level=0, as_type='dask')

Get image data for a single channel, selected by name.

Parameters:
  • name (str) – Channel name, matched against omero.channels[i].label.

  • level (int) – Multiscale pyramid level to read (0 = full resolution; negative values count from the coarsest level).

  • as_type (Literal['dask', 'numpy']) – Return a “dask” (lazy) or “numpy” (in-memory) array.

Returns:

Array with the channel (‘c’) axis removed.

Raises:
  • KeyError – If no channel with that name exists, or the array listed for level is missing.

  • ValueError – If the image has no channel (‘c’) axis.

  • IndexError – If level is out of range.

Return type:

Array | ndarray

property label_names: List[str]

Names of label images attached under the labels/ subgroup.

get_label(name, level=0, as_type='dask')

Get a label image by name.

Parameters:
  • name (str) – Label name as listed in label_names.

  • level (int) – Multiscale pyramid level of the label to read (0 = full resolution; negative values count from the coarsest level).

  • as_type (Literal['dask', 'numpy']) – Return a “dask” (lazy) or “numpy” (in-memory) array.

Raises:
  • KeyError – If no label with that name exists, or the array listed for level is missing.

  • ValueError – If the label has no valid multiscales metadata.

  • IndexError – If level is out of range.

Return type:

Array | ndarray

property dims: List[str]

Axis names (e.g. [‘t’, ‘c’, ‘z’, ‘y’, ‘x’]) for the base image.

property axes: List[Axis]

Axis metadata objects (name/type/unit) for the base image.

property n_levels: int

Number of multiscale pyramid levels available.

get_physical_size(level=0)

Get the physical pixel/voxel size for each spatial and time axis.

Parameters:

level (int) – Multiscale pyramid level to compute sizes for.

Returns:

Mapping of axis name (e.g. “z”, “y”, “x”, “t”) to a PhysicalSize, for every non-channel axis.

Raises:

IndexError – If level is out of range.

Return type:

Dict[str, PhysicalSize]

get_voxel_size(level=0)

Get the spatial (‘z’, ‘y’, ‘x’) pixel/voxel size at the given level.

Raises:

ValueError – If a spatial axis has no unit assigned in metadata.

Parameters:

level (int)

Return type:

Dict[str, float]

class ome_zarr_io.PhysicalSize(value, unit)

Physical size of a single axis (e.g. pixel/voxel spacing).

Parameters:
value: float
unit: str | None