Repository navigation
Fix wrong multi-animal tracking when ellipse fit fails on one animal - #3544
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The unrelated documentation changes should be split out, and the identity-specific regression path needs test coverage.
Review effort: Balanced
Findings: 1
Open (3)
What changed in this PR
Fixes incorrect multi-animal pose assignment when ellipse fitting skips a detection. The branch also includes an unrelated napari documentation refresh.
Changes:
- Maps fitted ellipses back to original pose indices.
- Adds regression coverage for failed ellipse fitting.
- Expands napari usage and troubleshooting documentation.
| File | Description |
|---|---|
deeplabcut/core/trackingutils.py |
Preserves original animal indices during ellipse tracking. |
tests/test_trackingutils.py |
Tests skipped ellipse-fit behavior. |
_toc.yml |
Adds troubleshooting documentation. |
docs/gui/napari/troubleshooting.md |
Adds troubleshooting guidance. |
docs/gui/napari/basic_usage.md |
Refreshes annotation workflows. |
docs/gui/napari/advanced_usage.md |
Updates documentation metadata. |
docs/gui/napari/tracking/basic_usage.md |
Updates title and metadata. |
docs/gui/napari_GUI.md |
Refreshes the napari documentation landing page. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
deruyter92
left a comment
There was a problem hiding this comment.
Good fix! Great that you added the regression test as well.
Just minor comments. I agree with copilot that the regression test now does not cover the entire failure mode.
Out of scope:
We should definitely look into the entire pipeline for other things that could be improved. E.g. the pickle saving that we discussed already (that would be a big migration). But also the config handling, which is a smaller fix. (now re-written as a side-effect; parameters not easily customizable). Maybe for some follow-up PRs. Let's discuss
ce318d6 to
6049de4
Compare


Bug
Fixes a bug in
SORTEllipse.trackwhere the tracking assigns ellipses to the wrong animals when an ellipse fit fails on one animal. Indices of tracked ellipses were not aligned with the input animal indices. Subsequent functionfill_trackletsis then assigning the wrong poses to the wrong animals on that failing frame.Fix
Add an additional record
pose_indsof animal indices from the inputposesarray and use it to write theanimalindexinstead ofellipsesindices.In case of given
identities, directly read the tracker id frompred_idsas it is only updated on successful ellipse fit.Test
The test function
test_sort_ellipse_unfitted_pose_keeps_animal_indexsimulates callingSORTEllipse.tracktwice on two mock frames with two mock animals (0 and 1), where the second frame of the animal 0 has all but 2 bodyparts withNandetected coordinates. This makes the ellipse fit fail, and prior to the fix, assign pose from animal 1 to animal 0 in the tracklets.Related
Fixes #3493.
Mentioned in #3089.