BrainCodec: Neural fMRI codec for the decoding of cognitive brain states

Yuto Nishimura, Masataka Sawayama, Ayumu Yamashita, Hideki Nakayama, Kaoru Amano

Abstract

Recently, leveraging big data in deep learning has led to significant performance improvements, as confirmed in applications like mental state decoding using fMRI data. However, fMRI datasets remain relatively small in scale, and the inherent issue of low signal-to-noise ratios (SNR) in fMRI data further exacerbates these challenges. To address this, we apply compression techniques as a preprocessing step for fMRI data. We propose BrainCodec, a novel fMRI codec inspired by the neural audio codec. We evaluated BrainCodec's compression capability in mental state decoding, demonstrating further improvements over previous methods. Furthermore, we analyzed the latent representations obtained through BrainCodec, elucidating the similarities and differences between task and resting state fMRI, highlighting the interpretability of BrainCodec. Additionally, we demonstrated that fMRI reconstructions using BrainCodec can enhance the visibility of brain activity by achieving higher SNR, suggesting its potential as a novel denoising method. Our study shows that BrainCodec not only enhances performance over previous methods but also offers new analytical possibilities for neuroscience.

Introduction

Functional Magnetic Resonance Imaging (fMRI) is a vital tool for observing the living human brain, yet it is plagued by two primary challenges: extreme noise and data scarcity. The signal-to-noise ratio (SNR) of fMRI is notoriously low, often requiring researchers to average numerous scans to identify clear patterns. Furthermore, while fields like natural language processing benefit from massive datasets, fMRI data remains relatively limited. Previous attempts to apply "Scaling Laws" to neuroscience have struggled because raw fMRI data is high-dimensional and messy. BrainCodec addresses these issues by adapting state-of-the-art neural audio compression techniques to create a discrete, hierarchical representation of brain activity that facilitates both denoising and high-accuracy decoding.

Methods

BrainCodec is a neural codec inspired by architectures like Meta’s EnCodec. It utilizes Residual Vector Quantization (RVQ) to discretize brain activity into a sequence of "tokens" from a learned codebook.

Architecture of BrainCodec featuring Encoder, Residual Vector Quantization (RVQ), and Decoder modules.

The system operates through three main components:

  1. The Encoder: Processes fMRI data (pre-processed into 1,024 functional regions via DiFuMo) and compresses it into a latent space.
  2. The RVQ Module: Employs 8 layers of codebooks. The first layer captures coarse, primary variations in brain activity, while subsequent layers refine details by quantizing the residual error from the previous layer.
  3. The Decoder: Reconstructs the fMRI signal from these discrete tokens.

By training on a vast array of brain scans, the model learns a robust "vocabulary" of brain states, effectively filtering out non-neural noise that does not fit learned patterns.

Datasets

The study utilized a broad range of data for robust evaluation:

  • Upstream (Pre-training): 34 datasets from OpenNeuro.org, totaling 11,980 fMRI runs from 1,726 subjects.
  • Downstream (Evaluation): Included the Human Connectome Project (HCP) with 20 tasks, the Multi-Domain Task Battery (MDTB) with 26 tasks, and the Over100 dataset involving 103 cognitive tasks.
  • Resting-State: Data from OpenNeuro and the SRPBS Traveling Subject MRI Dataset were used to compare "idle" brain activity with task-driven states.

Results and Discussion

BrainCodec achieved massive performance gains in mental state decoding. On the HCP dataset, a simple linear model using BrainCodec-reconstructed data improved decoding accuracy from 62.2% to 81.4%, a 31% relative improvement over the baseline. It consistently outperformed standard Variational Autoencoder (VAE) methods in both reconstruction quality and downstream task performance.

UMAP visualization of latent representations, showing separation between task and resting states.

A key insight is the model's interpretability. Visualizing the codebooks using UMAP (as seen above) revealed that the first layer of the hierarchy can distinguish between "resting" and "task-active" brain states. This suggests the model captures fundamental neuroscientific truths rather than mere mathematical artifacts. Furthermore, the hierarchical denoising capability was evident in motor tasks, where reconstructions showed much clearer, more localized activations in the motor cortex compared to raw, noisy single-run data.

Conclusion

BrainCodec demonstrates that neural compression is not just a preprocessing step but a powerful tool for denoising and interpreting complex fMRI data. While some performance dips were noted in highly complex tasks (e.g., in the MDTB dataset), suggesting that aggressive compression may occasionally discard subtle information, the overall framework provides a significant leap forward. Future work will focus on scaling the model and developing noise-robust discriminators to further enhance signal clarity and decoding precision.

Summary updated

BibTeX
@misc{nishimura2024braincodec,
  author = {Yuto Nishimura and Masataka Sawayama and Ayumu Yamashita and Hideki Nakayama and Kaoru Amano},
  title = {{BrainCodec: Neural fMRI codec for the decoding of cognitive brain states}},
  year = {2024},
  eprint = {2410.04383},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.04383},
}
Figure