sleap
sleap copied to clipboard
Refactor the max_tracking code
ONLY AFTER #1894 is merged.
I refactored the max_tracking
feature introduced in #1447 and simplified the implementation. It may give different results as the goal is similar but implemented differently.
One problem I had with the current implementation is that instances cannot be assigned to created but unused tracks. Say we have max_tracks=2
, and the 2 tracks are created. If a track is not assigned instances for track_window
timesteps, it does not contribute to instance candidates anymore, hence instances cannot be assigned to this track anymore, forever. What was happening is that instances stopped being tracked in the middle of the video. Therefore it was unusable for me and the "pre_cull" options are not available from the GUI anymore, so I need to use the CLI.
I added an option to reassign unused tracks to unmatched instances if the maximum number of tracks was reached.
I also added an option to merge instances in the "pre_cull" stage. That is because I often have two instances from inference: front of mouse and back of mouse, that could perfectly be merged. The idea is that only "good" merges are kept by the tracking step, but it is not perfect.
Summary by CodeRabbit
-
New Features
- Streamlined command-line documentation for tracking options enhances user clarity.
- New configuration parameter for saving shifted instances improves tracking performance.
- Enhanced prediction and tracking processes with backward compatibility for older Python versions.
- Improved flexibility in tracking tests with new image scaling options.
-
Bug Fixes
- Improved robustness of inference result handling by preventing negative counts.
-
Documentation
- Updated user guides to reflect changes in command usage and tracking options.
-
Tests
- Adjusted tests to align with the new streamlined tracking methods, improving clarity and performance.