refactor: Use sleap-io for analysis HDF5 and CSV exports#2649
Merged
gitttt-1234 merged 3 commits intodevelopfrom Mar 11, 2026
Merged
refactor: Use sleap-io for analysis HDF5 and CSV exports#2649gitttt-1234 merged 3 commits intodevelopfrom
gitttt-1234 merged 3 commits intodevelopfrom
Conversation
Replace SLEAP's internal write_tracking_h5.py with sleap-io's save_analysis_h5() and save_csv() functions for exporting analysis files. Benefits: - Single source of truth for analysis export logic (sleap-io) - Consistent format between SLEAP GUI and sleap-io CLI exports - Additional metadata in output files (dimension labels, skeleton info) - Backwards compatible with existing analysis file readers Changes: - sleap/io/format/sleap_analysis.py: Use sio.load_analysis_h5() and sio.save_analysis_h5() instead of custom implementation - sleap/io/format/csv.py: Use sio.save_csv() instead of write_tracking_h5 - sleap/io/convert.py: Use sleap-io functions for analysis export Related to #1651 (analysis export enhancements) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
Docs PreviewPreview has been removed. |
sleap-io raises ValueError when a video has no labeled frames, but the old SLEAP behavior was to silently skip such videos. Add try-except to maintain backwards compatibility. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
sleap-io's save_csv doesn't raise ValueError when there are no labeled frames - it writes an empty file. Check for labeled frames BEFORE calling the export function to maintain old behavior of skipping empty videos. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2649 +/- ##
===========================================
- Coverage 64.54% 64.52% -0.03%
===========================================
Files 95 95
Lines 20223 20205 -18
===========================================
- Hits 13053 13037 -16
+ Misses 7170 7168 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
write_tracking_h5.pywith sleap-io'ssave_analysis_h5()andsave_csv()functionsChanges Made
sleap/io/format/sleap_analysis.py:sio.load_analysis_h5()for reading (replaces 50+ lines of custom parsing)sio.save_analysis_h5()for writing withpreset="matlab"for SLEAP-compatible formatsleap/io/format/csv.py:sio.save_csv()withformat="sleap"instead ofwrite_tracking_h5(..., csv=True)sleap/io/convert.py:Benefits
dimsattributes to datasets and file-level metadata (preset,format,sleap_io_version)Backwards Compatibility
preset="matlab"which produces the same axis ordering as the original implementationRelated Issues
Testing
sleap-convert --format analysis🤖 Generated with Claude Code