Repository navigation
feat(analysis): add probability outputs and state transition maps - #4
Merged
btmlnsn merged 13 commits intoSep 24, 2026
Conversation
Owner
|
Nice work! |
Owner
|
Quick integration note: I added |
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
Author and primary contributor: Myra Lyu
Integration and visualization refinements: Bobby Tomlinson
This PR adds frame-level behavior-probability outputs and State Transition Maps to LabGym’s analysis workflow. It gives users the complete prediction distribution for each frame and a scientifically interpretable summary of bout-to-bout behavioral transitions.
Changes
Frame-Level Probability Matrix
Problem
Currently, LabGym reported the probability of different behaviors for each video frame; however, it would be difficult for users to interpret and inspect model uncertainty, especially during behavioral transitions or when visually similar behaviors received comparable prediction scores. Users also lacked a visual representation for comparing model outputs across datasets.
Implementation
Added export of a frame-level behavior-probability matrix for each analyzed individual. Each output includes a NumPy
.npymatrix, a CSV with frame/time information and one probability column per behavior, and a probability heat map showing behaviors by frame/time.The heat maps use a fixed linear 0–1 probability scale. Missing or non-finite values are shown in a distinct neutral gray rather than being displayed as low probabilities.
Impact
Users can now inspect the complete probability distribution behind every behavioral prediction, making uncertain frames and behavioral transitions easier to identify. The fixed scale also meaningful visual comparisons across recordings.
State-Transition Map
Problem
LabGym did not provide a compact, interpretable visualization of behavioral transition structure. Users could not easily inspect which behaviors tended to follow a source behavior, compare transition patterns across individuals, or connect a visual map to the underlying counts and probabilities.
Implementation
Added a user-configurable State Transition Map generator that reads LabGym
all_events.xlsxoutputs and creates a separate result package for each included individual.The analysis collapses consecutive frames with the same behavior into bouts, counts transitions between successive bouts within uninterrupted sequences, and computes row-normalized transition probabilities:
P(destination next | source current).NA and user-excluded behaviors break the sequence, preventing false transitions across those intervals. Node size represents frame occupancy, while edge width represents transition probability; equal probabilities use equal widths across maps. Edge labels report the transition identifier, probability, and observed count.
Impact
Users can identify dominant behavioral pathways, asymmetric transitions, and differences in behavioral organization across individuals or conditions.The accompanying tables preserve the quantitative evidence behind each visual encoding.
Testing
Prepared-component focused validation passed:
Coverage includes:
.npy/CSV outputs.Manual visualization review:
Known limitations