feat(backend): load STAC-format keypoint tracks#6
Merged
Conversation
Adds /api/load-keypoints and backend/keypoints_io so the UI can load already-resolved 3D keypoint tracks without going through monsees_retarget (the lab-private dependency that gates /api/load-matfile and /api/load-acm). Supported inputs: - .h5 with a `tracks` dataset (shape (frames, [animals,] keypoints, 3)) or a `positions` dataset (shape (frames, keypoints, 3)). - .mat with a `pred` field (shape (frames, 3, keypoints)), matching stac-mjx/tests/data/test_rodent_mocap_1000_frames.mat. Keypoint names come from a comma-separated kp_names query param if the count matches; otherwise the loader falls back to kp_0, kp_1, ... Frontend: new "Load KP" button, reuses the current kpNames from the store when sending the upload so names stay consistent across loads. Tests: - 9 unit tests with synthetic .h5 / .mat (tmp_path fixtures) - 2 live tests against stac-mjx/tests/data fixtures that skip gracefully when the stac-mjx checkout isn't alongside this repo
fda569d to
b712e0c
Compare
Collaborator
Author
|
Reviewed, merging. |
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
Adds
/api/load-keypointsandbackend/keypoints_ioso the UI can load already-resolved 3D keypoint tracks without going throughmonsees_retarget— the lab-private package that currently gates both/api/load-matfileand/api/load-acm. This unblocks end-to-end testing with real data for anyone who doesn't havemonsees_retargetinstalled (CI, external contributors, new lab members).Supported inputs
.h5with atracksdataset of shape(frames, [animals,] keypoints, 3)(SLEAP style) or apositionsdataset of shape(frames, keypoints, 3)..matwith apredfield of shape(frames, 3, keypoints)— matchesstac-mjx/tests/data/test_rodent_mocap_1000_frames.mat.Keypoint names come from a comma-separated
kp_namesquery param if the count matches; otherwise the loader falls back tokp_0, kp_1, ....Frontend
New Load KP button in the toolbar. Reuses the current
acmKeypointNamesfrom the store so names stay consistent when a config was loaded first.Test plan
tests/test_keypoints_io.pywith synthetic.h5/.matviatmp_path— covers bothtrackslayouts, thepositionsfallback, error paths, and name-count fallbackstac-mjx/tests/data/test_rodent_mocap_1000_frames.mat(23 keypoints) andtest_mouse_mocap_3600_frames.h5(34 keypoints); skip gracefully when thestac-mjxcheckout isn't alongside this repoTestClient: uploading the rat fixture returnsnumFrames=1000, numKeypoints=23pytest --ignore=tests/test_acm_processing.py→ 17/17 passcd frontend && npm run buildcleanWhy two loaders?
Keeping the existing
/api/load-matfile(which usesmonsees_retargetto do forward kinematics on raw ACM joint angles) around because lab members with the package still need it for the Monsees data pipeline./api/load-keypointsis the new supported path for anything already in keypoint form — which is what SLEAP, DeepLabCut, andstac-mjx's own test fixtures produce.