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 the RFC 4 orientation JSON schema. |
|
Validate RFC 4 anatomical orientation metadata against the JSON schema. |
|
Whether any axis carries a non-empty |
|
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.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"(typeother 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_orientationreads 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
orientationoptional per spatial axis: an image may orient only some of its spatial axes, and an absent orientation is equivalent to an explicitnull(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_metadataanswers 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
Noneand{}are undefined under RFC 4, which is the pair- Func:
validate_rfc4_orientationskips. Any other value, a falsey[],"",0orFalseincluded, 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