Skip to content

fix(review): show a live recording's keypoints, and stop misreading its other files - #203

Merged
gbradham merged 1 commit into
mainfrom
fix/session-review-live-keypoints
Oct 21, 2026
Merged

gbradham merged 1 commit into
mainfrom
fix/session-review-live-keypoints

Conversation

@gbradham

Copy link
Copy Markdown
Member

Summary

Session Review said "No poses found" for every run recorded with a live pose model. On the Maimu RTPP Day1 recordings it also played the overlay video instead of the raw recording, and named the session …_annotated_<ts>. Three causes, all fixed here:

  • The live keypoints were never read. SessionView.from_recording used the tracked centroid as a one-keypoint pose and ignored the <base>_keypoints.csv the tracking logger writes beside the tracking CSV. It now loads that file:
    • It's in long format (frame, object_id, keypoint, x, y, confidence), and only the subject's (frame, object_id) rows are kept, so a second animal never mixes in.
    • Blank x/y, which the logger writes for an undetected keypoint, becomes a gap.
    • The logger's keypoint labels are kept in order: the CV-settings bodypart names, or indices when none were set.
    • It falls back to the centroid when the file is missing or unusable.
  • The overlay video was taken for the raw recording. discover() and session_id_for() only recognised <stem>_annotated.mp4, but VideoRecorder writes <name>_annotated_<ts>.mp4. The overlay copy was therefore classified as the raw video and won as the newest file.
  • Opening a video used the wrong CSV as poses. find_pose_csv() treated <video stem>.csv as a hand-placed pose file, but for a live recording that's the DataRecorder's sensor CSV. Files that start with a # GLIDER header are now skipped.

New helpers in glider.analysis._io: is_annotated_video, raw_video_stem, keypoints_beside. Session exposes tracking_path. The Session tab's wording now says whether the poses are the live keypoints or the centroid.

Not in this PR

A folder holding several runs still opens as one session, the newest. GLIDER saves runs flat, so a folder like Day1 (9 runs) shows one. Each recorder also timestamps its own filename, so one run's files can differ by a second (…172144.mp4 vs …172145_keypoints.csv). Both are separate follow-ups.

Test plan

  • On the real Day1 share, read-only: the newest run opens with 7 keypoints on all 14,079 frames, the raw video, and session id Maimu_RTPP_1_20261020_172144. find_pose_csv on an older run's video no longer returns its data CSV.
  • New unit tests:
    • keypoints become the pose
    • bodypart names kept in logged order
    • an undetected keypoint becomes a gap
    • only the subject's keypoints kept
    • unreadable or empty keypoints fall back to the centroid
    • the recorder's annotated naming is recognised (discover, raw_video_stem)
    • keypoints_beside
    • a GLIDER CSV is never taken for poses, and doesn't shadow a batch output
  • Full pytest tests (offscreen, PYTHONPATH=src): 6,820 passed, 20 skipped
  • ruff check . and black --check . clean

…ts other files

Session Review said "No poses found" for every run recorded with a live
pose model, and on the Maimu RTPP Day1 data showed the wrong video and a
garbled session name. Three causes:

- SessionView.from_recording never read the keypoints CSV the tracking
  logger writes beside the tracking CSV; it used the tracked centroid as a
  one-keypoint pose and left pose_path unset. It now loads
  <base>_keypoints.csv (long: frame, object_id, keypoint, x, y, confidence),
  keeps only the subject's (frame, object_id) rows, reads blank x/y as a
  gap, keeps the logger's keypoint labels in order, and falls back to the
  centroid when the file is missing or unusable.
- discover() and session_id_for() only knew "<stem>_annotated.mp4", but
  VideoRecorder writes "<name>_annotated_<ts>.mp4". The overlay copy was
  taken for the raw video (and, being written last, won), and the session
  was named "<name>_annotated_<ts>".
- find_pose_csv() returned "<video stem>.csv" as a hand-placed pose file;
  for a live recording that is the DataRecorder's sensor CSV. Files that
  open with a "# GLIDER" header are now skipped.

_io gains is_annotated_video, raw_video_stem and keypoints_beside; Session
exposes tracking_path. A folder holding several runs still opens only the
newest; that is separate work.
@gbradham
gbradham merged commit 92bc239 into main Oct 21, 2026
4 checks passed
@gbradham
gbradham deleted the fix/session-review-live-keypoints branch October 21, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant