Phase 1: Skeleton Visualization for napari Plugin #763
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.



Summary
This PR implements Phase 1 of the skeleton visualization feature requested in #693, enabling researchers to visualize skeletal connections between tracked keypoints without sharing sensitive video content.
Key Achievement: Skeleton connections now render as lines (using napari's Vectors layer) providing a clean, anatomically-accurate visualization of animal poses.
Motivation and Context
Closes #693 (Phase 1)
Pose tracking datasets contain rich information about animal movement, but sharing and interpreting this data can be challenging:
This implementation solves these problems by adding a skeleton visualization layer that:
Implementation Details
New Module:
movement/napari/skeleton/Core Components:
PrecomputedRenderer(renderers/precomputed.py)(N, 2, D+1)where N is total vectors[x, y]→ napari[t, y, x]SkeletonState(state.py)Configuration I/O (
config.py)Templates (
templates.py)Main API (
__init__.py)add_skeleton_layer(viewer, dataset, connections, **kwargs)Technical Highlights
Napari Vector Format (Critical):
This format ensures:
NaN Handling:
Multi-Individual Support:
Features
Implemented in Phase 1
add_skeleton_layer()Planned for Phase 2 & 3
Phase 2: Multi-Renderer Support
Phase 3: Polish & Advanced Features
Usage Example
Testing
Test Suite
29 tests total (all passing ):
Coverage:
Manual Verification
Tested with:
Visual Confirmation:
Screenshot
Files Changed
New Files (12 total)
Core Module (
movement/napari/skeleton/):__init__.py- Main API and public exportsstate.py- SkeletonState classconfig.py- Configuration I/O and validationtemplates.py- Pre-defined skeleton templatesrenderers/__init__.py- Renderer exportsrenderers/base.py- BaseRenderer abstract classrenderers/precomputed.py- PrecomputedRenderer implementationTests:
tests/fixtures/skeleton.py- Test fixtures and synthetic data generatorstests/test_unit/test_napari_plugin/test_skeleton/__init__.pytests/test_unit/test_napari_plugin/test_skeleton/test_config.py- Config teststests/test_unit/test_napari_plugin/test_skeleton/test_precomputed_renderer.py- Renderer teststests/test_integration/test_skeleton_napari.py- napari integration testsBreaking Changes
None. This is a new feature with no impact on existing functionality.
Checklist
Next Steps
After Phase 1 review and merge:
Questions for Reviewers
Module location: Is
movement/napari/skeleton/the right place, or would you prefer a different structure?Template repository: Should additional species templates be in the codebase or maintained separately?
Performance warnings: Should we add warnings for large datasets (>10K frames) in Phase 1, or wait for Phase 2's optimized renderers?
Thank you for reviewing! Looking forward to feedback and happy to make adjustments.