initial commit
Browse files- .gitattributes +1 -0
- LICENSE +11 -0
- README.md +108 -0
- assets/brain-of-logo.png +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
assets/brain-of-logo.png filter=lfs diff=lfs merge=lfs -text
|
LICENSE
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Brain-OF Large checkpoint license
|
| 2 |
+
|
| 3 |
+
The model checkpoint weights released in this repository are licensed under Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0).
|
| 4 |
+
|
| 5 |
+
Full license terms:
|
| 6 |
+
https://creativecommons.org/licenses/by-nc/4.0/legalcode.en
|
| 7 |
+
|
| 8 |
+
This notice applies to the checkpoint weights. The training and model implementation code is distributed separately under Apache License 2.0:
|
| 9 |
+
https://github.com/HanningGuo/BrainOF/blob/main/LICENSE
|
| 10 |
+
|
| 11 |
+
Source datasets retain their original licenses and access requirements.
|
README.md
CHANGED
|
@@ -1,3 +1,111 @@
|
|
| 1 |
---
|
| 2 |
license: cc-by-nc-4.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: cc-by-nc-4.0
|
| 3 |
+
tags:
|
| 4 |
+
- pytorch
|
| 5 |
+
- brain-of
|
| 6 |
+
- neuroimaging
|
| 7 |
+
- fmri
|
| 8 |
+
- eeg
|
| 9 |
+
- meg
|
| 10 |
+
- omnifunctional modality
|
| 11 |
+
- brain foundation model
|
| 12 |
+
- joint pretraining
|
| 13 |
+
- arxiv:2602.23410
|
| 14 |
---
|
| 15 |
+
|
| 16 |
+
<p align="center">
|
| 17 |
+
<img src="assets/brain-of-logo.png" width="80" alt="Brain-OF logo">
|
| 18 |
+
</p>
|
| 19 |
+
|
| 20 |
+
<h1 align="center">Brain-OF Large</h1>
|
| 21 |
+
|
| 22 |
+
<p align="center">
|
| 23 |
+
<strong>Brain-OF: An Omnifunctional Foundation Model for fMRI, EEG and MEG</strong><br>
|
| 24 |
+
NeurIPS 2026
|
| 25 |
+
</p>
|
| 26 |
+
|
| 27 |
+
<p align="center">
|
| 28 |
+
<a href="https://hanningguo.github.io/BrainOF/"><img src="https://img.shields.io/badge/Project-Website-3564C0" alt="Project website"></a>
|
| 29 |
+
<a href="https://arxiv.org/abs/2602.23410"><img src="https://img.shields.io/badge/arXiv-2602.23410-B31B1B" alt="Paper on arXiv"></a>
|
| 30 |
+
<a href="https://github.com/HanningGuo/BrainOF"><img src="https://img.shields.io/badge/GitHub-Code-181717" alt="Code on GitHub"></a>
|
| 31 |
+
</p>
|
| 32 |
+
|
| 33 |
+
<!-- Replace YOUR_NAMESPACE throughout this card before publishing. -->
|
| 34 |
+
|
| 35 |
+
## Introduction
|
| 36 |
+
|
| 37 |
+
<p align="justify">
|
| 38 |
+
Brain-OF Large is a foundation model jointly pretrained on <strong>fMRI, EEG, and MEG</strong>, aiming to learn richer representations through cross-modal synergy.
|
| 39 |
+
<strong>ARNESS</strong> maps signals with varying channel/ROI counts and temporal resolutions to a shared latent space. <strong>Sparse MoE</strong> captures shared and modality-specific patterns, while <strong>DINT attention</strong> filters irrelevant context and integrates local and global dependencies. <strong>Masked Temporal-Frequency Modeling</strong> pretrains the model to reconstruct masked signals in the time and frequency domains.
|
| 40 |
+
Pretrained on <strong>37 public datasets</strong> with <strong>5.87 million samples</strong> from <strong>32,278 participants</strong>, the model supports unimodal and paired multimodal downstream tasks.
|
| 41 |
+
</p>
|
| 42 |
+
|
| 43 |
+
## Model specifications
|
| 44 |
+
|
| 45 |
+
| Property | Value |
|
| 46 |
+
| --- | --- |
|
| 47 |
+
| Total parameters | 331M |
|
| 48 |
+
| Active parameters per token | 150M |
|
| 49 |
+
| Backbone layers | 24 |
|
| 50 |
+
| Patch size | 64 time points |
|
| 51 |
+
| Checkpoint format | PyTorch `.pth`; DDP loading path |
|
| 52 |
+
|
| 53 |
+
## Usage
|
| 54 |
+
|
| 55 |
+
After [installing the environment](https://github.com/HanningGuo/BrainOF#installation), replace the checkpoint path below and run the example from the BrainOF repository root. It extracts a **512-dimensional embedding** from a randomly generated signal:
|
| 56 |
+
|
| 57 |
+
```python
|
| 58 |
+
import numpy as np
|
| 59 |
+
import torch
|
| 60 |
+
from datasets import DataTransform
|
| 61 |
+
from models.transformer import brainof_large_331M_A150M
|
| 62 |
+
|
| 63 |
+
model = brainof_large_331M_A150M(num_classes=0, layer_scale_type="per_channel")
|
| 64 |
+
checkpoint = torch.load(
|
| 65 |
+
"/path/to/brainof_large_331M_A150M.pth", map_location="cpu", weights_only=False
|
| 66 |
+
)
|
| 67 |
+
weights = {
|
| 68 |
+
k.removeprefix("encoder."): v
|
| 69 |
+
for k, v in checkpoint["model"].items() if k.startswith("encoder.")
|
| 70 |
+
}
|
| 71 |
+
model.load_state_dict(weights)
|
| 72 |
+
model.eval()
|
| 73 |
+
|
| 74 |
+
# Generate a random signal: 19 channels, 2,000 time points
|
| 75 |
+
signal = np.random.default_rng(0).standard_normal((19, 2000)).astype(np.float32)
|
| 76 |
+
transform = DataTransform(signal_size=signal.shape, patch_size=64, max_seq_length=2048)
|
| 77 |
+
patches, mask, _ = transform(signal)
|
| 78 |
+
x = torch.tensor(patches, dtype=torch.float32).unsqueeze(0)
|
| 79 |
+
attn_mask = torch.tensor(mask, dtype=torch.bool).unsqueeze(0)
|
| 80 |
+
|
| 81 |
+
with torch.inference_mode():
|
| 82 |
+
embedding = model(x, attn_mask)
|
| 83 |
+
print(embedding.shape) # torch.Size([1, 512])
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
For real data, replace the random signal with a [preprocessed](https://github.com/HanningGuo/BrainOF#data-preparation) NumPy array of shape `(channels_or_ROIs, time_points)`. `DataTransform` normalizes, patches, and pads it. We recommend using at most **2,048 patch tokens** per sample and the token count must not exceed `max_seq_length` (see [Input Size and Tokenization](https://github.com/HanningGuo/BrainOF#input-size-and-tokenization)).
|
| 87 |
+
|
| 88 |
+
## Model family
|
| 89 |
+
|
| 90 |
+
| Model | Total parameters | Active / token | Layers | Embedding dim. |
|
| 91 |
+
| :--- | ---: | ---: | ---: | ---: |
|
| 92 |
+
| [](https://huggingface.co/han-ning/Brain-OF-Base) | 47.5M | 21.5M | 12 | 256 |
|
| 93 |
+
| <a href="https://huggingface.co/han-ning/Brain-OF-Large" title="Current model"><img src="https://img.shields.io/badge/Brain--OF-Large-FFD21E" alt="Brain-OF Large — current model" style="outline: 2px solid #A87900; outline-offset: -2px; border-radius: 3px;"></a> | **331M** | **150M** | **24** | **512** |
|
| 94 |
+
| [](https://huggingface.co/han-ning/Brain-OF-Huge) | 1.7B | 500M | 36 | 768 |
|
| 95 |
+
| [](https://huggingface.co/han-ning/Brain-OF-Giant) | 9B | 1.2B | 48 | 1024 |
|
| 96 |
+
|
| 97 |
+
## License
|
| 98 |
+
|
| 99 |
+
This repository and the model weights are licensed under the [CC BY-NC 4.0](LICENSE).
|
| 100 |
+
|
| 101 |
+
## Citation
|
| 102 |
+
|
| 103 |
+
```bibtex
|
| 104 |
+
@inproceedings{guo2026brainof,
|
| 105 |
+
title = {{Brain-OF}: An Omnifunctional Foundation Model for {fMRI}, {EEG} and {MEG}},
|
| 106 |
+
author = {Guo, Hanning and Bi, Hanwen and Abdellatif, Farah and Galbenus, Andrei and Shah, Jon. N. and Morrison, Abigail and Dammers, Jürgen},
|
| 107 |
+
booktitle = {Advances in Neural Information Processing Systems},
|
| 108 |
+
year = {2026},
|
| 109 |
+
url = {https://arxiv.org/abs/2602.23410}
|
| 110 |
+
}
|
| 111 |
+
```
|
assets/brain-of-logo.png
ADDED
|
Git LFS Details
|