Research
Meta-learning In-Context Enables Training-Free Cross Subject Brain Decoding
Overview Research area: Computational neuroscience and machine learning — specifically, decoding visual information from fMRI brain activity, with a focus on cross-subject generalization. Technical le
- arXiv
- 2604.08537
- Published
- 2026-04-09
- Authors
- Mu Nan, Muquan Yu, Weijian Mai, Jacob S. Prince, Hossein Adeli, Rui Zhang, Jiahang Cao, Benjamin Becker, John A. Pyles, Margaret M. Henderson, Chunfeng Song, Nikolaus Kriegeskorte, Michael J. Tarr, Xiaoqing Hu, Andrew F. Luo
AI summary
Overview
Research area: Computational neuroscience and machine learning — specifically, decoding visual information from fMRI brain activity, with a focus on cross-subject generalization.
Technical level: Advanced. Familiarity with transformers, meta-learning, in-context learning, contrastive losses, and fMRI encoding models is assumed.
Scope: This paper introduces BrainCoDec, a meta-learned, two-stage in-context decoding framework that performs semantic visual decoding on entirely new subjects without any gradient-based fine-tuning, anatomical alignment, or shared stimuli.
What This Paper Is About
Visual decoding from fMRI — reconstructing or retrieving the image a person viewed from their brain activity — has advanced rapidly, but existing models must be trained or fine-tuned separately for each individual. This is because the mapping from images to brain responses varies substantially across people due to anatomical and functional differences.
BrainCoDec reframes this problem: instead of learning a fixed decoder, it meta-learns how to invert a subject's own encoding model on the fly, given just a small set of image–brain-activation examples from that new person. The goal is a training-free, generalizable decoder that works across subjects, scanners, and acquisition protocols.
Key Contributions
-
A hierarchical in-context decoding framework (BrainCoDec) that meta-learns functional inversion of visual encoding models in two stages: first inferring per-voxel encoder parameters from image–response pairs, then aggregating across voxels to invert the encoding and predict an image embedding.
-
The first fMRI decoding method to generalize across subjects, scanners, and acquisition protocols without any gradient-based fine-tuning, and without requiring anatomical alignment or overlap in stimuli between training and test subjects.
-
Strong robustness and interpretability findings: the model tolerates dropout of category-selective cortical regions, and its attention weights produce spatially structured maps that align with known functional regions of visual cortex (FFA, EBA, PPA, OPA, RSC).
-
Demonstration of context scaling: decoding accuracy improves monotonically with both the number of in-context images (Stage 1) and the number of in-context voxels (Stage 2), across multiple visual backbones (CLIP, DINOv2, SigLIP).
Main Findings
-
Large gains on unseen subjects: On held-out NSD subjects, BrainCoDec-200 (using only 200 in-context images) achieves a mean Top-1 retrieval accuracy of 22.7% and Top-5 of 54.0%, versus 3.90%/9.81% for MindEye2 (with anatomical alignment) and 0.82%/3.09% for TGBD. This is roughly a sixfold improvement in Top-1 over the best baseline.
-
Cross-scanner generalization: A model trained only on NSD subjects transfers directly to BOLD5000 (3T scanner, different voxel size, different protocol, different image set), reaching 31.45% Top-1 accuracy with just 20 in-context images and 20 test images — far above the 5% chance level.
-
Context scaling: Performance improves with more in-context images and more in-context voxels. Notably, a limited context (200 images, 4,000 voxels) matches full-context performance (all ~9,000 images and all higher-visual-cortex voxels), indicating high data efficiency.
-
Robustness to ROI masking: Masking category-selective regions (faces, places, food, words) produces only minimal degradation in most cases. Scene-selective ROI masking (PPA/OPA/RSC) causes a modest drop, suggesting partially distributed rather than region-dependent decoding.
-
Interpretable attention: Attention weights from the final layer concentrate on functionally appropriate regions (e.g., FFA/EBA for faces, PPA/OPA/RSC for places). UMAP projections of voxel attention weights form semantically organized clusters matching known cortical gradients.
-
Ablation results: Fine-tuning on real fMRI data substantially outperforms synthetic-pretraining-only and direct gradient-inversion baselines. Holding out the test subject during training has only a marginal effect, validating the training-free cross-subject claim.
-
Backbone robustness: The approach works across CLIP, DINOv2, and SigLIP visual encoders, with CLIP performing best on BOLD5000 (31.45% Top-1) and DINOv2 weakest (13.99% Top-1).
Methodology in Plain English
The core insight is that neural decoding is an inverse problem: to recover what someone saw, you need an accurate model of how their brain responds to images — their forward "encoding model" — and then invert it.
Rather than learning a decoder that maps brain activity directly to images (which would need retraining for every new person), BrainCoDec learns to infer a new person's forward model on the fly from a few examples, then invert it. This is done in two stages:
-
Per-voxel encoder inference. For each voxel, the model is given a small set of (image, activation) pairs and — via in-context learning with a pretrained transformer — outputs the parameters of that voxel's response function. This is done separately for each voxel, with context spanning stimuli.
-
Cross-voxel inversion. Each voxel is then represented as a token combining its inferred response function and the activation it produced for a novel test image. A transformer aggregates across these voxel tokens to predict the image's embedding.
Training follows a three-stage pipeline: (1) pretraining entirely on synthetic data (random Gaussian weights and simulated responses, no real fMRI); (2) extending to variable-length voxel contexts (randomly drawn between 200 and 4,000) so the model is robust to differing voxel counts; and (3) supervised fine-tuning on real fMRI with subject-specific responses. The model uses logit scaling instead of positional embeddings so it's invariant to voxel count and ordering, and is trained with a combined cosine + InfoNCE contrastive loss to balance reconstruction fidelity and discriminability.
Evaluation is done via nearest-neighbor image retrieval in the embedding space of a pretrained image encoder — a standard proxy for reconstruction quality that avoids confounding with the generative model.
Why This Matters
Impact on research: This work directly attacks the biggest practical barrier in brain decoding — inter-subject variability — by eliminating the need for per-subject training. It provides a principled computational framework for building population-wide brain foundation models, and its attention analyses offer a window into how semantic information is distributed across visual cortex.
Real-world applications:
- Brain–computer interfaces (BCIs): Devices that decode visual intent could be deployed on new users without lengthy calibration sessions.
- Clinical diagnostics and monitoring: Personalized assessment of visual or cognitive function (e.g., after stroke or in neurodegenerative disease) with minimal patient-specific data collection.
- Cognitive neuroscience research: Rapid translation of decoding models across labs, scanners, and subject pools without expensive per-subject retraining.
- Assistive communication: Restoring visual communication for patients with locked-in syndrome, where calibration time is costly or impossible.
Industry relevance: The training-free, cross-scanner property is significant for any commercial neurotechnology company whose business model depends on deploying decoding at scale across heterogeneous hardware and patient populations. Reducing data collection from ~10,000 images per subject to ~200 makes decoding far cheaper and more feasible outside research settings. The code and models are released publicly.
Future Directions
-
Extension to other modalities: The authors explicitly propose extending the same meta-learning + in-context inverse-function framework to EEG, MEG, and other neural signals.
-
Full image reconstruction: The current work decodes image embeddings rather than pixels. Integrating with generative models (e.g., Stable Diffusion, IP-Adapter) is a natural next step to produce photorealistic reconstructions.
-
Understanding the limits of context-free generalization: How does performance degrade with truly out-of-distribution subjects, clinical populations, or atypical neuroanatomy? The paper's BOLD5000 results are encouraging but limited in subject count.
-
Scaling and context efficiency: Can the model reach full-context performance with even fewer than 200 in-context images, and how does it behave when the available voxel set is severely restricted (e.g., surface EEG)?
Target Audience
This paper is most valuable to computational neuroscientists and machine learning researchers working on neural decoding, brain–computer interfaces, or transfer learning across heterogeneous biological signals. It is also relevant to neuroimaging practitioners seeking practical, deployment-ready decoding tools, and to cognitive neuroscientists interested in population-level models of visual cortex organization. Readers need a solid understanding of transformers, contrastive learning, and fMRI encoding models to fully engage with the methods sections.
Authors’ abstract
Visual decoding from brain signals is a key challenge at the intersection of computer vision and neuroscience, requiring methods that bridge neural representations and computational models of vision. A field-wide goal is to achieve generalizable, cross-subject models. A major obstacle towards this goal is the substantial variability in neural representations across individuals, which has so far required training bespoke models or fine-tuning separately for each subject. To address this challenge, we introduce a meta-optimized approach for semantic visual decoding from fMRI that generalizes to novel subjects without any fine-tuning. By simply conditioning on a small set of image-brain activation examples from the new individual, our model rapidly infers their unique neural encoding patterns to facilitate robust and efficient visual decoding. Our approach is explicitly optimized for in-context learning of the new subject's encoding model and performs decoding by hierarchical inference, inverting the encoder. First, for multiple brain regions, we estimate the per-voxel visual response encoder parameters by constructing a context over multiple stimuli and responses. Second, we construct a context consisting of encoder parameters and response values over multiple voxels to perform aggregated functional inversion. We demonstrate strong cross-subject and cross-scanner generalization across diverse visual backbones without retraining or fine-tuning. Moreover, our approach requires neither anatomical alignment nor stimulus overlap. This work is a critical step towards a generalizable foundation model for non-invasive brain decoding.