BrainMets AI is the result of a collaboration between the Netherlands Cancer Institute (NKI) and Robovision Healthcare. This repository gives further insights in how the underlying AI model was trained and the evaluation was performed. For more details we would like to refer to the article "Topff L, Petrychenko L, Jain N, et al. A Data-Centric Approach to Deep Learning for Brain Metastasis Analysis at MRI. Radiology. 2025;315(3):e242416. doi: 10.1148/radiol.242416."
You can try out the BrainMets AI model on our Test Page, for research purposes only, not for clinical use.
The BrainMets AI pipeline is built upon a modified nnU-Net framework to detect and segment brain metastases of all sizes on contrast-enhanced 3D T1-weighted MRI. The repository provides:
- Preprocessing: DICOM to Nifti conversion, brain extraction and some basic checks.
- Training: Five-fold cross-validation on the preprocessed dataset.
- Inference: Use the trained model to generate predictions on another dataset.
- Postprocessing: Generate probability maps, thresholding, connected‐component analysis and lesion confidence scoring.
- Evaluation: Scripts to compute lesion‐wise sensitivity, Dice Similarity Coefficient (DSC), Normalized Surface Distance (NSD), and Free-response Receiver Operating Characteristic (FROC) curves.
- Operating System: Ubuntu 20.04+
- Python: 3.11
- CUDA: 11.8
- Disk Space: ≥ 100 GB (depending on dataset size)
- RAM: ≥ 32 GB
- GPU: ~ NVIDIA A100 80 GB
Make sure to first create a virtual environment and install the correct Pytorch version. Then, all other required Python dependencies can be installed using the requirements.txt file.
- Create a virtual environment
python -m venv venv
source venv/bin/activate- Install Pytorch
pip install torch==2.6.0 --index-url https://download.pytorch.org/whl/cu118- Install other dependencies
pip install -r requirements.txt- Verify installation
python -c "import torch, nnunetv2, HD_BET; print('OK')"Place all input MRIs (in DICOM format) under a DATA_DIR in the expected directory structure:
DATA_DIR/
scan_001/
dicom_file_001.dcm
...
scan_002/
dicom_file_001.dcm
...
...Each scan folder must contain all the DICOM files of only a single DICOM series.
python preprocessing/preprocessing.py --data-dir DATA_DIR --preprocessing-dir PREPROCESSING_DIRThis will generate:
PREPROCESSING_DIR/
scan_001/
brain_masked_mri.nii.gz
scan_002/
brain_masked_mri.nii.gz
...Using the preprocessed data files, you can use any labeling platform that accepts Nifti files to generate binary segmentation masks. When you created these masks, put them in the PREPROCESSING_DIR:
PREPROCESSING_DIR/
scan_001/
brain_masked_mri.nii.gz
annotation.nii.gz
scan_002/
brain_masked_mri.nii.gz
annotation.nii.gz
...python training/training.py --preprocessing-dir PREPROCESSING_DIR --training-dir TRAINING_DIRThis will check if the data is consistent across the PREPROCESSING_DIR. If all goes well, the TRAINING_DIR will be populated and the training starts.
TRAINING_DIR/
nnUNet_raw/
Dataset001_BrainMetastasisAI/
imagesTr/
scan_001_0000.nii.gz
scan_002_0000.nii.gz
...
labelsTr/
scan_001.nii.gz
scan_002.nii.gz
...
nnUNet_preprocessed/
Dataset001_BrainMetastasisAI/
...
nnUNet_results/
Dataset001_BrainMetastasisAI/
...Once there is a trained model available in the TRAINING_DIR, you can also do inference for any PREPROCESSING_DIR and have the result outputted in the INFERENCE_DIR:
python inference/inference.py --preprocessing-dir PREPROCESSING_DIR --training-dir TRAINING_DIR --inference_dir INFERENCE_DIRThe INFERENCE_DIR will look like this:
INFERENCE_DIR/
scan_001/
brain_masked_mri.nii.gz (symlink)
annotation.nii.gz (symlink - optional)
prediction.nii.gz
scan_002/
brain_masked_mri.nii.gz (symlink)
annotation.nii.gz (symlink - optional)
prediction.nii.gz
...To postprocess an INFERENCE_DIR, make sure you started from a PREPROCESSING_DIR where you added ground truth annotations:
python postprocessing/postprocessing.py --inference_dir INFERENCE_DIRThis will inject some result.csv files into the INFERENCE_DIR.
INFERENCE_DIR/
scan_001/
brain_masked_mri.nii.gz (symlink)
annotation.nii.gz (symlink)
prediction.nii.gz
result.csv
scan_002/
brain_masked_mri.nii.gz (symlink)
annotation.nii.gz (symlink)
prediction.nii.gz
result.csv
...To run the evaluation, do:
python evaluation/evaluation.py --inference-dir INFERENCE_DIR --evaluation-dir EVALUATION_DIRThis will generate the tables and figures like in the paper:
EVALUATION_DIR/
figure_1.png
table_1.csv
...When making use of BrainMets AI, please also acknowledge this by referencing to or citing our work:
Topff L, Petrychenko L, Jain N, et al. A Data-Centric Approach to Deep Learning for Brain Metastasis Analysis at MRI. Radiology. 2025;315(3):e242416. doi: 10.1148/radiol.242416.
@article{topff2025datacentric-ef3,
year = {2025},
title = {A Data-Centric Approach to Deep Learning for Brain Metastasis Analysis at {MRI}},
author = {Topff, Laurens and Petrychenko, Liliana and Jain, Neeraj and Lingier, Sara and Bertels, Jeroen and Astudillo, Patricio and Prosec, Milan and Menéndez Fernández-Miranda, Pablo and Gevaert, Olivier and Smits, Marion and Derks, Sophie and Verhaak, Eline and Hanssens, Patrick E J and Marco de Lucas, Enrique and Sutil, Rodrigo and Dominguez, Pablo D and Negoita, Adina and Visser, Ernst and Corral Fontecha, David and Braun, Loes M M and Brandsma, Dieta and Visser, Jacob J and Ranschaert, Erik R and Groot Lipman, Kevin B W and Beets-Tan, Regina G H},
journal = {Radiology},
issn = {0033-8419},
doi = {10.1148/radiol.242416},
pmid = {40552999},
pages = {e242416},
number = {3},
volume = {315}
}For questions, bug reports, or feature requests, please open an issue on GitHub or contact:
Laurens Topff, MD, PhD (Corresponding author) — l.topff@nki.nl
Thank you for using our BrainMets AI!

