Repository containing code, models and tutorials for the paper Deep neural networks learn general and clinically relevant representations of the ageing brain
- Clone the github repo
git clone git@github.com:estenhl/pyment-public.git
- Enter the folder
cd pyment-public
- Create a conda environment
conda create --name pyment python=3.9
- Activate environment
conda activate pyment
- Install required packages
pip install -r requirements.txt
- Install Tensorflow
a. Tensorflow for GPU
pip install tensorflow-gpu
b. Tensorflow for CPU
pip install tensorflow
- Source the package
conda develop .
While the models adhere to the Keras Model interface and can thus be used however one wants, we have provided Dataset/Generator-classes for nifti-files which are used in the tutorials. For these classes to work off-the-shelf the Nifti-data has to be organized in the following folder structure:
.
├── labels.csv
└── images
├── image1.nii.gz
├── image2.nii.gz
...
└── imageN.nii.gz
where labels.csv
is a csv-file with column id
(corresponding to image1, image2, etc) and column age
.
Before training the models all images were ran through the following preprocessing pipeline:
- Extract brainmask with
recon-all -autorecon1
(FreeSurfer) - Transform to *.nii.gz with
mri_convert
(FreeSurfer) - Translate to FSL space with
fslreorient2std
(FSL) - Register to MNI space with
flirt -dof 6
(FSL, linear registration), and the standard FSL templateMNI152_T1_1mm_brain.nii.gz
- Crop away borders of
[6:173,2:214,0:160]
A full example which downloads the IXI dataset and preprocesses it can be found in the Preprocessing tutorial
Estimating brain age using the trained brain age model from the paper consists of downloading the weights, instantiating the model with said weights, and calling Model.fit() with an appropriate generator. A full tutorial (which relies on having a prepared dataset) can be found in the Python prediction tutorial
Instructions for downloading, building and using our docker containers for brain age predictions can be found in the docker-folder