ngff_zarr.parse_metadata

Module Contents

Functions

_extract_method_metadata

_parse_omero

Parse OMERO metadata dictionary into Omero dataclass.

_parse_hcs_path

Parse a potential HCS path into store and sub-path components.

_is_hcs_plate

Check if root attributes indicate an HCS plate structure.

_is_bioformats2raw

Check if root attributes indicate a bioformats2raw container layout.

_get_bioformats2raw_series

Get the list of image paths from a bioformats2raw container.

_detect_version

Detect NGFF version from root attributes.

API

ngff_zarr.parse_metadata._extract_method_metadata(
metadata_dict: dict,
) tuple[ngff_zarr.methods.Methods | None, str | None, ngff_zarr.v04.zarr_metadata.MethodMetadata | None]
ngff_zarr.parse_metadata._parse_omero(
omero_data: Union[dict, None],
) Optional[ngff_zarr.v04.zarr_metadata.Omero]

Parse OMERO metadata dictionary into Omero dataclass.

ngff_zarr.parse_metadata._parse_hcs_path(store_path: str) tuple[str, str | None]

Parse a potential HCS path into store and sub-path components.

Parameters

store_path : str Path that may contain a zarr store with an optional sub-path (e.g., ‘plate.zarr/A/1/0’)

Returns

store : str The path to the zarr store (preserves original path separators) subpath : str or None The sub-path within the store using forward slashes, or None if no sub-path

Examples

_parse_hcs_path(‘plate.zarr’) (‘plate.zarr’, None) _parse_hcs_path(‘plate.zarr/A/1/0’) (‘plate.zarr’, ‘A/1/0’) _parse_hcs_path(‘/path/to/plate.ome.zarr/B/2’) (‘/path/to/plate.ome.zarr’, ‘B/2’)

ngff_zarr.parse_metadata._is_hcs_plate(root_attrs: dict) bool

Check if root attributes indicate an HCS plate structure.

Returns True if this is an HCS plate (not a regular image group).

ngff_zarr.parse_metadata._is_bioformats2raw(root_attrs: dict) bool

Check if root attributes indicate a bioformats2raw container layout.

bioformats2raw produces OME-Zarr containers where the root level has a bioformats2raw.layout key (v0.4) or an ome key containing bioformats2raw.layout (v0.5), with the actual image data stored in numbered subdirectories (0/, 1/, …).

Returns True if the root is a bioformats2raw container (not a regular image group).

ngff_zarr.parse_metadata._get_bioformats2raw_series(root) list

Get the list of image paths from a bioformats2raw container.

Reads the series array from the OME subgroup if available, otherwise falls back to enumerating subgroups in the root.

Parameters

root : zarr.Group The root zarr group of the bioformats2raw container.

Returns

list of str Sorted list of image path strings (e.g., ["0", "1", "2"]).

ngff_zarr.parse_metadata._detect_version(root_attrs: dict) ngff_zarr._supported_versions.NgffVersion

Detect NGFF version from root attributes.

Handles both regular image groups and HCS plate structures.