Learning When Visual Context Matters for Mouse Behavior Analysis

Weihan Li, Jingyang Ke, Qinheng Pu, Yule Wang, Chengrui Li, Anqi WuNeurIPS 2026

TL;DR

Tracking laboratory mice with 2D skeleton coordinates is fast, clean, and fails spectacularly the moment two mice pile on top of each other. Adding raw video fixes the blind spots, but processing pixels on every single frame is expensive and actually adds distracting noise when the skeleton alone was doing fine. This paper introduces ResiFuse, a framework whose pose encoder raises a mathematical red flag on the exact frames where skeletal tracking falls short, calling in heavy visual processing only when it truly matters.

What Problem Does This Paper Address?

To decode brain function, neuroscientists spend a lot of time turning hours of mouse video into behavioral timelines—either classifying known actions (like grooming or chasing) or discovering recurring motifs without labels.

The standard pipeline extracts skeletal keypoints ("pose") and feeds those coordinates into machine learning models. Pose is wonderfully lightweight, but it throws away body texture, ignores surrounding context, and scrambles during social interactions when animals occlude one another—often the exact moments behavior gets interesting. Raw video preserves all of that rich context, yet feeding dense video features into a model on every frame is computationally heavy and empirically suboptimal. The real puzzle isn't how to mash pose and video together, but knowing when visual context is actually needed.

Methods

ResiFuse follows the standard two-stage pretraining and fine-tuning pipeline, but introduces a clever, parameter-free twist for selective sensor fusion.

Figure 2: ResiFuse framework. (A) Pretraining: a motion encoder compresses pose sequences through residual vector quantization (RVQ), temporal context, and social context modules, trained with four objectives (Lmask, Lpred, Lrecon, Lvq). The cross-modal prediction loss Lpred uses visual features from every frame as auxiliary supervision, shaping the residual to indicate when pose alone is insufficient. (B) Fine-tuning: the motion encoder is frozen. Its quantization residual selects the frames where visual features are extracted; the resulting motion-vision fused representation ht supports both supervised classification and unsupervised segmentation as downstream tasks.
  1. Cross-Modal Pretraining: A motion encoder processes pose sequences using Transformers that model temporal dynamics and cross-animal social interactions. Crucially, it compresses continuous motion latents into discrete patterns using Residual Vector Quantization (RVQ)—essentially forcing the network to map every frame's motion to the nearest entry in a finite "codebook" of typical movements. Alongside standard pose-reconstruction losses, the authors add an auxiliary cross-modal loss requiring the motion encoder to predict visual features from a frozen vision encoder (like VideoPrism).
  2. The Quantization Residual (What's New): When a frame contains weird pose tracking, sudden transitions, or visually complex social overlap that pose alone cannot predict, its continuous representation gets pulled far away from any standard codebook entry. That Euclidean distance in latent space—the quantization residual—becomes an automatic, parameter-free gauge of where pose is struggling.
How quantization residuals emerge from atypical pose patterns
  1. Selective Fine-Tuning: During downstream classification or unsupervised clustering, the motion encoder is frozen. Given a compute budget (say, 50% of frames), ResiFuse ranks frames by their pose residual—before decoding any video—and extracts visual features only for the highest-residual frames, fusing them with the motion representation.

Datasets

Rather than introducing a new benchmark, the authors evaluate across three existing mouse datasets chosen to form a clean gradient of social complexity and occlusion:

  • Open Field: Single mouse exploring an arena (20 videos, 13 keypoints; grooming and rearing).
  • CalMS21: Resident-intruder pairs interacting (89 videos, 7 keypoints per mouse; attack, investigation, mount).
  • Mouse Triplet: Three mice interacting in an arena (2,614 videos, 12 keypoints per mouse; chase, huddle, oral and oral-genital contact). The authors re-estimated poses with DeepLabCut across all baselines to reduce tracking artifacts.

Key Insights and Ideas

  • Less vision can beat all-the-vision: Processing 100% of video frames often underperforms processing just 25%–75% of residual-selected frames. On easy frames where pose is clean, tacking on dense visual features dilutes the discriminative signal rather than helping it.
  • Latent uncertainty beats tracker confidence: Why not just trigger video when the pose tracker reports low keypoint confidence? In ablations, quantization residuals handily beat both tracker confidence and end-to-end learned MLP selectors. A mouse's skeleton can be tracked with 99% confidence while still being behaviorally ambiguous without visual context.
  • Unsupervised discovery of edge cases: Without any behavior labels, high residuals naturally cluster around three distinct regimes: occluded social contact, rapid motion, and sharp transitions between behaviors.

Key Results

Across 3 datasets $\times$ 2 settings (supervised classification and unsupervised segmentation), ResiFuse takes top marks on 4 out of 6 tasks in macro-averaged F1:

  • Biggest gains in complex crowds: On the 3-mouse Mouse Triplet benchmark, ResiFuse reaches 0.784 F1 (supervised) and 0.537 F1 (unsupervised) using vision on 75% of frames—beating the strongest pose+video concatenation baseline (0.729 and 0.473, respectively).
  • Beating uniform sampling everywhere: Across all 18 tested combinations of dataset, supervision type, and frame budget (25%, 50%, 75%), residual selection outperforms uniform frame sampling every single time, and transfers cleanly across five different vision backbones (VideoPrism, VideoMAEv2, DINOv3, CLIP, Qwen3.5).
  • Compute savings: On Mouse Triplet, a 75% budget achieves higher accuracy than 100% full-vision (0.784 vs. 0.777 F1) in 76% of the single-GPU inference time; a 50% budget retains two-thirds of the vision gain in 54% of the time. (The one holdout dataset is CalMS21, where heavily hand-engineered domain features from MARS still edge out learned pipelines).

Limitations and Future Work

ResiFuse isn't a zero-shot foundation model yet—a separate motion encoder is pretrained from scratch for each dataset, and that one-time pretraining stage still requires extracting visual features from every training frame to shape the codebook. Furthermore, the frame budget is currently set as a rigid, fixed percentage per dataset rather than adapting dynamically to easy versus chaotic recordings. Scaling this parameter-free residual selection into a unified, cross-dataset behavioral foundation model is the authors' natural next step.

Summary updated

Abstract

Understanding mouse behavior at scale is a foundational problem in neuroscience, with two core tasks: classifying frames into known behaviors and segmenting recordings into recurring patterns without labels. Pose-based methods are the standard approach but face fundamental limitations: pose coordinates capture only skeletal information, discard environmental context, and degrade under frequent occlusions in social scenarios. Mouse videos can provide the visual context that pose lacks, yet not all frames benefit equally, and adding visual features uniformly to every frame is suboptimal. We find that a pose-based motion encoder, trained with auxiliary supervision from videos, can identify where it struggles: with a discrete representation, the encoder learns a codebook of recurring patterns, and frames whose motion does not fit this codebook produce large quantization residuals. We show that these high-residual frames are where visual context tends to help most: residual-guided frame selection consistently outperforms uniform selection across budgets, and matches or exceeds dense visual processing in most settings. We therefore propose ResiFuse, a framework that pretrains a motion encoder on pose with an auxiliary cross-modal loss and integrates vision context only on high-residual frames at fine-tuning time. We evaluate on three mouse behavior datasets and show improvements over pose- and video-based baselines on most tasks, with the largest gains on the most socially complex dataset. Code is available at \url{https://github.com/BRAINML-GT/ResiFuse}.
BibTeX
@inproceedings{li2026learning,
  author = {Weihan Li and Jingyang Ke and Qinheng Pu and Yule Wang and Chengrui Li and Anqi Wu},
  title = {{Learning When Visual Context Matters for Mouse Behavior Analysis}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=c7qXkgNCJB},
}
Figure