File size: 9,829 Bytes
3aefeeb 64a0c4a 23bcc8c 64a0c4a 3aefeeb 7b8f5e2 3aefeeb 23bcc8c 64a0c4a 3aefeeb 23bcc8c 3aefeeb 64a0c4a 3aefeeb 64a0c4a 3aefeeb 64a0c4a 23bcc8c 3aefeeb 42a31cf 3aefeeb 64a0c4a 3aefeeb 64a0c4a 3aefeeb 64a0c4a 3aefeeb 64a0c4a 3aefeeb 64a0c4a 3aefeeb 23bcc8c 203d32d 3aefeeb 23bcc8c 3aefeeb 23bcc8c 3aefeeb 23bcc8c 3aefeeb 15a317b 3aefeeb 23bcc8c 533f62e 23bcc8c 3aefeeb 23bcc8c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | ---
license: cc-by-nc-4.0
tags:
- fmri
- neuroscience
- masked-autoencoder
- vision-transformer
- brain
---
# CortexMAE-ReadyNeuro: encoder weights
CortexMAE-ReadyNeuro models are pretrained on [ReadyNeuro](https://github.com/SophontAI/ReadyNeuro):
the full corpus (`readyneuro-22373h/`, three seeds) and five nested subsets. The `hcpya-*` runs,
pretrained on HCP-YA, are the paper's ablations.
Encoder weights for the 19 pretraining runs in *Scaling fMRI Foundation Models with Native-Space
Data from Heterogeneous Public Studies* (NeurIPS 2026 Workshop on Foundation Models for the Brain
and Body).
- Paper: <https://openreview.net/forum?id=rLMKAJCLc1>
- Blog post: <https://sophont.med/blog/native-fmri/>
- Code: <https://github.com/SophontAI/CortexMAE-ReadyNeuro>
- Data: <https://github.com/SophontAI/ReadyNeuro> (full corpus on S3) and a 500 GB subset at
[medarc/ReadyNeuro](https://huggingface.co/datasets/medarc/ReadyNeuro)
## Model
Each run folder (`<folder>/seed<N>/`) holds the encoder of a 4D ViT-L masked autoencoder for fMRI, taken from the final
checkpoint (step 200,000) of one pretraining run.
- 24 transformer blocks, width 1024, 16 heads, 303M parameters, stored in fp32 (1.2 GB per file).
- Tokens are patches of 6×6×6 voxels of 2 mm (12 mm per side) × 4 frames (4 s). A 16-frame clip
gives 4 tokens per spatial patch.
- Positions enter through rotary embeddings on patch centres in world millimetres, read from each
scan's affine.
- Pretrained on native-space fMRI: volumes are rigidly aligned to a 2 mm MNI152NLin2009cAsym grid,
without nonlinear normalization. The `hcpya-mni` runs are the exception. They use the HCP
minimally preprocessed volumes, which are nonlinearly normalized to MNI space.
- Only the encoder is released. The decoder and optimizer state are not, so these files cannot
resume training or score reconstruction.
Each run folder has `model.safetensors`, the encoder state dict with the training step in its
header, and `config.yaml`, the `model` and `preproc` settings that rebuild it. `MANIFEST.tsv` maps
each folder to its training run and lists the SHA-256 of each weights file. Run names are the
original training-run names: `b1`, `b4`, `b8` and `b16` are the first 1, 4, 8 and 16 shard
batches, and `h1604` is the 1,520 h subset.
## Folders
| folder | pretraining corpus | preparation | stored BOLD hours | seeds | runs |
|---|---|---|---:|---|---:|
| `readyneuro-747h/` | ReadyNeuro subset, 459 studies | native | 747 | 42, 43 | 2 |
| `readyneuro-1520h/` | ReadyNeuro subset, 604 studies | native | 1,520 | 42, 43 | 2 |
| `readyneuro-2984h/` | ReadyNeuro subset, 708 studies | native | 2,984 | 42, 43 | 2 |
| `readyneuro-5919h/` | ReadyNeuro subset, 762 studies | native | 5,919 | 42, 43 | 2 |
| `readyneuro-11837h/` | ReadyNeuro subset, 800 studies | native | 11,837 | 42, 43 | 2 |
| `readyneuro-22373h/` | ReadyNeuro, full corpus, 837 studies | native | 22,373 | 42, 43, 44 | 3 |
| `hcpya-native/` | HCP-YA, 880 participants | native | 1,482 | 42, 43, 44 | 3 |
| `hcpya-mni/` | HCP-YA, 880 participants | MNI (HCP minimal preprocessing) | 1,482 | 42, 43, 44 | 3 |
The ReadyNeuro subsets are nested: each is a prefix of the next,
up to the paper's full corpus. The 1,520 h subset matches HCP-YA in hours.
## Usage
Install the code (Python 3.14):
```sh
git clone https://github.com/SophontAI/CortexMAE-ReadyNeuro.git
cd CortexMAE-ReadyNeuro
pip install -e '.[eval]'
```
To load the weights in Python only, `pip install -e .` is enough.
Download one run:
```python
from huggingface_hub import snapshot_download
root = snapshot_download("medarc/CortexMAE-ReadyNeuro", allow_patterns="readyneuro-22373h/seed42/*")
folder = f"{root}/readyneuro-22373h/seed42"
```
Load it:
```python
import torch
from fmrifm.checkpoint import load_weights
from fmrifm.config import parse_config
from fmrifm.model import build_model
model = build_model(parse_config(["--config", f"{folder}/config.yaml"]))
load_weights(f"{folder}/model.safetensors", model) # strict; fills model.encoder, the decoder stays untrained
model.eval()
# x [B, 16, N, 216]: N patches of 6^3 voxels over 16 frames; coord [B, N, 3]: patch centres in mm;
# valid [B, N]: False marks padding patches
with torch.inference_mode():
tokens = model(x, coord, valid=valid, compute_loss=False) # [B, 4, N, 1024]
```
To build `x` and `coord` from a ReadyNeuro shard, see
[Tokenize without densifying](https://github.com/SophontAI/CortexMAE-ReadyNeuro#tokenize-without-densifying).
For one subject, `valid` is all `True`.
Inputs follow the training preprocessing: 1 s frames, each voxel z-scored within its run, then each
frame z-scored across the subject's cortical grey-matter voxels, voxels outside that mask set to 0,
only patches with more than 10% cortical grey matter kept, and values clipped to ±3.
ReadyNeuro builds the per-run steps, and the Brainmarks plugin applies the per-frame and
patch steps.
In Brainmarks, use the model plugin `fmrifm_native` or
`fmrifm_mni` with `model_kwargs.ckpt_path=<folder>/model.safetensors`. The plugin reads the
`config.yaml` beside the weights. The plugin name selects which preparation of the benchmark data
to evaluate on, and every folder works with both. `scripts/eval_brainmarks.sbatch`
runs all 14 tasks (seven targets × two preparations) and takes the weights path as its fourth
argument. The evaluation data is not redistributed. Build it with [ReadyNeuro](https://github.com/SophontAI/ReadyNeuro). AABC also
needs its per-subject target maps (`AABC_TARGETS_ROOT`), which are not public.
The plugin needs the Brainmarks fork pinned by the `eval` extra
([Aceticia/Brainmarks@d464007](https://github.com/Aceticia/Brainmarks/tree/d4640074168f1c6dcb0a94ec78801577792be3f4)),
which the install above provides. Upstream [Brainmarks](https://github.com/MedARC-AI/Brainmarks)
lacks the padding mask the plugin returns.
## Training
All 19 runs use one recipe (`configs/model.yaml`). Only the corpus and the seed
differ. Each sample is a 16-frame (16 s) clip from one BOLD run, read within the subject's cortical
grey-matter mask. The encoder sees
96 spatial patches over the whole clip (384 tokens), and the decoder reconstructs 32 other spatial
patches. Training ran 200,000 AdamW updates with
batch size 128, peak learning rate 7.1e-5, 5,000 warmup steps, cosine decay and weight decay 0.05,
in bf16 mixed precision on one H100 GPU. Each run took 60-123 H100-hours.
## Data
ReadyNeuro, the preprocessed OpenNeuro corpus, is released under CC0 1.0; access instructions are in
the [ReadyNeuro repository](https://github.com/SophontAI/ReadyNeuro#get-the-data). The CortexMAE-ReadyNeuro models were
trained on the paper's corpus (837 training studies; the 838th stored accession is validation-only)
or on nested subsets of it. That corpus includes 21 studies since withdrawn from OpenNeuro (290 h of
the 22,373 h), which are removed from the public release of ReadyNeuro, so retraining on the public corpus will
not reproduce these runs exactly.
HCP-YA is not redistributed. Access requires registration with the Human Connectome Project.
## Evaluation
The paper reports frozen-encoder results on seven targets: HCP-YA task condition (Task21), NSD COCO
category, AABC age bin and sex, and PPMI, ABIDE and ADHD-200 diagnosis. Table 1 covers the
`hcpya-mni`, `hcpya-native`, `readyneuro-1520h` and `readyneuro-22373h` runs on MNI-normalized
benchmark scans; Appendix Table 6 covers all eight folders on both MNI-normalized and native-space
benchmark scans. All were scored with Brainmarks, with the encoder under fp16 autocast.
## HCP-YA
The `hcpya-native` and `hcpya-mni` models were trained on HCP-YA data.
> Data were provided in part by the Human Connectome Project, WU-Minn Consortium (Principal
> Investigators: David Van Essen and Kamil Ugurbil; 1U54MH091657) funded by the 16 NIH Institutes
> and Centers that support the NIH Blueprint for Neuroscience Research; and by the McDonnell Center
> for Systems Neuroscience at Washington University.
Users of the `hcpya-*` models should follow the
[WU-Minn HCP Open Access Data Use Terms](https://www.humanconnectome.org/study/hcp-young-adult/document/wu-minn-hcp-consortium-open-access-data-use-terms).
## Limitations
- Four OpenNeuro training studies overlap the HCP-YA evaluation. `ds003452` and `ds003465` share
HCP-YA participants, and `ds000244` and `ds002685` re-run the HCP task battery. The paper's
pretraining corpus kept them. Account for this when evaluating `readyneuro-*` models on HCP-YA. The
audit covered the HCP task battery only; stimulus overlap with the other benchmarks was not checked.
- The `hcpya-*` models were pretrained on HCP-YA runs that include the Task21 probe's training
participants; only its validation and test participants are held out. Use the Brainmarks splits
when evaluating them on HCP-YA.
- Every run trained for a fixed 200,000 updates. Held-out reconstruction loss was still falling at
the end of every `readyneuro-*` run, and the 747 h model shows signs of overfitting.
- The models expect the paper's preparation: a 2 mm grid, 1 s frames and patches from a cortical
grey-matter mask. Other preparations are untested.
## License
The weights are released under CC BY-NC 4.0. The code is MIT.
## Citation
If you use these weights, please cite our paper:
```bibtex
@inproceedings{liu2026scaling,
title = {Scaling {fMRI} Foundation Models with Native-Space Data from Heterogeneous Public Studies},
author = {Liu, Xujin Chris and Lane, Connor and Muhammad, Hassan and Abraham, Tanishq Mathew and Scotti, Paul Steven},
booktitle = {NeurIPS 2026 Workshop on Foundation Models for the Brain and Body},
year = {2026},
url = {https://openreview.net/forum?id=rLMKAJCLc1}
}
```
Contact: paul@sophont.med
|