File size: 3,736 Bytes
59f3f00
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
tags:
- pytorch
- fmri
- neuroscience
- representation-learning
- brain-atlas
---

# BrainLEAP

[![GitHub Repository](https://img.shields.io/badge/GitHub-Repository-181717?style=flat-square&logo=github&logoColor=white)](https://github.com/OneMore1/BrainLEAP) [![Hugging Face Models](https://img.shields.io/badge/Hugging%20Face-Models-007ACC?style=flat-square&logo=huggingface&logoColor=FFD21E)](https://huggingface.co/OneMore1/BrainLEAP)

BrainLEAP is a pretrained fMRI encoder that pairs each region's time series with an encoding of its spatial support. This release contains the RBF-conditioned main model and the frozen transform needed to use it with a new atlas. The implementation and input manifest format are in [OneMore1/BrainLEAP](https://github.com/OneMore1/BrainLEAP/tree/10e93cc0c52a731de7b970d7b8608946f2ea6aa8).

| File | Use |
| --- | --- |
| `brainleap.pth` | PyTorch checkpoint after the 160th epoch. The frozen extractor loads the encoder, not the pretraining projector. |
| `rbf_transform.npz` | The paired transform: spatial anchors, RBF bandwidths, standardization statistics and PCA basis. Use it as supplied; do not refit it on the target atlas. |

## Inputs and outputs

The encoder takes preprocessed ROI time series and matching 128-dimensional geometry codes in the same ROI order. The default window is 200 time points. A forward pass yields a 768-dimensional CLS representation per window, or a 768-dimensional contextual representation per ROI after temporal pooling. These are features, not diagnostic scores or calibrated predictions.

The main encoder has 12 Transformer blocks, 12 attention heads and 96,240,896 parameters. It was trained on 47,943 windows. During pretraining, each ROI window was min-max scaled before cropping and augmentation, and each view was then z-scored over time. For frozen extraction, the loader z-scores each ROI window directly without augmentation. Supply unscaled, preprocessed ROI signals to the loader; do not manually apply a second normalization.

## Use with the BrainLEAP code

Install the [BrainLEAP source package](https://github.com/OneMore1/BrainLEAP) and run the commands below from its repository root. Download both files from this model repository into `checkpoints/`. Keep the checkpoint as downloaded: `configs/brainleap.yaml` checks its file digest and verifies the RBF transform identity recorded in the encoded atlas.

```bash
brainleap-geometry encode --atlas data/atlas.nii.gz --transform checkpoints/rbf_transform.npz --out data/atlas_ge.npz
brainleap-extract --config configs/brainleap.yaml --manifest data/downstream.csv --checkpoint checkpoints/brainleap.pth --output outputs/features --device cpu
```

Use the generated geometry file in the manifest, with paths relative to the manifest location; see the [data format](https://github.com/OneMore1/BrainLEAP/blob/10e93cc0c52a731de7b970d7b8608946f2ea6aa8/docs/data.md). For regional features, add `--representation roi` and use a separate output directory. The model does not require an atlas-ID embedding. It does require the atlas mask to be in the coordinate space of the supplied transform and each feature row to identify the correct ROI.

## Intended use and limits

For research on fMRI representation learning, frozen readouts and cross-atlas transfer. No participant data, cohort manifests or task-specific readout heads are included. Performance on a different cohort, acquisition protocol or atlas must be evaluated independently. This release is not validated for clinical diagnosis or individual decision-making.

The source repository's Apache-2.0 licence applies to the code. It does not grant a licence to the model weights, the paired transform or the underlying datasets.