itasc.cellpose.retrack¶
DB-free greedy retracker for the standalone segment + track corrector.
This mirrors the constrained retracker in itasc.tracking_ultrack
(which ships in a separate itasc-tracking distribution the standalone
itasc-cellpose tool does not depend on), reduced to the validation-free
case the standalone needs: starting from the current frame, every later frame’s
labels are re-linked to the already-retracked neighbour toward the start frame
by the same additive similarity score (area ratio + centroid-corrected IoU -
distance), matched greedily best-first. Unmatched target cells receive fresh
ids. There is no locked/validated/reserved concept here — the standalone has no
validation store — so the algorithm is purely the geometric re-linking.
Everything here is Qt-free and depends only on numpy/scipy/skimage, so it ships inside the cellpose distro tree and is unit-testable without a viewer.
Functions
IoU after shifting the target so its centroid matches the source's. |
|
|
Remap every target id to its best-matching reference id by similarity. |
|
Retrack a time-first |
|
Additive similarity score (higher = more preferred). |
- itasc.cellpose.retrack.centroid_corrected_iou_from_coords(src_coords, src_centroid, target_coords, target_centroid)[source]¶
IoU after shifting the target so its centroid matches the source’s.
- itasc.cellpose.retrack.similarity_score(*, area_ratio, centroid_corrected_iou, distance, area_weight, iou_weight, distance_weight)[source]¶
Additive similarity score (higher = more preferred).
Shape terms are positive rewards in
[0, 1]; distance is a raw pixel penalty, so the score can go negative for far candidates.
- itasc.cellpose.retrack.retrack_frame(ref_labels, target_labels, *, max_dist_px=50.0, area_weight=1.0, iou_weight=1.0, distance_weight=0.05)[source]¶
Remap every target id to its best-matching reference id by similarity.
Each target cell takes its highest-scoring still-free reference cell (greedy best-first), among reference cells whose centroid is within
max_dist_px. Targets with no eligible reference get a fresh id above all existing ids, so no two cells ever collide. Returns a relabelled copy oftarget_labels(input arrays are not mutated).
- itasc.cellpose.retrack.retrack_stack(stack, *, start_frame, direction, max_dist_px=50.0, area_weight=1.0, iou_weight=1.0, distance_weight=0.05)[source]¶
Retrack a time-first
(T, Y, X)stack outward fromstart_frame.The start frame is kept as the anchor; each later frame in
directionis re-linked (retrack_frame()) to the already-retracked neighbour toward the start frame, so corrected ids propagate. Returns a new stack; the input is not mutated.