origin module

LPS origin specification for image construction.

This module exposes a single small value type, Origin, which replaces the legacy three-kwarg dance (set_origin, set_corner, set_corner_lps) on the various zarr_to_* builders. Instances are constructed via classmethods that name what they mean, and translate to the legacy kwargs internally.

class aind_zarr_utils.origin.Origin(point=None, corner_code=None, corner_lps=None)[source]

Bases: object

LPS-origin specification for an anatomical image.

Construct via the classmethods:

  • default() — origin at LPS (0, 0, 0).

  • at() — origin set directly to the given LPS point.

  • at_corner() — origin chosen so that the named anatomical corner of the image lands at the given LPS point.

Internally this is a tagged union: at most one of point or the pair (corner_code, corner_lps) is set; both None means the default origin.

point: tuple[float, float, float] | None
corner_code: str | None
corner_lps: tuple[float, float, float] | None
classmethod default()[source]

Return an Origin sentinel meaning (0, 0, 0) in LPS.

Return type:

Origin

classmethod at(point)[source]

Return an Origin whose value is point in LPS millimeters.

Return type:

Origin

classmethod at_corner(corner_code, lps_point)[source]

Return an Origin that anchors a labelled corner to lps_point.

Parameters:
  • corner_code (str) – Three-letter anatomical corner code (e.g. "RAI" for the Right-Anterior-Inferior corner of the volume).

  • lps_point (tuple[float, float, float]) – Target LPS coordinates of that corner, in millimeters.

Return type:

Origin

__init__(point=None, corner_code=None, corner_lps=None)

Overview

Origin replaces the legacy set_origin / set_corner / set_corner_lps argument group with one explicit value.

Examples

Default origin:

img = asset.image(level=3, origin=Origin.default())

Set origin directly:

img = asset.image(level=3, origin=Origin.at((0.0, 0.0, 0.0)))

Anchor a labelled corner:

img = asset.image(
    level=3,
    origin=Origin.at_corner("RAS", (0.0, 0.0, 0.0)),
)

Origin is only accepted when pipeline=False. Pipeline images and stubs use the corrected origin from the pipeline metadata.