Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

SaberPRC/BrainParc

Repository files navigation

BrainParc: Unified Lifespan Brain Region Parcellation

Official implementation of Unified Lifespan Brain Region Parcellation from Structural MR Images (BrainParc)


"BrainParc: Unified Lifespan Brain Parcellation with Anatomy-guided Progressive Transmission", ISMRM, 2025, [Jiameng Liu, Feihong Liu, Kaicong Sun, Caiwen Jiang, Yulin Wang, Tianyang Sun, Feng Shi and Dinggang Shen]

"BrainParc: Unified Lifespan Brain Parcellation from Structural MR Images", Nature Computational Science, 2026, [Jiameng Liu, Feihong Liu, Kaicong Sun, Zhiming Cui, Tianyang Sun, Zehong Cao, Jiawei Huang, Shuwei Bai, Yulin Wang, Yulong Dou, Kaicheng Zhang, Caiwen Jiang, Yuyan Ge, Han Zhang, Feng Shi and Dinggang Shen]



🧠 Main Framework

The entire BrainParc framework includes two parts:

  1. Brain extraction: Prerequisit for following brain tissue segmentation and region parcellation. We designed and trained an Automatic skull-strip (AutoStrip) method for lifespan T1w MRI data.

    • You can find the detailed implementation and pretrained model of AutoStrip can in this Repo. This repo mainly introduce the implementation details of the tissue segmentation and region parcellation part of BrainParc.
  2. Tissue segmentation and region parcellation: Unified Lifespan Brain Region Parcellation (BrainParc) framework which leverage the anatomical information invariant to intensity and contrast, enabling accurate, robust, and longitudinally consistent parcellation across heterogeneous dataset without the need for fine-tuning.


πŸ”₯ Updates


🚧 To-Do List

  • [] Update multi-model version
  • Release training code
  • Release pretrained model
  • Release inference script

πŸ—οΈ Implementation and Model Training

Step 1: Data Preparation Organize your project directory as follows to reproduce BrainParc on your own data

Experiments/
β”œβ”€β”€ csvfile/ # Training, validation, & testing splits
β”‚ └── file_list.csv # Each line: [IDs, folder, fold]
β”œβ”€β”€ data/ # Data folder
β”‚ β”œβ”€β”€ HCPA/
β”‚ β”‚ └── sub001/
β”‚ β”‚ β”œβ”€β”€ brain.nii.gz # skull-stripped T1w data
β”‚ β”‚ β”œβ”€β”€ tissue.nii.gz # ground-truth tissue maps
β”‚ β”‚ └── dk-struct.nii.gz # ground-truth dk struture maps
β”‚ β”œβ”€β”€ HCPD/
β”‚ └── HCPY/
└── Results/
 └── BrainParc/
 β”œβ”€β”€ checkpoints/ # Saved every 10 epochs
 β”œβ”€β”€ log/
 β”‚ └── log
 └── pred/ # Validation results per epoch

Note: The relative training, testing, and validation split should be recorded in file_list.csv. The example for file_list.csv is shown below:

IDs folder fold
sub001HCPY1
sub002HCPY2
sub003HCPY3
sub001HCPD1
sub002HCPD2
sub003HCPD3
sub004HCPD3
sub001HCPA3
where folder denote for different datasets and fold used for the training (fold=3), testing (fold=1), and validation (fold=2) split.

Step 2: Data Prepocessing

You are required performing the following steps for training BrainParc using your own data:

  • Brain Extraction: Please first remove brain skull using our AutoStrip.

  • Edge Extraction: Extracte the brain edge maps using sobel filter, you can refer to this script for extract brain sobel edge maps.

    python ./Code/Inference/Step01_Intensity_2_Edge.py --input /path/to/input/brain.nii.gz --output /path/to/save/extracted/edge/maps

After the data preprocess, your data directory should be:

Experiments/
β”œβ”€β”€ csvfile/ # Training, validation, & testing splits
β”‚ └── file_list.csv # Each line: [IDs, folder, fold]
β”œβ”€β”€ data/ # Data folder
β”‚ β”œβ”€β”€ HCPA/
β”‚ β”‚ └── sub001/
β”‚ β”‚ β”œβ”€β”€ brain.nii.gz # skull-stripped T1w data
β”‚ β”‚ β”œβ”€β”€ brain_edge.nii.gz # extracted brain edge maps
β”‚ β”‚ β”œβ”€β”€ tissue.nii.gz # ground-truth tissue maps
β”‚ β”‚ └── dk-struct.nii.gz # ground-truth dk struture maps
β”‚ β”œβ”€β”€ HCPD/
β”‚ └── HCPY/
└── Results/
 └── BrainParc/
 β”œβ”€β”€ checkpoints/ # Saved every 10 epochs
 β”œβ”€β”€ log/
 β”‚ └── log
 └── pred/ # Validation results per epoch

Step 3: Model Training (BrainParc)

  • Please find the implementation of BrainParc in ./Code folder with following format

    Code
    β”œβ”€β”€ config
    β”‚  β”œβ”€β”€ __init__.py
    β”‚  └── config.py # Configuration for model training
    β”œβ”€β”€ dataset
    β”‚  β”œβ”€β”€ __init__.py
    β”‚  β”œβ”€β”€ basic.py # Basic function for data loading
    β”‚  └── dataset.py # Data loader
    β”œβ”€β”€ network
    β”‚  β”œβ”€β”€ __init__.py
    β”‚  β”œβ”€β”€ basic.py # Basic function for model construction
    β”‚  └── Joint_Parc_96.py # Main framework for progressive segmentation model
    β”œβ”€β”€ trainSegNetMS_Joint_DDP.py # Training script using DDP
    └── utils
     β”œβ”€β”€ __init__.py
     β”œβ”€β”€ loss.py # Volume-aware adaptive weight loss function
     └── utils.py
  • Training scripts

    python -m torch.distributed.run --nproc_per_node=2 --nnodes=1 --master_port 10086 ./Code/trainSegNetMS_Joint_DDP.py --platform bme --save_path ParcJoint --file_list file_list.csv --batch_size 2 --resume -1 --weight 1

Inference Using Pretrained Model

We provided three infant and two child/adult samples in Test_Sample. You can also test BrainParc on your own data structured as:

Test_Sample/
β”œβ”€β”€ sub001_infant_infantile/
β”‚ └── brain.nii.gz
β”œβ”€β”€ sub002_infant_isointense/
β”‚ └── brain.nii.gz
β”œβ”€β”€ sub003_infant_adult_like/
β”‚ └── brain.nii.gz
β”œβ”€β”€ sub004_child/
β”‚ └── brain.nii.gz
└── sub005_adult/
 └── brain.nii.gz
  1. Skull-striping
  • Please first conduct skull-stripping on your own data using our AutoStrip
  1. Brain edge extraction
    python ./Code/Inference/Step01_Intensity_2_Edge.py --input ./Test_Samples/sub001_infant_infantile/brain.nii.gz --output ./Test_Samples/sub001_infant_infantile/brain_edge.nii.gz
    Run likewise for other data samples with appropriate --input and --output parameters. The processed data should include the following files:

brain.nii.gz, brain_edge.nii.gz

  1. Tissue segmentation and region parcellation
    python ./Code/Inference/Step02_BrainParc.py --input_brain ./Test_Samples/sub001_infant_infantile/brain.nii.gz --input_edge ./Test_Samples/sub001_infant_infantile/brain_edge.nii.gz --output_tissue ./Test_Samples/sub001_infant_infantile/tissue.nii.gz --output_dk ./Test_Samples/sub001_infant_infantile/dk-struct.nii.gz --norm_orientation 1 --norm_spacing 1 --standard_space [0.8, 0.8, 0.8]
    • --model_path: pretrained model path
    • --input_brain: path to brain.nii.gz
    • --input_edge: path to brain_edge.nii.gz
    • --output_tissue: path to tissue.nii.gz
    • --output_dk: path to dk-struct.nii.gz
    • --norm_orientation: whether normalize image orientation to RPI, default=1
    • --norm_spacing: whether normalize image spacing to standard_spacing, default=1

Pretrained model

You can download our pretrained model through the following link:

ROI Index of BrainParc and Corresponding ROI Index of FreeSurfer

  • We segment MRI brain according to dk structrue atlas, each label in our BrainParc are shown below:

A detailed label correspondence of our dk-struct and tissue maps can be find at Label_cor.xlsx This mapping is also used during training to maintain structural consistency between the tissue maps and dk-struct labels.

πŸ“ž Contact and License

License

Copyright IDEA Lab, School of Biomedical Engineering, ShanghaiTech University, Shanghai, China.

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

If you have any questions or suggestions, please feel free to contact the corresponding author:

πŸ“§ Jiameng Liu: JiamengLiu.PRC@gmail.com

About

Repo for Lifespan Brain Region Parcellation

Resources

License

Stars

Watchers

Forks

Packages

Contributors

Languages

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /