-
Notifications
You must be signed in to change notification settings - Fork 7
Complete Tracks by Length (nee. track accuracy over time) #331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cmalinmayor
wants to merge
46
commits into
main
Choose a base branch
from
track-accuracy-over-time
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 38 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
27f730f
Add a larger test case with multiple tracks and frames
cmalinmayor 86f8c8a
Add tests for compute_track_accuracy on canonical cases
cmalinmayor b9cc017
Merge branch 'main' into track-accuracy-over-time
cmalinmayor e52647a
Draft of lineage accuracy docs
cmalinmayor e1795ef
WIP: implementation of track accuracy given no skip edges, untested
cmalinmayor eaacd52
WIP (untested): ensure processing in temporal order
cmalinmayor 1c50902
Merge branch 'main' into track-accuracy-over-time
cmalinmayor b9399d7
Implementation that works for basic, non-division test cases
cmalinmayor 7d4d540
Add Claude-generated tests for all the other basic errors (still need…
cmalinmayor a3d69f3
Measure window size in frames, not edges
cmalinmayor 08311b5
Add benchmarking function
cmalinmayor 2f5de12
Add citation and link to original implementation to docs
cmalinmayor 3216e94
Don't explicitly call basic errors, let division do it
cmalinmayor 4a34776
Merge branch 'main' into track-accuracy-over-time
cmalinmayor c7e475a
WIP: dynamic programming refactor
cmalinmayor 659fff0
update tests to count short gt tracks
cmalinmayor 7c1654e
Clean up track accuracy implementation
cmalinmayor 9ef7d21
Merge branch 'main' into track-accuracy-over-time
cmalinmayor 24c18a3
Update docs/source/metrics/lineage-accuracy.md
cmalinmayor 7e7c435
Docs and docstring fixes
cmalinmayor 11cbeac
Change default max window to None
cmalinmayor 690bc94
Make docstrings describe high level objectives
cmalinmayor 3da701a
Simplify and comment lineage traversal logic
cmalinmayor ea538cb
Remove dead code to fill empty windows
cmalinmayor 5eaef2e
Return lists of values instead of giant flat dict
cmalinmayor 0765aac
Check for fp divs as a separate check from node and edge
cmalinmayor cbac8bd
Use shared correctness helpers in complete tracks
cmalinmayor b560430
Fix mypy error
cmalinmayor 4a7eb63
Move end-to-end tests to their own file
cmalinmayor 4e92d56
Fix docstring formatting for autodocs
cmalinmayor 3992f48
Directly test helper function for DP
cmalinmayor 7bad3d5
Remove unnecessary warning about matching type
cmalinmayor df81573
Test track accuracy edge cases
cmalinmayor 036ee4b
Test that we short-circuit when window bigger than track
cmalinmayor f5b9f14
Remove more dead code
cmalinmayor 0aec6ff
More docs fixes
cmalinmayor 73cd2c3
More docs fixes!
cmalinmayor f961941
Update docs/source/metrics/lineage-accuracy.md
cmalinmayor c13401f
Improve lineage/tracklet accuracy description
cmalinmayor 8bed7da
Morgan's wording suggestion about division segments
cmalinmayor 559ab38
Merge branch 'main' into track-accuracy-over-time
msschwartz21 942e16d
Remove assert check in favor of ValueError
msschwartz21 e176cf8
Fix track accuracy tests to handle new validation
cmalinmayor 8098f66
Merge branch 'main' into track-accuracy-over-time
cmalinmayor 162e67a
Rename to complete tracks by length
cmalinmayor 45e3a16
Disambiguate docs link
cmalinmayor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| (lineage-accuracy-metrics)= | ||
| # Tracklet and Lineage Accuracy Metrics | ||
|
|
||
| Track accuracy over N frames measures what fraction of ground truth tracklet or lineage segments that span N frames are correctly reconstructed. | ||
|
cmalinmayor marked this conversation as resolved.
Outdated
|
||
| For lineage segments, all branches are included - a segment is only correct if all branches are correct. | ||
| Skip edges that span multiple frames count toward their actual frame difference. For example, a skip edge from t=0 to t=3 contributes a segment of size 3, not size 1. | ||
|
|
||
| A segment is counted as correct if there are no errors anywhere in it. In our current implementation, this includes checking: | ||
| - The starting node is a true positive | ||
| - All edges are true positives (edge TP implies endpoint nodes are TP) | ||
|
|
||
| Important counting rules: | ||
| - Isolated nodes (nodes with no outgoing edges) are NOT counted as segments | ||
| - Ground truth tracks shorter than window size N do contribute 1 to the total for window N | ||
|
|
||
| In the extreme case where N equals the number of frames in the dataset, this is the same as the CTC-BIO [Complete Tracks](complete-tracks). | ||
|
|
||
| Tracklet accuracy over N frames is the same, but counts each tracklet (segment between divisions) independently rather than full lineages. Division edges are not included in this version of the metric. | ||
|
|
||
| ## Usage | ||
|
|
||
| ```python | ||
| from traccuracy.metrics import TrackAccuracyOverTime | ||
| from traccuracy.matchers import IOUMatcher | ||
|
|
||
| # Match ground truth and predicted tracking graphs | ||
| matcher = IOUMatcher(iou_threshold=0.5) | ||
| matched = matcher.compute_mapping(gt_graph, pred_graph) | ||
|
|
||
| # Compute lineage accuracy over windows spanning 1-50 frames | ||
| metric = TrackAccuracyOverTime(max_window=50, lineages=True, error_type="basic") | ||
| result = metric.compute(matched) | ||
|
|
||
| # Results contain three lists (index 0 = window 1, index 1 = window 2, etc.): | ||
| # "correct" - number of correctly reconstructed segments at each window size | ||
| # "total" - total number of GT segments at each window size | ||
| # "accuracy"- correct/total (or NaN if total is 0) | ||
| print(f"Window 1: {result.results['accuracy'][0]:.2%}") | ||
| print(f"Window 10: {result.results['accuracy'][9]:.2%}") | ||
| print(f"Window 50: {result.results['accuracy'][49]:.2%}") | ||
|
|
||
| # For tracklet accuracy (segments between divisions): | ||
| tracklet_metric = TrackAccuracyOverTime(max_window=50, lineages=False) | ||
| tracklet_result = tracklet_metric.compute(matched) | ||
| ``` | ||
|
|
||
| ## References | ||
|
|
||
| This metric is based on the track accuracy evaluation from linajea: | ||
|
|
||
| - **Paper:** Malin-Mayor, C., Hirsch, P., Guber, L. et al. Automated reconstruction of whole-embryo cell lineages by learning from sparse annotations. *Nat Biotechnol* 41, 44–49 (2023). [https://doi.org/10.1038/s41587-022-01427-7](https://www.nature.com/articles/s41587-022-01427-7) | ||
|
|
||
| - **Original implementation:** [`linajea.evaluation.evaluator.get_perfect_segments`](https://github.com/funkelab/linajea/blob/master/linajea/evaluation/evaluator.py#L409) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.