acia.selection#
Selection manifest — persist curation and reconstruct lazy crops.
A SelectionManifest records a set of ROI selections (position + rotated
rectangle) plus the source metadata baked in (pixel size, timing, axes), so
downstream analysis reconstructs only the selected crops — lazily — without
re-opening the original (possibly hundreds-of-GB) file for calibration.
load_selection() turns a manifest back into a list of lazy cropped
ImageSequenceSource views, optionally against a different
file (“load file, apply selection, work only on the crops”). No pixel data is
read while building the crops; each is a lazy rotated-rectangle view.
- class acia.selection.RoiSelection[source]#
Bases:
objectOne curated ROI: a rotated-rectangle crop of a single position.
- Variables:
position (int) – Index of the position the ROI was drawn on.
roi (acia.base.RotatedCropSpec) – The rotated rectangle, in the pixel coordinate system of the frame it was drawn on – see
anchor_frame.label (str) – Free-text label, shown in the curation UI and available to export naming templates.
id (str) – Stable identifier; also names the preview PNG.
notes (str) – Free-text notes.
preview (str | None) – Optional file name of a preview image for this ROI.
anchor_frame (int) – The frame index
roiwas drawn on. Cropping the raw source ignores this – the spec is already in that source’s coordinates. It matters after drift correction: aRegisteredSequenceSourceputs every frame into the reference frame’s coordinate system, so a spec anchored anywhere else must first be carried across withacia.registration.apply_correction_to_spec()or the crop lands off by the drift accumulated up to this frame. Defaults to0, which is what every selection written before this field existed in fact was – frame 0 was the only frame the editor showed.
- roi: RotatedCropSpec#
- property spec: RotatedCropSpec#
The rotated-crop spec (image pixels), usable by
crop_rotated.
- class acia.selection.SelectionManifest[source]#
Bases:
objectA curation result: selections + baked-in source metadata.
- selections: list[RoiSelection]#
- classmethod load(path)[source]#
Read a manifest from a
selection.jsonfile.- Parameters:
path (str | PathLike) – The
selection.jsonfile, or the directory containing it — i.e. the same directorysave_selection()was given, so a caller can round-trip an output dir without restating the filename.- Return type:
- acia.selection.make_source_block(seqfile)[source]#
Build the manifest
sourceblock from aSequenceFile.Bakes in the metadata (pixel size, timing, axes, channels) and a
(size, mtime)fingerprint so a moved/changed file can be detected later.- Return type:
- acia.selection.save_selection(manifest, directory, *, previews=None)[source]#
Write
selection.json(+ optionalpreviews/*.png) intodirectory.- Parameters:
- Returns:
The path to the written
selection.json.- Return type:
- acia.selection.load_selection(manifest, source=None)[source]#
Reconstruct lazy cropped sources from a manifest.
Each selection becomes
seqfile.position(i).crop_rotated(spec)— a lazy rotated-rectangle view; no pixel data is read here. Calibration comes from the (possibly overriding) source. The returned sources carry.selectionand.labelattributes so the ROI’s identity is recoverable.- Parameters:
manifest (SelectionManifest) – The manifest to reconstruct.
source –
Noneto open the manifest’s original file, a path/str to apply the selections to a different file, or an already-openSequenceFile.
- Returns:
A list of lazy cropped
ImageSequenceSource(one per selection).- Return type:
Note
Each selection’s
anchor_frameis deliberately ignored here: the crop is taken from the raw source, whose coordinate system is the one the ROI was drawn in, so the spec already applies as-is. It only needs translating once the source has been drift-corrected onto a reference frame – seeacia.registration.apply_correction_to_spec().- Raises:
ValueError – If a selection’s
positionis out of range for the source.- Parameters:
manifest (SelectionManifest)
- Return type: