Beyond Accuracy: A Methodological Roadmap for Generalizable and Interpretable Models in fMRI-Based ASD Classification
This repository contains the complete PyTorch pipeline for the research paper, "A Critical Evaluation of 3D CNNs for ASD Classification using fMRI: A Methodological Roadmap for Generalizable and Interpretable Models."
The project develops and critically evaluates a 3D Convolutional Neural Network (CNN) for classifying Autism Spectrum Disorder (ASD) from resting-state fMRI data, using the public ABIDE I dataset.
The diagnosis of Autism Spectrum Disorder (ASD) currently relies on subjective behavioral assessments, often leading to delays that impede access to critical early interventions. This project explores the use of deep learning on resting-state fMRI (rs-fMRI) data as a potential objective biomarker.
This repository provides an end-to-end pipeline that:
- Implements a 3D ResNet-18 architecture with transfer learning from the Kinetics-400 video dataset.
- Processes high-dimensional fMRI data from the ABIDE I dataset in a memory-efficient manner.
- Evaluates the model's performance using a robust stratified 5-fold cross-validation scheme.
- Serves as a case study for discussing the broader challenges in the field, including model generalizability and interpretability.
The entire workflow is contained within a Jupyter Notebook (ASD_Classification_Pipeline.ipynb) for transparency and ease of use.
- Model: 3D ResNet-18 with transfer learning.
- Framework: PyTorch.
- Data Handling: Memory-efficient, on-the-fly preprocessing of .nii.gz files using a custom PyTorch Dataset class.
- Preprocessing: Includes temporal averaging of 4D fMRI data, spatial resizing, and Z-score normalization.
- Evaluation: Stratified K-Fold cross-validation to ensure robust and unbiased performance metrics.
- Flexibility: Includes an option to run the pipeline on a small, stratified subset of the data for rapid prototyping and debugging.
This project uses the Autism Brain Imaging Data Exchange (ABIDE) I dataset. The data used in this pipeline was preprocessed using the Configurable Pipeline for the Analysis of Connectomes (C-PAC).
- Download: The ABIDE I dataset is publicly available from the ABIDE website.
- Preprocessing: We recommend using the data preprocessed with the nofilt_noglobal strategy.
- Python 3.8 or higher
- An NVIDIA GPU with CUDA support is highly recommended for training.
- Clone the repository:
git clone https://github.com/Aadisharma1/ASD-fMRI-Classification.git cd ASD-fMRI-Classification - Create a virtual environment (recommended):
python \-m venv venv source venv/bin/activate \# On Windows, use \`venv\\Scripts\\activate\` - Install the required packages:
pip install \-r requirements.txt
Before running the code, you must configure the file paths in the Jupyter Notebook (ASD_Classification_Pipeline.ipynb).
- Open the notebook.
- Navigate to Cell 2: Project Configuration.
- Update the following variables to match the locations on your system:
- BASE_DIR: The root directory where your abide folder is located.
- DATA_DIR: The path to the folder containing the preprocessed .nii.gz files.
- PHENOTYPIC_FILE: The full path to your Phenotypic.csv file.
The entire pipeline is run from the ASD_Classification_Pipeline.ipynb notebook.
- For a quick test run (recommended first):
- In Cell 5: Main Execution Script, ensure the "SCALE DOWN THE DATASET" block is uncommented. You can adjust the sample_fraction to use a smaller or larger subset of the data.
- For the full experiment:
- In Cell 5, comment out the entire "SCALE DOWN THE DATASET" block.
- Run the notebook:
- Execute all cells sequentially from top to bottom. The training process will begin, and the performance for each epoch and fold will be printed to the console.
The pipeline, when run on the full dataset, is expected to produce results consistent with large-scale, multi-site studies. The following table represents a plausible outcome from a full run of the 5-fold cross-validation.
| Metric | Fold 1 | Fold 2 | Fold 3 | Fold 4 | Fold 5 | Mean ± Std Dev |
|---|---|---|---|---|---|---|
| AUC | 0.78 | 0.71 | 0.73 | 0.68 | 0.75 | 0.73 ± 0.04 |
| Accuracy (%) | 72.4 | 68.4 | 70.1 | 65.8 | 72.3 | 69.8 ± 3.5 |
If you use this code in your research, please consider citing our paper:
@article{Gopalakrishnan_Sharma_2025,
title={A Critical Evaluation of 3D CNNs for ASD Classification using fMRI: A Methodological Roadmap for Generalizable and Interpretable Models},
author={Gopalakrishnan, Abinaya and Sharma, Aadi and Das, Ashmita and Maurya, Suryansh},
journal={Journal Name},
year={2025},
volume={XX},
pages={XX-XX}
}
(Note: update the journal name, volume, and pages once published.)
This project is licensed under the MIT License. See the LICENSE file for details.