OpenMAP-BrainAge predicts brain age from:
- a skull-stripped, rigidly aligned T1 MRI
- a 280-region parcellation volume CSV from OpenMAP-T1
The model follows the design in OpenMAP-BrainAge: Generalizable and Interpretable Brain Age Predictor. Part of the implementation also builds on Heterogeneous Pre-trained Transformers.
The OpenMAP-BrainAge is a publication of The Johns Hopkins University and copyright © 2026 The Johns Hopkins University. All rights reserved.
If you have a folder of raw T1 MRI scans and want final age predictions with the least manual setup, use the full pipeline:
python run_full_pipeline.py \
--input_dir /path/to/raw_mri_folder \
--output_dir /path/to/output_folder \
--openmap_t1_model_dir /path/to/openmap_t1_models \
--mni_path ./data_processing/MNI_template/MNI_FULL.nii \
--age_model_checkpoint ./saved_ckpt/trained_model_multiview/checkpoint0199.pthThis one command will:
- skull-strip the scans
- rigidly register them to MNI space
- generate the 280-region parcellation volume CSV
- build the metadata CSV required by the age model
- output final brain-age predictions
For more detail, see FULL_PIPELINE_README.md.
We recommend using Anaconda or Miniconda.
Clone the repository first:
git clone https://github.com/OishiLab/OpenMAP-BrainAge.git
cd OpenMAP-BrainAgeFrom the repository root:
conda env create -f environment.yml
conda activate openmap-brainageThe provided environment.yml contains the Python and package setup used by this project.
The current version has been tested on Linux and is expected to run properly there.
It has not yet been tested on macOS or Windows.
For raw MRI input, we recommend using a folder layout similar to OpenMAP-T1 v2.0.0:
INPUT_FOLDER/
├ subject_001.nii
├ subject_002.nii
├ subject_003.nii.gz
└ ...
The full pipeline will scan the input directory recursively for .nii and .nii.gz files.
After running the full pipeline, your output folder will look like:
OUTPUT_FOLDER/
01_skull_removed/
subject_001.nii
subject_002.nii
...
02_parcellation/
subject_001/
subject_001_280.nii
subject_001_volume.csv
subject_002/
subject_002_280.nii
subject_002_volume.csv
...
03_metadata/
full_pipeline_demo_data.csv
04_predictions/
age_predictions.csv
To make the repository easier to use, we recommend the following local folder structure for external assets:
OpenMAP-BrainAge/
data_processing/
MNI_template/
MNI_FULL.nii
saved_ckpt/
openmap_t1/
CNet/
CNet.pth
SSNet/
SSNet.pth
PNet/
coronal.pth
sagittal.pth
axial.pth
HNet/
coronal.pth
axial.pth
trained_model_multiview/
checkpoint0199.pth
We recommend placing the provided MNI template at:
./data_processing/MNI_template/MNI_FULL.nii
Then you can pass it to the full pipeline with:
--mni_path ./data_processing/MNI_template/MNI_FULL.niiWe recommend placing the trained OpenMAP-BrainAge checkpoints under:
./saved_ckpt/trained_model_multiview/
For example:
saved_ckpt/
trained_model_multiview/
checkpoint0199.pth
This matches the checkpoint path used in Inference.ipynb:
./saved_ckpt/trained_model_multiview/checkpoint0199.pth
To obtain the trained OpenMAP-BrainAge age-predictor checkpoint for inference, please submit the model-weight request form: Microsoft Forms.
We also recommend placing the OpenMAP-T1 preprocessing checkpoints under:
./saved_ckpt/openmap_t1/
Expected structure:
./saved_ckpt/openmap_t1/
CNet/
CNet.pth
SSNet/
SSNet.pth
PNet/
coronal.pth
sagittal.pth
axial.pth
HNet/
coronal.pth
axial.pth
These checkpoints are used by the preprocessing scripts in data_processing/ and by the full pipeline through:
--openmap_t1_model_dir ./saved_ckpt/openmap_t1The most important files and folders are:
OpenMAP-BrainAge/
README.md
environment.yml
run_full_pipeline.py
FULL_PIPELINE_README.md
Inference.ipynb
train_ADNI_multiview.py
train_ADNI_multiview.sh
dataADNI_multiview.py
modelADNI.py
data/
demo_data.csv
data_processing/
README.md
skull_removal.py
parcellation_from_skull_removed_img.py
utils/
level/
hpt/
hpt_pretrained_model/
-
run_full_pipeline.pyMain end-to-end script from raw MRI folder to final age prediction. -
data_processing/Preprocessing code for skull stripping, rigid registration, and 280-region parcellation. -
Inference.ipynbExample inference workflow when you already have skull-stripped MRI and parcellation volume CSV files. -
train_ADNI_multiview.pyandtrain_ADNI_multiview.shTraining code for users who want to train their own OpenMAP-BrainAge model. -
data/demo_data.csvExample metadata CSV showing the required input format for inference and training.
Use:
run_full_pipeline.py
This is the recommended path for most clinical users.
Use:
data_processing/skull_removal.pydata_processing/parcellation_from_skull_removed_img.py
This is useful if you want skull-stripped images and regional volume CSV files but do not want to run age prediction yet.
For details, see:
data_processing/README.md
Use:
Inference.ipynb
This is the best route if your preprocessing has already been done.
Use:
train_ADNI_multiview.pytrain_ADNI_multiview.sh
The full pipeline expects:
- raw T1 MRI scans in
.niior.nii.gz - OpenMAP-T1 preprocessing checkpoints
- an MNI template
- a trained OpenMAP-BrainAge checkpoint
The output directory will contain:
<OUTPUT_DIR>/
01_skull_removed/
02_parcellation/
03_metadata/
full_pipeline_demo_data.csv
04_predictions/
age_predictions.csv
The generated CSV in 03_metadata/full_pipeline_demo_data.csv follows the same format as data/demo_data.csv.
A typical command using the recommended repo-local asset layout is:
python run_full_pipeline.py \
--input_dir ./INPUT_FOLDER \
--output_dir ./OUTPUT_FOLDER \
--openmap_t1_model_dir /path/to/openmap_t1_models \
--mni_path ./data_processing/MNI_template/MNI_FULL.nii \
--age_model_checkpoint ./saved_ckpt/trained_model_multiview/checkpoint0199.pthYou do not need to run the preprocessing scripts again if you already have:
- skull-stripped, rigidly aligned MRI scans
- 280-region parcellation volume CSV files
In that case, follow the example in Inference.ipynb.
The notebook shows how to:
- load the pretrained HPT backbone
- build the OpenMAP-BrainAge model
- load a trained age-prediction checkpoint
- read a metadata CSV
- output the predicted brain age
The expected CSV format is:
path_full,age,path_rigid_parcellation_volume
/path/to/subject001.nii,,/path/to/subject001_volume.csvNotes:
path_fullshould point to the skull-stripped, rigidly aligned MRI imagepath_rigid_parcellation_volumeshould point to the 280-region volume CSV- for inference-only use, the
agecolumn can be left blank
See also:
data/demo_data.csv
If you want to build a new brain-age model on your own cohort, the typical workflow is:
- preprocess your MRI scans
- generate the parcellation volume CSV for each case
- prepare a metadata CSV in the same style as
data/demo_data.csv - train using
train_ADNI_multiview.py
The default training launcher is:
bash train_ADNI_multiview.shYou will usually need to update:
- training and validation CSV paths
- checkpoint paths
- output path
- hyperparameters for your experiment
Important training files:
train_ADNI_multiview.shtrain_ADNI_multiview.pydataADNI_multiview.pymodelADNI.py
The training output checkpoint is typically written under:
./trained_model_multiview/
Depending on your workflow, you may need:
- OpenMAP-T1 preprocessing model files for
data_processing/ - pretrained HPT trunk files for training
- pretrained 3D ResNet18 files for training
- a trained OpenMAP-BrainAge checkpoint for inference
For the trained OpenMAP-BrainAge age-predictor checkpoint used in inference, please submit the model-weight request form: Microsoft Forms.
Please contact the project authors if access to any other required pretrained checkpoints is not already available to you.
-
FULL_PIPELINE_README.mdMore detail on the raw-MRI-to-age-prediction pipeline -
data_processing/README.mdMore detail on the preprocessing folder and scripts -
Inference.ipynbExample notebook for direct inference on prepared inputs
