Neural Encoding and Decoding at Scale

Yizi Zhang, Yanchen Wang, Mehdi Azabou, Alexandre Andre, Zixuan Wang, Hanrui Lyu, International Brain Laboratory, Eva L Dyer, Liam Paninski, Cole Lincoln Hurwitz

Overview

NEDS (Neural Encoding and Decoding at Scale) is a multimodal transformer model that unifies neural encoding and decoding into a single framework. By using a novel multi-task masking strategy, it achieves state-of-the-art performance across multiple animals and even develops the "emergent" ability to identify brain regions without explicit training.

The Challenge: Bridging Encoding and Decoding

In systems neuroscience, researchers generally ask two complementary questions:

  1. Encoding: How does behavior (like moving a limb or making a choice) drive neural activity?
  2. Decoding: Can we look at neural activity and predict what the animal is doing?

Historically, models have been "one-way streets," specialized for either encoding or decoding, and often limited to a single animal or recording session. As data acquisition scales up—thanks to tools like Neuropixels probes that record thousands of neurons simultaneously—we need models that can handle the bidirectional relationship between brain and behavior across massive, multi-animal datasets. The authors aim to move toward a "foundation model" for the brain that is flexible, scalable, and capable of seamless translation between modalities.

Methods: The NEDS Architecture

The authors introduce NEDS, a multimodal transformer-based architecture. Its core innovation is a multi-task-masking strategy used during pretraining.

NEDS Architecture and Masking Strategy

Instead of a standard objective, the model alternates between four types of masking:

  • Neural Masking: Hides neural activity to force the model to perform encoding (predicting spikes from behavior).
  • Behavior Masking: Hides behavioral data to force the model to perform decoding (predicting behavior from spikes).
  • Within-Modality Random Masking: Hides random tokens within a single modality to learn internal dependencies.
  • Cross-Modal Random Masking: Hides random tokens across both modalities to learn joint relationships.

The architecture uses modality-specific tokenizers (converting spikes and behaviors into 20ms bins) and a shared transformer encoder. To handle the variability between different animals and labs, they incorporate session-specific embeddings and input/output matrices, allowing a single large model to adapt to the unique "fingerprint" of each recording session.

Datasets

  • IBL Repeated Site Dataset: The primary dataset from the International Brain Laboratory, featuring Neuropixels recordings from 83 mice performing a standardized visual decision-making task. The authors pretrained on 73 animals and evaluated on 10 held-out animals.
  • MC-RTT Dataset: A primate (macaque) reaching task dataset used to demonstrate that NEDS generalizes across species and different recording technologies (Utah arrays vs. Neuropixels).

Key Insights and Results

State-of-the-Art Performance and Scaling

Training on both encoding and decoding tasks simultaneously makes the model better at each individual task. The multimodal approach outperformed unimodal versions of the same transformer. NEDS outperformed existing large-scale models like POYO+ and NDT2, improving decoding performance by 11–37% over NDT2 and 1–13% over POYO+ across various tasks.

Furthermore, pretraining on 74 sessions from different animals led to a 24% improvement in spike encoding compared to training on a single session alone. The model also showed strong zero-shot generalization on held-out animals after only a brief "fine-tuning" period, suggesting it learned a generalized representation of mouse brain dynamics.

Emergent Anatomical Knowledge

Perhaps the most striking finding is that NEDS's learned embeddings are highly predictive of brain regions.

Emergent Anatomical Knowledge in NEDS Embeddings

Even though the model was never told which neurons belonged to which part of the brain (e.g., the hippocampus vs. the thalamus), it clustered them accurately, achieving an 83% classification accuracy. This suggests the model is capturing fundamental biological structures just by observing activity patterns.

Ranking Behavioral Importance

Because the model can perform encoding, researchers can "mask" specific behaviors (like whisker motion vs. wheel speed) to see which one explains more neural variance, providing a powerful new tool for scientific discovery.

Limitations and Future Work

  • Trial-Alignment: The current version of NEDS relies on trial-aligned data (segments of time locked to a specific task event). Moving to "unaligned" or continuous data would allow the use of much larger, more diverse datasets.
  • Computational Cost: Scaling to 73+ animals makes hyperparameter tuning prohibitively expensive, requiring the authors to use a subset of data for tuning before scaling up.
  • Modality Expansion: Future work could incorporate other data types, such as Local Field Potentials (LFP) or calcium imaging, to create a truly universal neural foundation model.
  • Cell-Type Specificity: Integrating electrophysiological features could allow the model to identify and predict the activity of specific cell types (e.g., inhibitory vs. excitatory neurons).

Summary updated

BibTeX
@inproceedings{zhang2025neural,
  author = {Yizi Zhang and Yanchen Wang and Mehdi Azabou and Alexandre Andre and Zixuan Wang and Hanrui Lyu and International Brain Laboratory and Eva L Dyer and Liam Paninski and Cole Lincoln Hurwitz},
  title = {{Neural Encoding and Decoding at Scale}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=vOdz3zhSCj},
}
Figure