ngff_zarr.v09.zarr_metadata

OME-Zarr 0.9.dev1 metadata model (RFC-3).

0.9.dev1 is OME-Zarr 0.6 plus RFC-3: an image may declare any number of axes, with any names, any type strings, and in any order. The RFC-5 coordinate-system and transformation model of 0.6 is unchanged.

The dataclasses here carry no version condition. The axis restrictions live in

mod:

ngff_zarr.structural_validation and are applied against the target version by the writer.

This module defines :class:Axis, :class:CoordinateSystem and

class:

Metadata; every other symbol is re-exported from

mod:

ngff_zarr.v06.zarr_metadata.

Module Contents

Classes

Axis

An RFC-3 axis.

CoordinateSystem

A named set of RFC-3 axes.

Metadata

OME-Zarr 0.9.dev1 multiscales metadata.

Functions

_get_axis_fields

Valid field names of :class:Axis, cached.

_filter_axis_dict

Filter an axis dict down to the recognized :class:Axis fields.

_axis_from

Re-instantiate any version’s axis object as a v0.9.dev1 :class:Axis.

Data

API

ngff_zarr.v09.zarr_metadata.__all__

[‘Affine’, ‘Axis’, ‘BaseTransform’, ‘CoordinateSystem’, ‘CoordinateSystemIdentifier’, ‘Coordinates’,…

ngff_zarr.v09.zarr_metadata.logger

‘getLogger(…)’

ngff_zarr.v09.zarr_metadata.AxisName

None

ngff_zarr.v09.zarr_metadata.AxesType

None

class ngff_zarr.v09.zarr_metadata.Axis

An RFC-3 axis.

Same fields as :class:ngff_zarr.v06.zarr_metadata.Axis, with name, type and unit widened: each keeps the spec-defined vocabulary in a union with the free-form string RFC-3 allows.

orientation (RFC-4) and discrete (RFC-5) are carried so a 0.6 document round-trips without loss.

name: ngff_zarr.v09.zarr_metadata.AxisName

None

type: ngff_zarr.v09.zarr_metadata.AxesType

None

unit: ngff_zarr.v04.zarr_metadata.AxisUnit | None

None

orientation: ngff_zarr.rfc4.AnatomicalOrientation | None

None

discrete: bool | None

None

class ngff_zarr.v09.zarr_metadata.CoordinateSystem

A named set of RFC-3 axes.

name: str

None

axes: list[ngff_zarr.v09.zarr_metadata.Axis]

None

ngff_zarr.v09.zarr_metadata._get_axis_fields() → set[str]

Valid field names of :class:Axis, cached.

ngff_zarr.v09.zarr_metadata._filter_axis_dict(axis_dict: dict) → dict

Filter an axis dict down to the recognized :class:Axis fields.

Unknown keys are logged and dropped. The 0.6 axes schema permits keys this dataclass does not declare, such as longName.

Raises

ValueError If the required name key is absent.

ngff_zarr.v09.zarr_metadata._axis_from(axis: object) → ngff_zarr.v09.zarr_metadata.Axis

Re-instantiate any version’s axis object as a v0.9.dev1 :class:Axis.

discrete is read with :func:getattr: v06.Metadata._from_v05 assigns the v0.5 axis list straight into a CoordinateSystem, so a v0.6 Metadata reached from a 0.4/0.5 store holds v0.4 Axis instances, which have no discrete field.

class ngff_zarr.v09.zarr_metadata.Metadata

OME-Zarr 0.9.dev1 multiscales metadata.

Same fields as :class:ngff_zarr.v06.zarr_metadata.Metadata. It carries coordinateSystems, not the flat axes list of v0.4/v0.5, so the v0.6 <-> 0.9.dev1 hop is a lossless structural copy; routing through v0.5 would drop every rotation, affine, coordinates and displacements transform.

There is no version field, as in v0.5 and v0.6. From v0.5 on the spec version lives in the group-level ome namespace, written by to_ngff_zarr._write_root_ome_attrs from the writer’s version argument. A field here would be emitted by asdict inside the multiscales[] entry, which the ome-namespace rule rejects.

coordinateSystems: list[ngff_zarr.v09.zarr_metadata.CoordinateSystem]

None

datasets: list[ngff_zarr.v06.zarr_metadata.Dataset]

None

coordinateTransformations: list[ngff_zarr.v06.zarr_metadata.Transform] | None

None

omero: ngff_zarr.v06.zarr_metadata.Omero | None

None

name: str

‘image’

type: str | None

None

metadata: ngff_zarr.v06.zarr_metadata.MethodMetadata | None

None

extra: dict

‘field(…)’

__post_init__()

On-the-fly validation not well covered by the JSON schemas.

property intrinsic_coordinate_system: ngff_zarr.v09.zarr_metadata.CoordinateSystem
property axes: list[ngff_zarr.v09.zarr_metadata.Axis]

The intrinsic coordinate system’s axes.

A property, not a field, so dataclasses.asdict and dataclasses.fields ignore it and the serialized entry is unchanged. The axis rules in :mod:ngff_zarr.structural_validation read metadata.axes.

property dimension_names: tuple
to_version(
version: Union[str, ngff_zarr._supported_versions.NgffVersion],
) → Union[ngff_zarr.v09.zarr_metadata.Metadata, ngff_zarr.v04.zarr_metadata.Metadata, ngff_zarr.v05.zarr_metadata.Metadata, ngff_zarr.v06.zarr_metadata.Metadata]
classmethod from_version(
metadata: Union[ngff_zarr.v09.zarr_metadata.Metadata, ngff_zarr.v04.zarr_metadata.Metadata, ngff_zarr.v05.zarr_metadata.Metadata, ngff_zarr.v06.zarr_metadata.Metadata],
) → ngff_zarr.v09.zarr_metadata.Metadata
_to_v06() → ngff_zarr.v06.zarr_metadata.Metadata

Structurally map to v0.6, re-instantiating every axis.

This does not enforce the v0.6 axis restrictions; the writer applies them against the target version. This converter is also used on the way to v0.5 and v0.4.

classmethod _from_v06(
metadata_v06: ngff_zarr.v06.zarr_metadata.Metadata,
) → ngff_zarr.v09.zarr_metadata.Metadata

Structurally map from v0.6, re-instantiating every axis.

v06.Metadata._from_v05 assigns the v0.5 axis list straight into CoordinateSystem.axes, so a v0.6 Metadata reached from a 0.4/0.5 store holds v0.4 Axis objects, in the same list object. Aliasing them would share mutable state with the source, drop fields under dataclasses.asdict (which walks the runtime class), and break equality, which dataclasses compare class-exact.

classmethod _from_zarr_attrs(
root_attrs: dict,
store: ngff_zarr._store_types.StoreLike,
validate: bool = False,
subpath: str | None = None,
) → tuple[ngff_zarr.v09.zarr_metadata.Metadata, list[ngff_zarr.ngff_image.NgffImage]]

Read a 0.9.dev1 store.

Dataset transform parsing and NgffImage construction are delegated to the v0.6 reader. Handled here first:

  1. validate=True runs the schema pass against the bundled spec/0.9 tree, which holds the schemas of the 0.9.dev1 release. The delegate then runs with validate=False: it would otherwise measure the document against the schemas of its own version.

  2. A 0.5-shaped entry (flat axes, no coordinateSystems) is normalized to a single intrinsic coordinate system, so either shape is readable.

  3. Unknown axis keys are stripped; the v0.6 reader builds axes with a bare Axis(**axis).