openmind / README.md
benoit-dufumier's picture
OpenMind preprocessed: quasiraw-v2.1.1, cat12vbm-12.8.2, participants.tsv, val_split.csv
ed0af62
|
Raw History Blame Contribute Delete
15.2 kB
---
license: cc-by-4.0
pretty_name: OpenMind (preprocessed, NeuroSpin)
task_categories:
- image-feature-extraction
tags:
- 3d
- mri
- neuroimaging
- brain
- medical
- webdataset
- self-supervised-learning
- voxel-based-morphometry
- cat12
size_categories:
- 10K<n<100K
configs:
- config_name: quasiraw-v2.1.1
data_files:
- split: train
path: quasiraw-v2.1.1/*/*.tar
- config_name: cat12vbm-12.8.2
data_files:
- split: train
path: cat12vbm-12.8.2/*/*.tar
---
# OpenMind: preprocessed brain MRI (NeuroSpin)
Preprocessed versions of the [OpenMind dataset](https://huggingface.co/datasets/MIC-DKFZ/OpenMind)
(Wald et al., 2025): head & neck 3D MRI pooled from ~800 [OpenNeuro](https://openneuro.org)
datasets. Here the brain T1w, T2w and FLAIR images were preprocessed at
[NeuroSpin](https://joliot.cea.fr/drf/joliot/en/Pages/research_entities/NeuroSpin.aspx)
using [brainprep](https://github.com/brainprepdesk/brainprep) and packed as
[WebDataset](https://github.com/webdataset/webdataset) shards, ready for large-scale
(e.g. self-supervised) deep learning.
| Folder | Pipeline | Status |
|---|---|---|
| `quasiraw-v2.1.1/` | brainprep quasi-raw v2.1.1 (T1w, T2w, FLAIR) | available |
| `cat12vbm-12.8.2/` | CAT12 12.8.2 VBM via brainprep v2.1.0 (T1w): grey matter maps + ROI morphometry | available |
All folders share the same sample identifiers: (`dataset_id`, `subject`, `session`, `run`),
with `dataset_id` the shard folder name, so derivatives of the same scan can be joined
across folders.
## Repository layout
```
README.md
val_split.csv # recommended validation split, for all folders (see below)
participants.tsv # per scan: age, sex, bmi, race, handedness, health_status
quasiraw-v2.1.1/ # see below
cat12vbm-12.8.2/ # see below
```
Each preprocessing folder holds one folder of WebDataset shards per OpenNeuro dataset and an
`index.json.gz` with the byte offsets of every file of the shards, used by
[nidl](#usage-with-nidl) for random access.
## Validation split
`val_split.csv` (columns `dataset_id, participant_id, session, run`) defines a held-out
validation set made of **whole datasets** (no subject or dataset is shared with training),
stratified on age, sex and BMI. It holds ~10% of the images. Only the rows listed in the
csv belong to validation. The others belong to training.
The split is given by scan identifiers, shared by all folders: it applies to
`quasiraw-v2.1.1` and `cat12vbm-12.8.2` alike.
## Usage with nidl
[nidl](https://github.com/neurospin-deepinsight/nidl) provides an `OpenMind`
PyTorch `Dataset` that reads the shards by byte offset (from `index.json.gz`): random access,
any sampler and any number of `DataLoader` workers, modality pairing and the subject-level
train / val split. By default the images are streamed from this repository with HTTP range
requests (nothing is written to disk but the index and the split); `streaming=False`
downloads the needed shards first.
```bash
pip install "git+https://github.com/neurospin-deepinsight/nidl"
```
```python
from torch.utils.data import DataLoader
from nidl.datasets import OpenMind
root = "openmind" # local mirror of this repository, files are fetched on demand
# Quasi-raw: one T1w image per item, subject-level split from <root>/val_split.csv
train = OpenMind(root, preprocessing="quasiraw", modality="t1", split="train", apply_mask=True)
val = OpenMind(root, preprocessing="quasiraw", modality="t1", split="val", apply_mask=True)
print(train[0].shape) # (1, 182, 218, 182)
# Quasi-raw: paired T1w / T2w acquired in the same session
paired = OpenMind(root, modality=("t1", "t2"), group_by="session", split="train")
sample = paired[0] # {"t1": array, "t2": array}
# CAT12 VBM: grey matter map and ROI morphometry
vbm = OpenMind(root, preprocessing="cat12vbm", split="train", return_morphometry=True)
gm, morphometry = vbm[0]
print(gm.shape, morphometry["total_volumes"]["TIV"]) # (1, 113, 137, 113) ...
loader = DataLoader(train, batch_size=8, shuffle=True, num_workers=8)
```
`nidl` does not read the CAT12 quality ratings (`qc.json`): use the webdataset example of the
`cat12vbm-12.8.2` section to get them.
## `quasiraw-v2.1.1`
### Content
| | |
|---|---|
| Images | 71,490 (T1w 42,941 · T2w 23,935 · FLAIR 4,614) |
| Subjects | 33,738 |
| Source datasets | 787 OpenNeuro datasets |
| Size | 462 GB, 849 shards |
| Image grid | 182 × 218 × 182, 1 mm isotropic, MNI152 space, float32 |
### Preprocessing
[brainprep](https://github.com/brainprepdesk/brainprep) `subject-level-quasiraw` (v2.1.1
container), applied per modality, with the matching MNI152 template (T1 template for T1w,
T2 template for T2w / FLAIR):
1. Reorientation to the MNI152 orientation.
2. Brain mask with FreeSurfer [SynthStrip](https://surfer.nmr.mgh.harvard.edu/docs/synthstrip/).
3. N4 bias field correction.
4. Resampling to 1 mm isotropic.
5. Linear (affine, 9 DOF) registration to the MNI152 1 mm template.
6. The registration is applied to the bias-corrected image and the brain mask; the image
is then multiplied by the mask (skull-stripped).
"Quasi-raw" means minimal preprocessing: no non-linear warp, no tissue segmentation, no
intensity standardization across scans. Intensities are those of the bias-corrected scan.
### Layout
```
quasiraw-v2.1.1/
├── index.json.gz # byte offsets for random access (nidl)
└── <dataset_id>/ # one folder per OpenNeuro dataset, e.g. ds000001
└── <dataset_id>-NNNNNN.tar # WebDataset shard(s), ≤ ~3 GB each
```
Each sample is one image of one (subject, session, run, modality). Its key is
`sub-<label>_ses-<label>_mod-<t1|t2|flair>_run-<id>` (`ses-DEFAULT` when the source has no
session) and it holds three files:
| Extension | Content |
|---|---|
| `<mod>.nii.gz` | skull-stripped image in MNI space (`<mod>` = `t1`, `t2` or `flair`) |
| `<mod>_mask.nii.gz` | binary brain mask, same grid |
| `meta.json` | `subject`, `session`, `modality`, `run`, BIDS `entities` |
Different subjects can have the same subject's id across different OpenNeuro datasets: a
subject is thus uniquely identified by the pair (`dataset_id`, `subject`), with `dataset_id` given
by the shard folder name.
The `run` is the BIDS `run-` index of the source file when it is unambiguous, otherwise a
hash of the source file name (brainprep convention).
### Streaming with webdataset
Without downloading (`pip install webdataset nibabel huggingface_hub`):
```python
import gzip, io, json
import nibabel as nib
import webdataset as wds
from huggingface_hub import HfFileSystem, hf_hub_url
repo = "neurospin/openmind"
fs = HfFileSystem()
shards = sorted(fs.glob(f"datasets/{repo}/quasiraw-v2.1.1/*/*.tar"))
urls = [hf_hub_url(repo, s.split(f"{repo}/", 1)[1], repo_type="dataset") for s in shards]
def load_nifti(b):
fh = nib.FileHolder(fileobj=io.BytesIO(gzip.decompress(b)))
return nib.Nifti1Image.from_file_map({"header": fh, "image": fh})
def decode(s):
meta = json.loads(s["meta.json"])
mod = meta["modality"]
return {
"dataset_id": s["__url__"].rsplit("/", 2)[-2],
"meta": meta,
"image": load_nifti(s[f"{mod}.nii.gz"]).get_fdata(dtype="float32"),
"mask": load_nifti(s[f"{mod}_mask.nii.gz"]).get_fdata(dtype="float32") > 0,
}
ds = wds.WebDataset([f"pipe:curl -s -L {u}" for u in urls], shardshuffle=True).map(decode)
sample = next(iter(ds))
print(sample["dataset_id"], sample["meta"], sample["image"].shape)
```
### Quality control
No manual QC beyond the source curation was applied to this release: a small fraction of
images may have failed skull-stripping or registration. The source OpenMind metadata
includes a per-modality, per-dataset image quality score (1–5) that can be used to filter.
## `cat12vbm-12.8.2`
### Content
| | |
|---|---|
| Images | 42,951 T1w (41,353 pass the CAT12 quality check, see below) |
| Subjects | 32,995 |
| Sessions | 38,047 |
| Source datasets | 780 OpenNeuro datasets |
| Size | 121 GB, 784 shards |
| Image grid | 113 × 137 × 113, 1.5 mm isotropic, MNI152NLin2009cAsym space, float32 |
| Morphometry | 15 atlases (ROI grey / white matter / CSF volumes) + total volumes |
43,076 T1w images were processed: 125 are missing from this release because CAT12 failed
on them or their group-level measures could not be computed.
### Preprocessing
[brainprep](https://github.com/brainprepdesk/brainprep) `subject-level-vbm` and
`group-level-vbm` (v2.1.0 container) running
[CAT12](https://neuro-jena.github.io/cat/) 12.8.2 (r2166, SPM12 standalone), with the
brainprep CAT12 batch (cross-sectional, DARTEL registration):
1. Bias correction, affine registration to MNI and tissue segmentation (grey matter, white
matter, CSF) with CAT12.
2. Non-linear registration (DARTEL) to the CAT12 MNI152NLin2009cAsym template, resampled at
1.5 mm.
3. The released image is the **modulated normalized grey matter map** (`mwp1`): GM tissue
probability multiplied by the Jacobian of the warp, so that voxel values sum to the
subject's GM volume.
4. ROI volumes are computed by CAT12 in native space for each atlas; total intracranial
(TIV), grey matter, white matter and CSF volumes come from the CAT12 report.
### Layout
```
cat12vbm-12.8.2/
├── index.json.gz # byte offsets for random access (nidl)
└── <dataset_id>/ # one folder per OpenNeuro dataset, e.g. ds000001
└── <dataset_id>-NNNNNN.tar # WebDataset shard(s), ≤ ~3 GB each
```
Each sample is one T1w image of one (subject, session, run). Its key is
`sub-<label>_ses-<label>_mod-mwp1_run-<id>` and it holds four files:
| Extension | Content |
|---|---|
| `mwp1.nii.gz` | modulated grey matter map in MNI space |
| `morphometry.json` | `{<atlas>: {<feature>: value}}`, volumes in cm³ (see below) |
| `qc.json` | `{"group_stats": {"NCR", "ICR", "IQR", "qc"}}` (see Quality control) |
| `meta.json` | `dataset`, `subject`, `session`, `run` |
`run` follows the same convention as `quasiraw-v2.1.1`: the BIDS `run-` index of the source
file when it is unambiguous, otherwise a hash of the source file name (brainprep
convention). A sample of this folder and the `quasiraw-v2.1.1` T1w sample of the same scan
thus share (`dataset_id`, `subject`, `session`, `run`) in `meta.json`: 42,850 of the 42,951
samples have such a quasi-raw counterpart (the other 101 scans failed quasi-raw
preprocessing, mostly because their raw image contains NaN voxels).
#### Morphometry
`morphometry.json` holds one entry per atlas. Features are named `<tissue>_<ROI name>` with
`<tissue>` in `Vgm` (grey matter), `Vwm` (white matter) and `Vcsf` (CSF) volumes, in cm³:
| Atlas | Tissues | Features |
|---|---|---|
| `neuromorphometrics` | Vgm, Vwm, Vcsf | 408 |
| `hammers` | Vgm, Vwm, Vcsf | 285 |
| `ibsr` | Vgm, Vwm, Vcsf | 96 |
| `lpba40` | Vgm, Vwm | 112 |
| `cobra` | Vgm, Vwm | 104 |
| `mori` | Vgm, Vwm | 256 |
| `julichbrain` | Vgm, Vwm | 496 |
| `suit` | Vgm, Vwm | 56 |
| `aal3` | Vgm | 170 |
| `thalamus` | Vgm | 14 |
| `thalamic_nuclei` | Vgm | 22 |
| `Schaefer2018_{100,200,400,600}Parcels_17Networks_order` | Vgm, Vwm | 200, 400, 800, 1200 |
| `total_volumes` | | `TIV`, `GM_Vol`, `WM_Vol`, `CSF_Vol` |
### Streaming with webdataset
See [Usage with nidl](#usage-with-nidl) for random access. Streaming without downloading
(`pip install webdataset nibabel huggingface_hub`):
```python
import gzip, io, json
import nibabel as nib
import webdataset as wds
from huggingface_hub import HfFileSystem, hf_hub_url
repo = "neurospin/openmind"
fs = HfFileSystem()
shards = sorted(fs.glob(f"datasets/{repo}/cat12vbm-12.8.2/*/*.tar"))
urls = [hf_hub_url(repo, s.split(f"{repo}/", 1)[1], repo_type="dataset") for s in shards]
def load_nifti(b):
fh = nib.FileHolder(fileobj=io.BytesIO(gzip.decompress(b)))
return nib.Nifti1Image.from_file_map({"header": fh, "image": fh})
def decode(s):
return {
"dataset_id": s["__url__"].rsplit("/", 2)[-2],
"meta": json.loads(s["meta.json"]),
"gm": load_nifti(s["mwp1.nii.gz"]).get_fdata(dtype="float32"),
"morphometry": json.loads(s["morphometry.json"]),
"qc": json.loads(s["qc.json"])["group_stats"],
}
ds = (wds.WebDataset([f"pipe:curl -s -L {u}" for u in urls], shardshuffle=True)
.map(decode)
.select(lambda s: s["qc"]["qc"] == 1)) # keep scans passing the CAT12 QC
sample = next(iter(ds))
print(sample["dataset_id"], sample["meta"], sample["gm"].shape,
sample["morphometry"]["total_volumes"]["TIV"])
```
### Quality control
`qc.json` holds the CAT12 image quality ratings of the scan: noise to contrast ratio (`NCR`),
inhomogeneity to contrast ratio (`ICR`) and the overall image quality rating (`IQR`), on the
CAT12 grading scale (lower is better). `qc` is 1 when `NCR < 4.5` and `IQR < 4.5`, the
thresholds of [OpenBHB](https://baobablab.github.io/bhb/) (Dufumier et al., 2022), and 0
otherwise; 41,353 of the 42,951 images pass. No visual QC was applied.
## Phenotypes / metadata
`participants.tsv` (tab-separated) gives the phenotypes of every scan of this repository, one
row per scan (66,661 rows, 33,827 subjects, 790 datasets), identified by `dataset_id`,
`participant_id`, `session` and `run`: it joins with the `meta.json` of any folder on
(`dataset_id`, `subject`, `session`, `run`). Missing values are `n/a`.
| Column | Values | Available for |
|---|---|---|
| `age` | years (2–100) | 36,299 scans |
| `sex` | `female`, `male` | 40,670 scans |
| `bmi` | kg/m² | 6,107 scans |
| `race` | e.g. `white/caucasian`, `african american/black`, `asian`, `multiracial/mixed` | 5,018 scans |
| `handedness` | `right`, `left`, `ambidextrous` | 13,585 scans |
| `health_status` | `healthy`, `ill` | 14,166 scans |
Scanner information and the per-dataset image quality scores are in the original OpenMind
release: see [MIC-DKFZ/OpenMind](https://huggingface.co/datasets/MIC-DKFZ/OpenMind).
## License and citation
The original OpenMind dataset is released under CC-BY 4.0 and is built from OpenNeuro
datasets, most of which are released under CC0. This derivative is released under
**CC-BY 4.0**. If you use it, please cite OpenMind, the OpenNeuro datasets you use,
brainprep and, for `cat12vbm-12.8.2`, CAT12:
```bibtex
@article{wald2025openmind,
title = {An OpenMind for 3D medical vision self-supervised learning},
author = {Wald, Tassilo and others},
journal = {arXiv preprint arXiv:2412.17041},
year = {2025}
}
@misc{brainprep,
title = {{BrainPrep source code}},
author = {Grigis, Antoine and Victor, Julie and Dorval, Loic and Duchesnay, Edouard},
url = {https://github.com/brainprepdesk/brainprep}
}
@article{gaser2024cat,
title = {{CAT}: a computational anatomy toolbox for the analysis of structural {MRI} data},
author = {Gaser, Christian and Dahnke, Robert and Thompson, Paul M. and Kurth, Florian
and Luders, Eileen and {the Alzheimer's Disease Neuroimaging Initiative}},
journal = {GigaScience},
volume = {13},
year = {2024}
}
```
## Contact
Benoit Dufumier, NeuroSpin (CEA, Université Paris-Saclay).