ngff_zarr.rfc4_validation

RFC 4 validation for anatomical orientation in OME-NGFF.

This module provides validation for RFC 4 anatomical orientation metadata against the JSON schema.

Module Contents

Functions

load_rfc4_orientation_schema

Load the RFC 4 orientation JSON schema.

validate_rfc4_orientation

Validate RFC 4 anatomical orientation metadata against the JSON schema.

has_any_rfc4_orientation

Whether any axis carries a non-empty orientation.

has_rfc4_orientation_metadata

Check if the axes contain RFC 4 anatomical orientation metadata.

Data

API

ngff_zarr.rfc4_validation.load_rfc4_orientation_schema() dict

Load the RFC 4 orientation JSON schema.

ngff_zarr.rfc4_validation._ANATOMICAL_AXIS_OF: dict[str, str]

None

ngff_zarr.rfc4_validation.validate_rfc4_orientation(axes: list[dict[str, Any]]) None

Validate RFC 4 anatomical orientation metadata against the JSON schema.

Parameters

axes : List[Dict[str, Any]] List of axis metadata dictionaries to validate

Raises

ImportError If jsonschema is not available jsonschema.ValidationError If the orientation metadata is invalid ValueError If orientation is illegally defined. The messages carry stable marker substrings – "must be anatomical" (type other than the single value the vocabulary defines), "non-space axes" (orientation on a non-spatial axis) and "same anatomical axis" (two axes on one antonym pair) – that :func:ngff_zarr.structural_validation.validate_axis_orientation reads to map each failure onto its :class:SpecRule. These markers are a load-bearing contract pinned by a message-stability test (test_rfc4_orientation_messages_carry_mapping_markers) so the mapping cannot silently break if the wording is later edited.

Notes

RFC 4 makes orientation optional per spatial axis: an image may orient only some of its spatial axes, and an absent orientation is equivalent to an explicit null (the axis orientation is undefined). No all-or-none completeness rule is enforced.

ngff_zarr.rfc4_validation.has_any_rfc4_orientation(axes: list[dict[str, Any]]) bool

Whether any axis carries a non-empty orientation.

Func:

has_rfc4_orientation_metadata answers the narrower question of whether a spatial axis is oriented, which is what callers deciding whether to record orientation want. Callers deciding whether to validate want this one: an orientation on a non-spatial axis is itself an RFC 4 violation, so skipping validation because no spatial axis is oriented is precisely how that violation goes unreported.

Only None and {} are undefined under RFC 4, which is the pair

Func:

validate_rfc4_orientation skips. Any other value, a falsey [], "", 0 or False included, is malformed rather than absent and so must reach the validator.

Parameters

axes : List[Dict[str, Any]] List of axis metadata dictionaries

Returns

bool True if any axis carries an orientation that is neither absent nor empty

ngff_zarr.rfc4_validation.has_rfc4_orientation_metadata(axes: list[dict[str, Any]]) bool

Check if the axes contain RFC 4 anatomical orientation metadata.

Parameters

axes : List[Dict[str, Any]] List of axis metadata dictionaries

Returns

bool True if any spatial axis has orientation metadata