acia.tracking.formats#
Module to convert tracking formats
- acia.tracking.formats.parse_simple_tracking(file_content)[source]#
Parse simple tracking format from file content string
- acia.tracking.formats.gen_simple_tracking(overlay, tracking_graph)[source]#
Create a simple tracking format from overlay and tracking graph
- acia.tracking.formats.write_ctc_tracking(output_path, images, overlay, tracklet_graph)[source]#
Write ctc tracking to output folder
- Parameters:
output_path (Path) – output folder for writing
images (ImageSequenceSource) – image time-lapse (only used to compute mask sizes)
overlay (Overlay) – segmentation overlay
tracklet_graph (nx.DiGraph) – tracklet graph (every cell cycle is a node)
- acia.tracking.formats.save_tracking(path, images, overlay, tracklet_graph)[source]#
Store a tracking result as a CTC folder, guaranteeing full frame coverage.
The counterpart of
load_tracking(), and the recommended way to persist a tracker’s(overlay, tracklet_graph)output. It wrapswrite_ctc_tracking()and adds the one guarantee that function cannot give on its own: the written mask stack is aligned withimages.write_ctc_trackingnames its masks by enumeratingtimeIterator(), which starts at the overlay’s first populated frame when the overlay carries no explicit frame list. An overlay whose frame 0 happens to hold no detections would therefore write a stack shifted against the movie – every reloaded detection landing on the wrong frame, with no error anywhere. This function re-wraps such an overlay overrange(images.size_t)first (the caller’s overlay is not mutated).- Parameters:
path (str | Path) – output directory (created if missing). It must be owned by this artifact:
load_tracking()reads every*.tifin it.images (ImageSequenceSource) – the image sequence the tracking was computed on – used for the mask size and the frame extent.
overlay (Overlay) – tracked overlay;
labelcarries the tracklet id.tracklet_graph (DiGraph) – one node per tracklet (
start_frame/end_frame).
- Returns:
The directory written.
- Raises:
ValueError – if the overlay holds a frame beyond
images.size_t, i.e. overlay and images do not belong to the same sequence.- Return type:
- acia.tracking.formats.load_tracking(path, source)[source]#
Load a tracking stored by
save_tracking(), with time re-attached.Returns the same
(overlay, tracklet_graph, tracking_graph)triple, in the same order, that a tracking processor (e.g.TrackastraTracker) returns – so a step that loads is a drop-in for a step that tracked.This is not equivalent to
read_ctc_tracking(). That function builds the tracking graph while the reloaded overlay is still uncalibrated, andctc_track_graph()reads each detection’stimeto stamp its nodes – so re-attaching the time model afterwards leaves the graph timeless, and a lineage plotted overtime_feature="time"silently has nothing to plot. Here the calibration is attached first and the tracking graph is built from the calibrated overlay.Detection ids are not stable across this round-trip: the CTC mask format stores label images, so ids are renumbered on load (this is already true of the trackers themselves, which round-trip through the same format). After tracking,
label– the tracklet id – is the stable key; do not join these ids against a property table exported before tracking.- Parameters:
path (str | Path) – the CTC directory written by
save_tracking().source (ImageSequenceSource) – the image sequence the tracking was computed on. Required: it is the only carrier of the time calibration.
- Returns:
(overlay, tracklet_graph, tracking_graph). Whensourceis uncalibrated, the graphs simply carry no time attributes.- Raises:
FileNotFoundError – if the directory or its
man_track.txtis missing.- Return type:
- acia.tracking.formats.ctc_track_graph(ov, tracklet_graph)[source]#
Computes the ctc track graph (every cell detection is a node) based on cell detections (overlay) and the tracklet graph (every tracklet is one node).
Hint: overlay labels and tracklet_graph node ids need to align.
- Parameters:
ov (Overlay) – _description_
tracklet_graph (nx.DiGraph) – _description_
- Returns:
_type_ – _description_
- acia.tracking.formats.tracking_to_graph(data)[source]#
Populates a ctc tracking into a full tracking lineage where every detection has its own node with a unique id based on (ctc_id, frame)
- Parameters:
data (list[dict]) – Output of
read_ctc_tracking()- Returns:
nx.DiGraph – A lineage graph where every detection has its unique node (id, frame) and the edges represent the linking
- Return type: