Reconstructing the Mind's Eye: fMRI-to-Image with Contrastive Learning and Diffusion Priors

Paul S. Scotti, Atmadeep Banerjee, Jimmie Goode, Stepan Shabalin, Alex Nguyen, Ethan Cohen, Aidan J. Dempster, Nathalie Verlinde, Elad Yundler, David Weisberg, Kenneth A. Norman, Tanishq Mathew Abraham

TL;DR

MindEye is a state-of-the-art fMRI-to-image framework that uses specialized contrastive learning and diffusion priors to retrieve and reconstruct viewed images from brain activity. By mapping neural signals into a high-dimensional CLIP latent space, it achieves unprecedented accuracy, successfully identifying the exact image a participant viewed out of nearly a thousand candidates with over 90% accuracy.

What Problem Does This Paper Address?

The goal of fMRI decoding is to translate patterns of brain activity—measured via blood oxygenation changes—back into the sensory inputs or cognitive states that triggered them. While previous research has successfully reconstructed basic shapes or coarse categories, high-fidelity reconstruction of complex, natural scenes has remained a significant challenge.

Earlier methods often relied on simple linear mappings (like ridge regression) to link brain activity to the latent spaces of generative models. These approaches frequently struggled with a fundamental tradeoff: a model optimized to reconstruct the general "vibe" of an image (semantic content) often failed at precise retrieval (finding the exact image), and vice versa. Furthermore, preserving low-level details like exact color, texture, and spatial positioning remained elusive.

Methods

MindEye introduces a sophisticated architecture consisting of two parallel pipelines: a high-level (semantic) pipeline and a low-level (perceptual) pipeline.

Figure 2: MindEye overall schematic. A high-level “semantic” pipeline maps voxels to CLIP embeddings for image reconstruction (outputs from a diffusion prior feed through generative models like Versatile Diffusion) or retrieval tasks (such as K-nearest neighbor querying of brain embeddings to the CLIP embeddings of LAION-5B images). A low-level “perceptual” pipeline maps voxels to the variational autoencoder used by Stable Diffusion to obtain blurry reconstructions, which are used as the initialization for subsequent diffusion-based image generation. The contrastive loss for the low-level pipeline is omitted for simplicity; see Appendix A.3.2 for details.

The High-Level Pipeline

This is the core of the system. It uses a massive Multi-Layer Perceptron (MLP) backbone—boasting nearly a billion parameters—to map flattened fMRI voxels into an intermediate space. From there, the signal splits into two specialized submodules:

  1. MLP Projector: Trained using a novel bidirectional mixup contrastive loss (BiMixCo). This submodule is specialized for retrieval, creating "disjointed" embeddings that are highly effective for finding matches in large databases.
  2. Diffusion Prior: Inspired by DALL-E 2, this submodule is trained to align the brain-derived embeddings with the actual CLIP image space. It bridges the "modality gap" between brain signals and image features, producing "aligned" embeddings suitable for generative models like Versatile Diffusion.

The Low-Level Pipeline

To capture fine-grained details that CLIP might ignore (like the exact position of a red dot), MindEye uses a separate encoder that maps voxels directly to the latent space of Stable Diffusion’s Variational Autoencoder (VAE). This produces a blurry but spatially accurate "perceptual" reconstruction.

Integration

The final high-fidelity image is generated using an img2img process. The blurry low-level reconstruction serves as the starting point, which is then refined by the generative model guided by the aligned high-level semantic embeddings.

Datasets

The researchers primarily utilized the Natural Scenes Dataset (NSD), a large-scale 7-Tesla fMRI dataset. It contains brain responses from participants who viewed thousands of natural images sourced from MS-COCO.

  • Training: ~25,000 fMRI-image pairs per subject.
  • Testing: 982 unique images (averaged over three repetitions to reduce noise).
  • Retrieval Benchmark: The authors also scaled their retrieval task to the LAION-5B database, which contains billions of image-text pairs, to test the limits of their brain-derived embeddings.

Key Insights and Ideas

  • The Power of Scale: Contrary to the common belief that small fMRI datasets require small models to avoid overfitting, the authors found that using a deep MLP with orders of magnitude more parameters (940M) significantly boosted performance.
  • Specialization is Key: Retrieval and reconstruction are distinct tasks. By using parallel submodules (Projector vs. Prior), MindEye avoids the performance tradeoff inherent in trying to force a single embedding space to do both.
  • Exemplar-Level Signal: The brain's representation of images is incredibly fine-grained. MindEye can distinguish between very similar images (e.g., two different photos of zebras) based solely on fMRI data.
  • BiMixCo Loss: The introduction of a bidirectional mixup contrastive loss proved crucial for training high-performing models in the relatively low-sample regime of neuroimaging.

Key Results

MindEye achieved new state-of-the-art results across both retrieval and reconstruction metrics:

  • Retrieval Accuracy: For Subject 1, MindEye achieved a 93.2% top-1 accuracy in retrieving the exact viewed image from the 982-image test set (random chance is 0.1%). Previous SOTA methods were below 50%.
  • Large-Scale Retrieval: Even when searching through the massive LAION-5B database, MindEye could retrieve images that were remarkably similar to the original stimuli.
MindEye image retrieval results showing top-1 accuracy and scaling to LAION-5B.
  • Reconstruction Quality: Qualitatively, the reconstructions are strikingly similar to the original "seen" images, capturing both the semantic category and the spatial layout with high fidelity. Quantitatively, MindEye outperformed competitors like Brain-Diffuser and Takagi et al. across nearly all high-level and low-level image metrics.
Side-by-side comparison of reconstructions from different models.

Limitations and Future Work

Despite its success, MindEye has several limitations:

  • Subject Specificity: Currently, a new model must be trained for each individual participant. Future work aims to create "universal" decoders that generalize across different people.
  • Domain Constraints: The model is currently optimized for natural scenes (MS-COCO). Reconstructing other types of imagery (e.g., abstract art or medical diagrams) would likely require additional specialized training.
  • Practicality: The requirement for 7-Tesla fMRI and 40 hours of scan time per subject makes this technology impractical for widespread clinical or consumer use today.
  • Privacy Concerns: As decoding technology improves, the authors emphasize the critical need for robust data protection and ethical frameworks to prevent the misuse of "mind-reading" capabilities.

Summary updated

Abstract

We present MindEye, a novel fMRI-to-image approach to retrieve and reconstruct viewed images from brain activity. Our model comprises two parallel submodules that are specialized for retrieval (using contrastive learning) and reconstruction (using a diffusion prior). MindEye can map fMRI brain activity to any high dimensional multimodal latent space, like CLIP image space, enabling image reconstruction using generative models that accept embeddings from this latent space. We comprehensively compare our approach with other existing methods, using both qualitative side-by-side comparisons and quantitative evaluations, and show that MindEye achieves state-of-the-art performance in both reconstruction and retrieval tasks. In particular, MindEye can retrieve the exact original image even among highly similar candidates indicating that its brain embeddings retain fine-grained image-specific information. This allows us to accurately retrieve images even from large-scale databases like LAION-5B. We demonstrate through ablations that MindEye's performance improvements over previous methods result from specialized submodules for retrieval and reconstruction, improved training techniques, and training models with orders of magnitude more parameters. Furthermore, we show that MindEye can better preserve low-level image features in the reconstructions by using img2img, with outputs from a separate autoencoder. All code is available on GitHub.
BibTeX
@inproceedings{scotti2023reconstructing,
  author = {Paul S. Scotti and Atmadeep Banerjee and Jimmie Goode and Stepan Shabalin and Alex Nguyen and Ethan Cohen and Aidan J. Dempster and Nathalie Verlinde and Elad Yundler and David Weisberg and Kenneth A. Norman and Tanishq Mathew Abraham},
  title = {{Reconstructing the Mind's Eye: fMRI-to-Image with Contrastive Learning and Diffusion Priors}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=rwrblCYb2A},
}
Figure