Skip to content

Towards the development of robust models for clinical dementia rating classification with improved interpretability

License

Notifications You must be signed in to change notification settings

binfnstats/CDR-Classification

Repository files navigation

CDR Classification from MRI, Age, and Sex

This is a project to classify five levels of clinical dementia rating using MRI, age, and sex of the subject. The project uses CNN based model, developed using Tensorflow, to predict CDR. The trained model can also be used in transfer learning.

Installation

Option 1: by running commands

  1. Create a new conda or docker environment with python 3.7.
  2. Activate the environment.
  3. Run the commands listed in requirements.txt.
  4. Install niftyreg.
  5. Download the standard ICBM 2009c Nonlinear Symmetric MNI space available here.

Option 2: by building identical conda environment

Run the command

conda create --name myenv --file spec-file.txt

Getting data

Download the required data from the folder /project/RDS-SMS-FFgenomics-RW/raquib/cdr/ of Uni Artemis to the local data folder.

Training your own model

To start the training, run the command

python train.py LOGDIR

Be sure to replace LOGDIR with the path of your log directory where tensorboard history and model will be saved.

Use our trained model to predict CDR

  1. Register your mri image into standard MNI space ICBM 2009c Nonlinear Symmetric MNI space.
    reg_aladin -flo PATH_TO_YOUR_MRI -ref PATH_TO_MNI_FILE -res OUTPUT_MRI_PATH
    
    Be sure to replace PATH_TO_YOUR_MRI with the path to your MRI file, PATH_TO_MNI_FILE path to the MNI file you downloaded, and OUTPUT_MRI_PATH location where the registered MRI should be saved.
  2. Download the model from 10.6084/m9.figshare.12954521.
  3. To classify the MRI, follow one of the following two options.

Option 1: Use command line

To predict CDR from MRI, age, and sex, run the command:

python predict.py MODEL_PATH IMAGE_PATH AGE SEX

Be sure to replace, MODEL_PATH with the path of the model (.h5 file) you just downloaded, IMAGE_PATH with the registered .nii or .nii.gz (MRI) file, AGE with subject's age in years and SEX with 0 or 1. Here, 0 indicates male while 1 indicates female. The output will be subject's CDR in the form of one of five numbers: 0, 0.5, 1, 2, or 3.

Note that loading a model requires a few seconds. However the actual time to predict is usually less than a second when a GPU is used.

Option 2: Use python

  1. Copy the encoder.py file in your project which can transform between one hot encoded CDR to normal CDR scale.
  2. Copy the code in predict.py and paste it in your code.
  3. Make sure to use registered MRI file for executing the copied code.

Get Grad-CAM visualization

The following command does two things. (a) Predict CDR from MRI, age, and sex. (b) Generates and saves the gradcam heatmap.

python gradcam.py MODEL_PATH IMAGE_PATH AGE SEX CDR OUTPUT_PATH

Be sure to replace, MODEL_PATH with the path of the model (.h5 file) you just downloaded, IMAGE_PATH with the .nii or .nii.gz (MRI) file, AGE with subject's age in years, SEX with 0 (male) or 1 (female), CDR with class label to generate Grad-CAM for, OUTPUT_PATH with the directory where the generated three dimensional heatmap should be saved. The command will also output the subject's CDR in the form of one of five numbers: 0, 0.5, 1, 2, or 3. For CDR argument, you can use -1 to produce Grad-CAM for the predicted class.

License

License: MIT

About

Towards the development of robust models for clinical dementia rating classification with improved interpretability

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages