Learning Disentangled Behavior Embeddings

Changhao Shi, Sivan Schwartz, Shahar Levy, Shay Achvat, Maisan Abboud, Amir Ghanayim, Jackie Schiller, Gal Mishne

Introduction

In neuroscience, understanding the link between brain activity and behavior is a "holy grail." To achieve this, researchers record high-resolution videos of animals performing tasks. However, analyzing these videos remains a major bottleneck.

Current methods generally fall into two camps, both with significant flaws:

  1. Pose Estimation (e.g., DeepLabCut): Requires humans to manually label body parts across thousands of frames. It is expensive, subjective, and often misses subtle movements like facial twitches.
  2. Unsupervised Autoencoders: These models learn to compress video frames into low-dimensional "embeddings." While they do not need manual labels, they are easily distracted by "nuisance factors"—such as changes in lighting, camera distance, or the physical appearance of different animals. This causes the model to cluster data by session or animal rather than by the actual behavior.

To bridge this gap, researchers have developed a deep learning framework that "disentangles" animal behavior (pose) from environmental noise (context) in video recordings. By separating these factors and applying a stochastic temporal model, they can automatically identify fine-grained behavioral "motifs" across different animals and experimental sessions without any manual labeling.

Methods: Disentangling Pose and Context

The authors propose two models: Disentangled Behavior Embedding (DBE) and its temporal extension, Variational DBE (VDBE).

The core innovation is disentanglement. Instead of generating one single representation for a video frame, the model uses two separate encoders:

  • Context Encoder ($Enc^c$): Extracts time-invariant features (the "where" and "who"). It looks at a single frame to capture the background, lighting, and the animal's appearance.
  • Pose Encoder ($Enc^p$): Extracts dynamic behavioral features (the "what"). Crucially, this encoder is "bottlenecked"—forced to use the smallest possible number of dimensions—to ensure it only captures movement and does not waste capacity on redundant background information.
Overview of the VDBE architecture showing the separation of pose and context.

VDBE takes this further by adding a stochastic dynamic model (an RNN combined with a Linear State-Space Model). It uses a Gaussian mixture prior to model transitions between poses. This allows the model to learn both continuous movements and discrete "behavioral motifs" (like "reaching" or "grabbing") in a single end-to-end training process.

The generation and inference process of the stochastic dynamic model.

Datasets

The models were evaluated on two multi-session video datasets:

  1. Hand-reach dataset: A newly collected dataset of head-fixed mice trained to grab food pellets. It includes 263 successful trials across 8 sessions with multi-view camera angles.
  2. Wide-Field Calcium Imaging (WFCI) dataset: An existing dataset of mice performing a visual decision-making task using levers, featuring 3,708 videos across 8 sessions.

Key Insights and Results

  • Session-Agnostic Embeddings: By explicitly factoring out context, the pose embeddings become "session-agnostic." In standard models, a "reach" by Mouse A looks completely different from a "reach" by Mouse B to the computer. DBE aligns these behaviors into the same latent space, allowing for much easier cross-animal analysis.
  • Robustness to Nuisance: When a classifier was trained to guess which session a frame came from based on its embedding, standard models were 100% accurate (meaning they were heavily biased by session-specific noise). DBE’s pose embeddings dropped this accuracy to ~28%, proving they successfully ignored the environmental "noise."
  • The Power of Mixture Priors: Most temporal models assume behavior follows a simple Gaussian distribution. VDBE uses a mixture of Gaussians, which better reflects reality: animal behavior is often composed of distinct, prototypical actions (motifs).
  • Superior Motif Segmentation: On the Hand-reach task, VDBE achieved a motif clustering accuracy of ~79.5%, significantly outperforming the popular BehaveNet model (~53%).
  • Trajectory Decoding: The researchers showed they could accurately reconstruct physical paw trajectories (which normally require manual DLC labels) directly from the unsupervised DBE embeddings.
  • Controllable Generation: Because the model separates pose from context, it can perform "style transfer." Researchers can take the behavior of a mouse from Session A and render it into the environment of Session B, proving the model has truly learned the underlying dynamics of the behavior.

Limitations and Future Work

The authors acknowledge a few areas for improvement:

  • Fixed State Count: The model currently requires a predefined number of behavioral states ($k$), which might not capture the full complexity of novel or unseen behaviors.
  • Stationary Context: It assumes the environment (context) does not change during a video clip. Future versions could benefit from allowing "slow dynamics" in the context embedding to handle shifting backgrounds or lighting.
  • Naturalistic Behavior: The study focused on head-fixed animals. Extending this to freely moving animals in complex environments remains an open challenge.

Summary updated

BibTeX
@inproceedings{shi2021learning,
  author = {Changhao Shi and Sivan Schwartz and Shahar Levy and Shay Achvat and Maisan Abboud and Amir Ghanayim and Jackie Schiller and Gal Mishne},
  title = {{Learning Disentangled Behavior Embeddings}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
}
Figure