Home

Awesome

Learning Diffeomorphism for Image Registration with Time-Continuous Networks using Semigroup Regularization

This is the official repository of the SGDIR paper submitted to IEEE Transactions on Medical Imaging.

Installing the dependencies

This package is written in Python 3.10. To install the dependencies, run the following command

pip install -r requirements.txt

Datasets

You must specify the path to the dataset inside the config file associated to each dataset.

NOTE In writing the dataloader for the OASIS dataset we have assumed the data folder structure is as follows:

πŸ“¦OASIS
┣ πŸ“‚OASIS_OAS1_0001_MR1
┃ ┣ πŸ“œaligned_norm.nii.gz
┃ β”— πŸ“œaligned_seg35.nii.gz
┣ πŸ“‚OASIS_OAS1_0002_MR1
┣ πŸ“‚OASIS_OAS1_0003_MR1
┣ πŸ“‚OASIS_OAS1_0004_MR1
┃ .
┃ .
┃ .
β”— πŸ“‚OASIS_OAS1_0457_MR1

Where each subject has the aligned_norm.nii.gz (for the MNI 152 1mm normalized image) and aligned_seg35.nii.gz (for the segmentation mask with 35 structures). If your file structure or file names are different, you might need to modify the load_image_pair method of OASISRegistrationV2 dataloader in data.py.

NOTE In writing the dataloader for the CANDI dataset we have assumed the data folder structure is as follows:

πŸ“¦CANDI
┣ πŸ“‚SchizBull_2008
┃ ┣ πŸ“‚BPDwithPsy
┃ ┃ ┣ πŸ“‚BPDwPsy_065
┃ ┃ ┃ ┣ πŸ“‚MNI152_2mm_Linear
┃ ┃ ┃ ┃ ┣ πŸ“œBPDwPsy_065_affine_transf.mat
┃ ┃ ┃ ┃ ┣ πŸ“œBPDwPsy_065_linear_MRI.nii.gz
┃ ┃ ┃ β”— β”— πŸ“œBPDwPsy_065_linear_SEG.nii.gz
┃ ┃ ┣ πŸ“‚BPDwPsy_066
┃ ┃ .
┃ ┃ .
┃ ┃ .
┃ ┣ πŸ“‚BPDwithoutPsy
┃ ┃ ┣ πŸ“‚BPDwoPsy_030
┃ ┃ ┃ ┣ πŸ“‚MNI152_2mm_Linear
┃ ┃ ┃ ┃ ┣ πŸ“œBPDwoPsy_030_affine_transf.mat
┃ ┃ ┃ ┃ ┣ πŸ“œBPDwoPsy_030_linear_MRI.nii.gz
┃ ┃ ┃ β”— β”— πŸ“œBPDwoPsy_030_linear_SEG.nii.gz
┃ ┃ ┣ πŸ“‚BPDwoPsy_031
┃ ┃ .
┃ ┃ .
┃ ┃ .
┃ ┣ πŸ“‚HC
┃ ┃ ┣ πŸ“‚HC_001
┃ ┃ ┃ ┣ πŸ“‚MNI152_2mm_Linear
┃ ┃ ┃ ┃ ┣ πŸ“œHC_001_affine_transf.mat
┃ ┃ ┃ ┃ ┣ πŸ“œHC_001_linear_MRI.nii.gz
┃ ┃ ┃ β”— β”— πŸ“œHC_001_linear_SEG.nii.gz
┃ ┃ ┣ πŸ“‚HC_002
┃ ┃ .
┃ ┃ .
┃ ┃ .
┃ β”— πŸ“‚SS
┃ ┃ ┣ πŸ“‚SS_084
┃ ┃ ┃ ┣ πŸ“‚MNI152_2mm_Linear
┃ ┃ ┃ ┃ ┣ πŸ“œSS_084_affine_transf.mat
┃ ┃ ┃ ┃ ┣ πŸ“œSS_084_linear_MRI.nii.gz
┃ ┃ ┃ β”— β”— πŸ“œSS_084_linear_SEG.nii.gz
┃ ┃ ┣ πŸ“‚SS_085
┃ ┃ .
┃ ┃ .
┃ ┃ .

If your file structure or file names are different, you might need to modify the load_image_pair method of CANDIRegistrationV2 dataloader in data.py.

NOTE In writing the dataloader for the LPBA40 dataset we have assumed the data folder structure is as follows:

πŸ“¦LPBA40
┣ πŸ“‚Delineation
┃ ┣ πŸ“‚S01
┃ ┃ ┣ πŸ“œS01.delineation.skullstripped.img
┃ ┃ ┣ πŸ“œS01.delineation.skullstripped.hdr
┃ ┃ ┣ πŸ“œS01.delineation.structure.label.img
┃ ┃ β”— πŸ“œS01.delineation.structure.label.hdr
┃ ┣ πŸ“‚S02
┃ ┃ .
┃ ┃ .
┃ ┃ .
β”— β”— πŸ“‚S40

If your file structure or file names are different, you might need to modify the load_image_pair method of LPBA40Registration dataloader in data.py.

The training, validation, and test pair ids are stored in

πŸ“¦tmp
┣ πŸ“œcandi_train_val_test.json
┣ πŸ“œlpba_train_val_test.json
β”— πŸ“œoasis_train_val_test.json

If such files do not exist already, the dataloaders inside the data.py will automatically create one. Otherwise, the already existing files are used to retrieve the training, validation, and test pairs.

For the showcase, the file consisting of a single same pair for training, validation, and test pair is included. Feel free to remove the file, and run the program to generate the pairs for the entire dataset, or manually change the file to include the pairs of your choice.

Training

python train.py -c oasis | candi | lpba

NOTE Running train or eval file wihtout the option -c sets the OASIS dataset as the default.

NOTE You can change some training/validation configurations and model architecture inside the OASIS config file, CANDI config file, and LPBA40 config file

Evaluation

python eval.py -c oasis | candi | lpba