Skip to content

Early detection of Alzheimer’s Disease using 3D CNNs on structural MRIs, leveraging the ADNI dataset, Clinica preprocessing, and MeluXina HPC for high-performance training and Grad-CAM interpretability. 🧠

Notifications You must be signed in to change notification settings

justvicthor/Early_Alzheimer_Detection_DL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

58 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Early Alzheimer’s Disease Detection from Structural MRIs Using Deep Learning

🧠 Overview

GIF via GradCam

This project explores the use of 3D Convolutional Neural Networks (3D CNNs) for early detection of Alzheimer’s Disease (AD) using structural magnetic resonance imaging (sMRI). Inspired by and building upon the work of Liu et al. (2022), we aim to not only replicate but enhance their deep learning architecture using high-performance computing (HPC) resources, particularly the MeluXina Supercomputer.

The model classifies subjects into three categories:

  • Cognitively Normal (CN)
  • Mild Cognitive Impairment (MCI)
  • Mild AD Dementia (AD)

Our work highlights the value of deep learning in automating and improving the diagnostic process for Alzheimer’s Disease, enabling scalable and efficient MRI-based screening.


βœ… Contributions

  • Re-implemented and validated Liu et al.’s 3D CNN model on the ADNI dataset
  • Used the Clinica software suite for standardized MRI preprocessing in BIDS format
  • Integrated data augmentation techniques (Gaussian blurring, random cropping)
  • Leveraged MeluXina HPC for full-scale GPU-based training and evaluation
  • Achieved promising classification results with improved performance on the original paper

πŸ—οΈ Model Architecture

Model Architecture Placeholder

Note: Figure shows a placeholder representation of the deep learning architecture.

The model architecture consists of:

  • Multiple 3D convolutional blocks with normalization steps and ReLU activations
  • Fully connected layers for classification
  • Cross-entropy loss optimized with Adam

πŸ“¦ Data Pipeline

Dataset: ADNI

session_id participant_id sex original_study diagnosis ...
ses-M006 sub-ADNI052S0671 F ADNI1 LMCI ...
ses-M000 sub-ADNI109S0967 M ADNI1 CN ...
ses-M000 sub-ADNI027S0850 M ADNI1 AD ...

βš™οΈ Preprocessing

To collect the MRI scans and utilize them correctly to train the model please refer to INSTALL.md

MRI scans were processed using the Clinica software suite:

  1. Convert to BIDS format
  2. Generate a template from the training set
  3. Apply spatial normalization using the template
  4. Apply intensity normalization to reduce scanner bias

This pipeline ensures data consistency across training, validation, and testing sets.


πŸ” Data Augmentation

To improve generalization and model robustness, we applied:

  • Gaussian Blurring
  • Random Cropping

Augmentation is performed on-the-fly during training.


πŸ’» Infrastructure: MeluXina Supercomputer

We worked on the GPU-enabled MeluXina system provided by EuroHPC.

SSH Access

# ~/.ssh/config
Host meluxina
  Hostname login.lxp.lu
  User <user_id>
  Port 8822
  IdentityFile ~/.ssh/id_ed25519_mel
  IdentitiesOnly yes
  ForwardAgent no

To connect simply type on the command line

ssh meluxina

πŸš€ Benefits of MeluXina

  • Large amount of GPU hours available

  • Support for large batch sizes

  • GPU parallelization capabilities

  • Extended memory for ~1TB datasets


πŸ§ͺ Neural Network Training

  • Loss Function: Cross-Entropy
  • Optimizer: Adam
  • Normalization: InstanceNorm / BatchNorm

Most of the model parameters can be tuned by modifying the config.yaml file.


πŸ“ˆ Results

NOTE: Placeholder section. Insert metrics when available.

Expected outcomes based on Liu et al.:

  • AUC > 89.21% for AD classification
  • Improved performance over ROI-volume/thickness-based models
  • Demonstrated progression prediction capabilities

πŸ–ΌοΈ Visualizations

We implemented Grad-CAM to interpret model decisions and highlight the most discriminative brain regions contributing to each prediction (CN / MCI / AD). The visualization pipeline generates GIF overlays for axial, coronal, and sagittal slices, color-coded by predicted diagnosis:

  • 🟩 Green = CN
  • 🟨 Yellow = MCI
  • πŸŸ₯ Red = AD

Additionally, an optional hippocampal crop (based on the AAL atlas) is used to focus on clinically relevant areas, automatically handled via nilearn.

To define which part of the Grad-CAM heatmap is considered "active", the script supports multiple thresholding strategies, selectable via --threshold_mode:

  • pct: retains the top-N% activations (configurable via --pct, e.g., --pct 60 for 60%)
  • otsu: uses Otsu’s adaptive method
  • std: keeps voxels with activation > mean + k Γ— std (--std_k 0.5, etc.)

This interpretability module offers visual insight into model behavior, improves clinical trust, and highlights class-specific decision regions.


πŸ“‚ Project Structure

β”œβ”€β”€ python/                  # Python Model
β”‚   β”œβ”€β”€ model.py               # CNN architecture
β”‚   β”œβ”€β”€ dataset.py             # Dataset preparation
β”‚   β”œβ”€β”€ test.py                # Test perfomance script
β”‚   β”œβ”€β”€ test.sh                # Shell script for test.py
β”‚   β”œβ”€β”€ train.py               # Main training script 
β”‚   └── train.sh               # Shell script for train.py
β”œβ”€β”€ cpp/                     # C++ Model
β”‚   β”œβ”€β”€ CMakeLists.txt         # CMake config file
β”‚   β”œβ”€β”€ model.h                # CNN architecture
β”‚   β”œβ”€β”€ dataset.h              # Dataset preparation
β”‚   β”œβ”€β”€ config.h               # Parameters config
β”‚   β”œβ”€β”€ test.cpp               # Test perfomance script
β”‚   β”œβ”€β”€ test.sh                # Shell script for test.cpp
β”‚   β”œβ”€β”€ train.cpp              # Main training script
β”‚   └── train.sh               # Shell script for train.cpp
β”œβ”€β”€ utils/                   # Other code
β”‚   β”œβ”€β”€ plot_metrics.py        # Plot loss, Plot accuracy
β”‚   β”œβ”€β”€ plot_metrics.sh        # Shell script for plot_metrics.py
β”‚   └── spm_get_doc.m          # MATLAB script for Nipype troubleshooting
β”œβ”€β”€ preprocess/              # Preprocessing scripts
β”‚   β”œβ”€β”€ run_convert.sh         # ADNI -> BIDS convertion
β”‚   β”œβ”€β”€ run_adni_preproc.sh    # T1-volume segmentation on training set
β”‚   └── run_adni_valtest.sh    # T1-volume segmentation on val & test set
β”œβ”€β”€ data/                    # Diagnosis datasets
β”‚   β”œβ”€β”€ participants_Test.tsv  # Subjects in the test set
β”‚   β”œβ”€β”€ participants_Train.tsv # Subjects in the train set
β”‚   └── participants_Val.tsv   # Subjects in the validation set
β”œβ”€β”€ envs/                    # Conda Environments
β”‚   β”œβ”€β”€ clinicaEnv.yml         # Conda Env for Clinica
β”‚   β”œβ”€β”€ gradcamEnv.yml         # Conda Env for Grad-CAM
β”‚   └── trainEnv.yml           # Conda Env for Training
β”œβ”€β”€ gradcam/                 # Grad-CAM visualization
β”‚   β”œβ”€β”€ gradcam_out/           # Folder containing Grad-CAM outputs
β”‚   β”œβ”€β”€ visualize.py           # Script for Grad-CAM visualization
β”‚   β”œβ”€β”€ gradcam_otsu.sh        # Shell script for visualize.py w/Otsu
β”‚   β”œβ”€β”€ gradcam_std.sh         # Shell script for visualize.py w/std
β”‚   └── gradcam_pct.sh         # Shell script for visualize.py w/pct
β”œβ”€β”€ results/                 # Output files containing Test results
β”‚   β”œβ”€β”€ cpp/                   # Folder containing C++ results
β”‚   β”œβ”€β”€ python/                # Folder containing Python results
β”‚   └── Test_Results.ipynb     # Notebook for model evaluation metrics
β”œβ”€β”€ media/                   # Images/GIFs/...
β”œβ”€β”€ config.yaml              # Model hyperparameters
β”œβ”€β”€ INSTALL.md
β”œβ”€β”€ README.md
└── report.pdf

πŸ™ Acknowledgements

  • Liu et al. for their foundational model and research

  • MeluXina Support Team for infrastructure and consultation

  • Clinica Developers for powerful neuroimaging tools

  • MOX Lab @ Politecnico di Milano for support and guidance

πŸ“¬ Contacts

β”œβ”€β”€ Vittorio Pio Remigio Cozzoli, Student, Politecnico di Milano
β”‚     β”œβ”€β”€ [email protected]
β”œβ”€β”€ Tommaso Crippa, Student, Politecnico di Milano
β”‚     β”œβ”€β”€ [email protected]
β”œβ”€β”€ Alberto Taddei, Student, Politecnico di Milano
β”‚     β”œβ”€β”€ [email protected]

License and Ethical Use Notice

All rights reserved.
This repository contains research code developed for academic purposes only.
Images and medical data used in this project are derived from publicly available datasets (ADNI), that are not linked to any identifiable individuals.

Nevertheless, as the subject matter involves sensitive neuroimaging data, we kindly ask users to treat visual outputs with scientific respect.
Any clinical, diagnostic, or commercial usage of this code or its outputs is strictly prohibited without prior written permission.

If you are a researcher or instructor and wish to reuse this material for non-commercial academic use, please contact the authors.

About

Early detection of Alzheimer’s Disease using 3D CNNs on structural MRIs, leveraging the ADNI dataset, Clinica preprocessing, and MeluXina HPC for high-performance training and Grad-CAM interpretability. 🧠

Topics

Resources

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •