acia.registration_persistence#

Registration manifest — persist drift-correction transforms and reconstruct lazy corrected sources.

A RegistrationManifest records, per position, the per-frame FrameTransform estimated by a chosen RegistrationMethod against that position’s own frame 0 – plus the source metadata baked in (pixel size, timing, axes), mirroring acia.selection’s manifest pattern exactly.

load_registration() turns a manifest back into a dict of lazy RegisteredSequenceSource views (position index -> source), optionally against a different file (“load file, apply registration, work only on the corrected sequence”). No pixel data is read while reconstructing.

class acia.registration_persistence.RegistrationRecord[source]#

Bases: object

One position’s registration result: per-frame transforms + failures.

Every transform is expressed relative to reference_frame, whatever frame was actually compared against to compute it. reference_mode and reference_frames record how they were obtained (see ReanchoringReference), which matters when resuming a partially-registered position: progress made under one policy is not valid to continue under another.

Variables:
  • reference_mode (str) – The reference policy this record was produced under – one of MODES. Defaults to "fixed" so a manifest written before the policy existed loads as what it in fact was.

  • reference_frames (dict[int, int]) – frame -> anchor for the frames that were estimated against something other than reference_frame. Only the exceptions are stored; a purely fixed-reference run leaves this empty and serializes without the key at all.

position: int#
method: str#
transforms: dict[int, FrameTransform]#
reference_frame: int = 0#
failed_frames: dict[int, str]#
notes: str = ''#
reference_mode: str = 'fixed'#
reference_frames: dict[int, int]#
to_dict()[source]#
Return type:

dict

classmethod from_dict(data)[source]#
Parameters:

data (dict)

Return type:

RegistrationRecord

__init__(position, method, transforms, reference_frame=0, failed_frames=<factory>, notes='', reference_mode='fixed', reference_frames=<factory>)#
Parameters:
Return type:

None

class acia.registration_persistence.RegistrationManifest[source]#

Bases: object

A batch-apply result: per-position records + baked-in source metadata.

Variables:

method_params (dict) – The settings the registration method was constructed with (min_confidence, exclude_shrink_px, …), so a run is reproducible from the file rather than only from the notebook that produced it. Only JSON-representable values are kept; anything else is stringified.

source: dict#
records: list[RegistrationRecord]#
method: str = ''#
schema: str = 'acia.registration/v1'#
created: str | None = None#
method_params: dict#
property source_path: str#

Path of the original file the registration was estimated against.

to_dict()[source]#
Return type:

dict

classmethod from_dict(data)[source]#
Parameters:

data (dict)

Return type:

RegistrationManifest

save(path)[source]#

Write the manifest as pretty JSON; returns the written path.

Parameters:

path (str | PathLike)

Return type:

str

classmethod load(path)[source]#

Read a manifest from a registration_transforms.json file.

Parameters:

path (str | PathLike)

Return type:

RegistrationManifest

__init__(source, records=<factory>, method='', schema='acia.registration/v1', created=None, method_params=<factory>)#
Parameters:
Return type:

None

acia.registration_persistence.save_registration(manifest, directory)[source]#

Write registration_transforms.json into directory.

Parameters:
  • manifest (RegistrationManifest) – The manifest to persist.

  • directory (str | PathLike) – Output directory (created if missing) — typically beside the notebook.

Returns:

The path to the written registration_transforms.json.

Return type:

str

acia.registration_persistence.load_registration(manifest, source=None, *, on_missing='warn')[source]#

Reconstruct lazy registered sources from a manifest.

Each completed record becomes seqfile.position(record.position).register( record.transforms) — a lazy per-frame-corrected view; no pixel data is read here. Calibration comes from the (possibly overriding) source.

Parameters:
  • manifest (RegistrationManifest) – The manifest to reconstruct.

  • sourceNone to open the manifest’s original file, a path/str to apply the records to a different file, or an already-open SequenceFile.

  • on_missing (str) – How each reconstructed view should handle a frame that has no stored transform (one that landed in failed_frames) — see RegisteredSequenceSource.

Returns:

dict[int, ~acia.base.RegisteredSequenceSource] – Position index -> lazy registered source, one entry per record in the manifest.

Raises:

ValueError – If a record’s position is out of range for the source.

Return type:

dict