Repository navigation
Add ADNI Alzheimers Diagnosis Classification: Dataset+Task+Model - #1781
AnnaClark99 wants to merge 6 commits into
Conversation
…dni_cnn.py, example adni_diagnosis_classification_cnn.py, and corresponding tests / yaml.
…ded saliency analysis
…i_classification, updated seed in classification example # Conflicts: # docs/api/models.rst # docs/api/tasks.rst
…i_classification, updated seed in classification example
Test CoverageTotal: 89.05% (62909 / 70645 lines)
|
|
Labeled |
|
/review |
| ) | ||
|
|
||
| # Convert MRI to model input | ||
| image = torch.from_numpy( |
There was a problem hiding this comment.
[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(), |
There was a problem hiding this comment.
[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.
There was a problem hiding this comment.
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:
- In
examples/adni_saliency_analysis.py,analyze_mrifeeds raw NIfTI intensities to the model. Training usesnormalize="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. Thetranspose(2,1,0)calls should be checked against it.
Optional suggestions:
build_recordsonly 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
ADNIDatasetdocstring differ (ADNI_dxwithparticipants.tsvversusTRAINwithTrain_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_mappingcopies the label map instead of checkingtask.label_map. Using the task's own map would make the test meaningful.cropis 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
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.
ADNIDatasetloads Clinica-preprocessed ADNI T1 MRIs and a diagnosis TSV, with one event per scan session.AdniMRIClassificationcreates one sample per scan and maps the raw ADNI diagnoses to CN, MCI and AD.ADNICNNimplements the paper's architecture (4 × Conv3D → InstanceNorm → ReLU → MaxPool, widening factor 8) and its training augmentation (Gaussian blur, random 96³ crop).--synthetic. A second example extends the paper's saliency analysis to AAL brain regions.Files to Review:
pyhealth/datasets/adni.py:ADNIDatasetandbuild_recordspyhealth/datasets/configs/adni.yaml: dataset table configpyhealth/tasks/adni_mri_classification.py:AdniMRIClassificationtaskpyhealth/models/adni_cnn.py:ADNICNNmodelpyhealth/datasets/__init__.py,pyhealth/tasks/__init__.py,pyhealth/models/__init__.py: exportstests/core/test_adni.py: dataset teststests/core/test_adni_mri_classification.py: task teststests/core/test_adni_cnn.py: model testsexamples/adni_mri_classification_cnn.py: full pipeline example (--syntheticfor a no-data run)examples/adni_saliency_analysis.py: saliency and AAL region attribution exampledocs/api/datasets/pyhealth.datasets.ADNIDataset.rst,docs/api/tasks/pyhealth.tasks.AdniMRIClassification.rst,docs/api/models/pyhealth.models.ADNICNN.rst: API docsdocs/api/datasets.rst,docs/api/tasks.rst,docs/api/models.rst: index updates