Skip to content

Add ADNI Alzheimers Diagnosis Classification: Dataset+Task+Model - #1781

Open
AnnaClark99 wants to merge 6 commits into
sunlabuiuc:masterfrom
AnnaClark99:master
Open

AnnaClark99 wants to merge 6 commits into
sunlabuiuc:masterfrom
AnnaClark99:master

Conversation

@AnnaClark99

Copy link
Copy Markdown

Contributor: Anna Clark (GTID: aclark339, aclark339@gatech.edu) and Ananya Kulkarni (GTID: akulkarni351, akulkarni351@gatech.edu)

Contribution Type: Full Pipeline (Dataset + Task + Model)

Paper: Liu, S., Yadav, C., Fernandez-Granda, C., & Razavian, N. (2019). On the design of convolutional neural networks for automatic detection of Alzheimer's disease. Machine Learning for Health (ML4H) Workshop, NeurIPS 2019. https://arxiv.org/abs/1911.03740

Description:
This PR adds an end-to-end pipeline for three-class Alzheimer's disease diagnosis (CN / MCI / AD) from T1-weighted brain MRI, reproducing the main 3D CNN of Liu et al. (2019) without its optional age encoding.

  • ADNIDataset loads Clinica-preprocessed ADNI T1 MRIs and a diagnosis TSV, with one event per scan session.
  • AdniMRIClassification creates one sample per scan and maps the raw ADNI diagnoses to CN, MCI and AD.
  • ADNICNN implements the paper's architecture (4 × Conv3D → InstanceNorm → ReLU → MaxPool, widening factor 8) and its training augmentation (Gaussian blur, random 96³ crop).
  • The example trains and evaluates the full pipeline with the paper's settings, and runs with no ADNI access via --synthetic. A second example extends the paper's saliency analysis to AAL brain regions.

Files to Review:

  • pyhealth/datasets/adni.py: ADNIDataset and build_records
  • pyhealth/datasets/configs/adni.yaml: dataset table config
  • pyhealth/tasks/adni_mri_classification.py: AdniMRIClassification task
  • pyhealth/models/adni_cnn.py: ADNICNN model
  • pyhealth/datasets/__init__.py, pyhealth/tasks/__init__.py, pyhealth/models/__init__.py: exports
  • tests/core/test_adni.py: dataset tests
  • tests/core/test_adni_mri_classification.py: task tests
  • tests/core/test_adni_cnn.py: model tests
  • examples/adni_mri_classification_cnn.py: full pipeline example (--synthetic for a no-data run)
  • examples/adni_saliency_analysis.py: saliency and AAL region attribution example
  • docs/api/datasets/pyhealth.datasets.ADNIDataset.rst, docs/api/tasks/pyhealth.tasks.AdniMRIClassification.rst, docs/api/models/pyhealth.models.ADNICNN.rst: API docs
  • docs/api/datasets.rst, docs/api/tasks.rst, docs/api/models.rst: index updates

…dni_cnn.py, example adni_diagnosis_classification_cnn.py, and corresponding tests / yaml.
…i_classification, updated seed in classification example

# Conflicts:
#	docs/api/models.rst
#	docs/api/tasks.rst
…i_classification, updated seed in classification example
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Test Coverage

Total: 89.05% (62909 / 70645 lines)

Modified file Coverage Lines
pyhealth/datasets/__init__.py 100.00% 96 / 96
pyhealth/datasets/adni.py 88.00% 22 / 25
pyhealth/models/__init__.py 100.00% 135 / 135
pyhealth/models/adni_cnn.py 93.10% 54 / 58
pyhealth/tasks/__init__.py 98.68% 149 / 151
pyhealth/tasks/adni_mri_classification.py 95.45% 21 / 22

Workflow run · 8213bef

@solarsys solarsys added the status: automatic The PR will go through automatic review process. label Dec 1, 2026
@solarsys

solarsys commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Labeled status: automatic: everything is in the review folders and tests are in tests/core. One thing blocks merging: the contribution-rules check fails on ruff findings in the new files (see the check log). Most are fixed by ruff check --fix <files>. Then run python tools/check_pr_rules.py --base master --head HEAD and push. Once the build and rules pass, the AI review will run.

@solarsys

solarsys commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed commit 8213bef

)

# Convert MRI to model input
image = torch.from_numpy(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[high] Saliency analysis feeds unnormalized MRI to a model trained on z-scored input

analyze_mri loads the NIfTI with nibabel and passes the raw intensities (after a center crop and transpose) straight to the model. Training uses AdniMRIClassification's nifti input, which goes through NiftiProcessor with canonical=False and normalize="mri" (a per-image z-score over non-zero voxels). The predicted probabilities, confidence and saliency maps are therefore computed on inputs the model never saw in training, and the ROI results inherit that error. Fix: apply the same intensity normalization before the model call, for example normalize_intensity(volume, "mri") from pyhealth.processors.image_io.transforms, or load through NiftiProcessor with the task's settings. Also confirm the transpose(2,1,0) axis order matches what the processor returns.

*block(3, 3, 0, 2, 4 * f, 32 * f),
*block(5, 3, 2, 2, 32 * f, 64 * f),
*block(3, 5, 1, 2, 64 * f, 64 * f),
nn.Flatten(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[medium] Two stacked linear head layers with no activation

nn.Linear(64*f, 1024) is followed directly by nn.Linear(1024, output_size) with no nonlinearity or dropout between them. The composition is a single linear map, so the 1024-unit layer adds no capacity, and the class docstring lists the same FC1/FC2 structure with no activation. Check the head against Liu et al. (2019). If the paper has an activation (and possibly dropout) after FC1, add it here and in the docstring; if the omission is intended, state it in the docstring. I could not check the paper from the repository.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Review

suggestion: need change
decision: need change

Thank you for this contribution. It adds a full ADNI pipeline: a Clinica-based dataset, a CN/MCI/AD classification task, and a 3D CNN that follows Liu et al. (2019). It also adds two examples, API docs and tests. The library code looks solid, and the dataset cites its source. Coverage is above the bar: the whole repository is at 89.05%, adni.py at 88%, adni_cnn.py at 93.1%, and adni_mri_classification.py at 95.45%. The new components build only on the base classes and the existing NiftiProcessor, and no shared code is changed.

To get this merged:

  1. In examples/adni_saliency_analysis.py, analyze_mri feeds raw NIfTI intensities to the model. Training uses normalize="mri" (per-image z-score) through the task's input schema. The predictions, saliency maps and ROI rankings are therefore computed on inputs the model never saw. Please apply the same normalization to the cropped volume, or reuse the processor, before building the tensor. Please also confirm the axis order matches what the processor produces. The transpose(2,1,0) calls should be checked against it.

Optional suggestions:

  • build_records only fails when no MRI file exists. If some files are missing, those rows still reach the dataset and will fail later. Consider dropping rows whose file doesn't exist, or warning about them.
  • The two Clinica commands in the docs page and the ADNIDataset docstring differ (ADNI_dx with participants.tsv versus TRAIN with Train_ADNI.tsv). Using one version would be clearer.
  • The two linear layers in the head have no activation between them, so they act as a single linear map. Please check this against the paper. If it is intended, a short docstring note would help.
  • test_label_mapping copies the label map instead of checking task.label_map. Using the task's own map would make the test meaningful.
  • crop is documented as "must be 96" but isn't validated.
  • The saliency example is long, and splitting it up could make it easier to read.

Reviewed commit 8213bef

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: automatic The PR will go through automatic review process.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants