AmyloidPETNet: Classification of Amyloid Positivity in Brain PET Imaging Using End-to-End Deep Learning
This is the repository for running inference using AmyloidPETNet with pre-trained weights. AmyloidPETNet is a deep learning model that can make binary amyloid positivity classifications based on minimally processed brain PET scans without companion structural MRI scans. Follow this README to get started. The repoistory onsists of the following:
environment.yaml: conda environment file for dependency installationmodel: subdirectory containing the model weightspredict.py: main inference scriptDeepPET: local python module
To install the dependencies of AmyloidPETNet, run the following command:
conda env create -f environment.yml
This environment setup had been tested on a Linux cluster with AMD64 CPUs and NVIDIA GPUs. We welcome PRs for environment setups on other platforms.
This repository includes a Dockerized workflow for running inference and training in a reproducible environment.
Dockerfile: builds the project image fromenvironment.ymlusingmicromambadocker-compose.yml: defines the runtime container, cache mount, and output mount.vscode/tasks.json: one-click VS Code tasks for Windows+WSL users
- Docker Engine with Docker Compose v2
- For Windows users: Docker Desktop + WSL2 integration enabled
- For Linux users: Docker and Compose available in your shell
From VS Code:
- Open Command Palette
- Run
Tasks: Run Task - Choose
Docker: Build AmyloidPETNet image (WSL)
This task runs:
wsl bash -lc "docker compose build amyloidpetnet"
Equivalent command-line build from repository root:
docker compose build amyloidpetnetUse task Docker: Predict (WSL).
It will prompt you for:
- dataset csv path relative to repo (example:
data/predict.csv) - model directory relative to repo (example:
model) - visualization output subdirectory inside
outputs/(example:vis)
The task writes visualizations to outputs/<your_vis_dir> and uses /tmp inside the container for temporary cache files.
Equivalent command-line prediction from repository root:
docker compose run --rm amyloidpetnet predict.py --odir /app/model --dataset /app/data/predict.csv --cdir /tmp --vdir /outputs/visUse task Docker: Train (WSL).
It will prompt you for:
- training csv path relative to repo
- validation csv path relative to repo
- output subdirectory inside
outputs/
Training outputs are saved under outputs/<your_train_output_dir>.
Equivalent command-line training from repository root:
docker compose run --rm amyloidpetnet train.py --train /app/data/train.csv --val /app/data/val.csv --cdir /tmp --odir /outputs/train-run- The tasks map the repo root to
/appin container. - CSVs should use image paths that are accessible from inside container.
- Easiest approach: keep data under this repo (for example
data/) and reference/app/...paths.
AmyloidPETNet expects input images of the NIfTI format (.nii or .nii.gz). Depending on the amyloid tracer, each amyloid brain scan consists of multiple frames of various durations. AmyloidPETNet is compatible with 5-minute frames acquired after the tracer binding steady state was reached. For more details, please refer to our Radiology manuscript.
To make predictions with our model, run the following command:
python predict.py
--odir $MODEL_DIR
--dataset $DATASET_CSV
--cdir $TMP_DIR
--vdir $VIS_DIR
$MODEL_DIR: directory containing the model weights, i.e.model.pth.$MODEL_DIRdefaults to./model.$DATASET_CSV: path to a.csvfile with a column namedimg_path(case-sensitive) that contains the paths to input images, each image being a 3D frame.$TMP_DIR: directory for storing temporary cached files of the preprocessing pipeline. This can be any directory that you have write access to, but please note that during clean-up the script will remove all files with a.ptsuffix.$TMP_DIRdefaults to/tmp.$VIS_DIR: directory for storing the processed images. For more details, please refer to the trouble shooting section. To skip storing the processed images, remove this flag.
For each frame, the script will output the logit, defined as $
\text{logit}(p) = \ln\left(\frac{p}{1 - p}\right)
$, where .csv file in $MODEL_DIR with logits stored under a column named y_score.
If you would like to train AmyloidPETNet from scratch on your own dataset, run the following command
python train.py
--train $PATH_TO_TRAIN_DATA
--val $PATH_TO_VAL_DATA
--cdir $TMP_DIR
-
$PATH_TO_TRAIN_DATA: path to a.csvfile with the following columns:-
img_path: paths to input images, each image being a 3D frame. -
suvr_positivity: binary labels of amyloid positivity.
-
-
$PATH_TO_VAL_DATA: same as above but for validation data -
$TMP_DIR: directory for storing temporary cached files of the preprocessing pipeline. This can be any directory that you have write access to, but please note that during clean-up the script will remove all files with a.ptsuffix.$TMP_DIRdefaults to/tmp.
To help with trouble shooting, the user can optionally save the processed images as a series of 2D .png files that span the axial, coronal, and sagittal views. For an example of this, please refer to tmp/example, which contains images of a processed frame from the Centiloid project.
This project is licensed under the LICENSE file in the root directory of the project.
