traccuracy.metrics._complete_tracks_by_length
Module Contents
Classes
Fraction of fully correct tracks as a function of track length. |
- class traccuracy.metrics._complete_tracks_by_length.CompleteTracksByLength(max_length: int | None = None, lineages: bool = True, error_type: Literal[basic, ctc] = 'basic')[source]
Fraction of fully correct tracks as a function of track length.
This is the CTC-BIO Complete Tracks metric generalized to every track length: for each length from 1 to
max_length(in frames), it computes the accuracy (number correct / number total) of the ground truth track segments that span that many frames. At the maximum length this reduces toCompleteTracks.Length is measured in frames (time difference), not edge count. A segment of length N spans N frames from start to end. For example:
A segment of length 1 spans 1 frame (node at t=0 to node at t=1)
A segment of length 2 spans 2 frames (node at t=0 to node at t=2)
Skip edges that span multiple frames are decomposed into individual single-frame edges, each carrying the skip edge’s correctness. For example, a skip edge from t=0 to t=3 contributes three length-1 segments (t=0->1, t=1->2, t=2->3), and likewise contributes to the length-2 and length-3 totals.
At division points, all branches are included in the same segment - a segment is only correct if all branches are correct.
A segment is counted as correct if:
The starting node is a true positive
All edges along the path are true positives
Important counting rules:
Isolated nodes (nodes with no outgoing edges) are NOT counted
Skip edges are decomposed into single-frame edges, so they contribute at every length they span (see above)
Tracks shorter than length N still contribute 1 to the total for length N (correct iff the entire track is correct)
This metric helps identify whether tracking errors occur more frequently in short or long tracks, providing granular insight into tracking quality at different temporal scales.
- Parameters:
max_length (int | None) – Maximum track length in frames to evaluate. The default is None, which uses gt_tracks.end - gt_tracks.start
lineages – If True, evaluate on full lineages (connected components). If False, evaluate on tracklets (segments between divisions).
error_type – “basic” or “ctc” error classification scheme
The compute function returns a results dictionary with three lists, each indexed by track length (index 0 = length 1, index 1 = length 2, etc.):
correct- number of correct segments at each lengthtotal- total number of segments at each lengthaccuracy- correct/total at each length, or np.nan if total is 0
- property info: dict[str, Any]
Dictionary with Metric name and any parameters
- compute(matched: traccuracy.matchers._matched.Matched, override_matcher: bool = False, relax_skips_gt: bool = False, relax_skips_pred: bool = False) traccuracy.metrics._results.Results
The compute methods of Metric objects return a Results object populated with results and associated metadata
- Parameters:
matched (traccuracy.matchers.Matched) – Matched data object to compute metrics on
override_matcher (bool) – If True, the metric will not validate the matcher type
relax_skips_gt (bool) – If True, the metric will check if skips in the ground truth graph have an equivalent multi-edge path in predicted graph
relax_skips_pred (bool) – If True, the metric will check if skips in the predicted graph have an equivalent multi-edge path in ground truth graph
- Returns:
- Object containing metric results
and associated pipeline metadata
- Return type: