PICAI Baselines
Project description
Baseline AI Models for Prostate Cancer Detection in MRI
This repository contains utilities to set up and train deep learning-based detection models for clinically significant prostate cancer (csPCa) in MRI. In turn, these models serve as the official baseline AI solutions for the PI-CAI challenge. As of now, the following three models are provided and supported:
All three solutions share the same starting point, with respect to their expected folder structure and data preparation pipeline.
Issues
Please feel free to raise any issues you encounter here.
Installation
picai_baseline
can be pip-installed:
pip install picai_baseline
Alternatively, picai_baseline
can be installed from source:
git clone https://github.com/DIAGNijmegen/picai_baseline
cd picai_baseline
pip install -e .
Installing from source ensures the scripts are present locally, which enables you to run the provided Python scripts. Additionally, this allows you to modify the baseline solutions, due to the -e
option.
General Setup
We define setup steps that are shared between the different baseline algorithms. To follow the model-specific baseline algorithm tutorials, these steps must be completed first.
Folder Structure
We define three main folders that must be prepared:
/input/
contains the PI-CAI dataset. In this tutorial we assume this is the PI-CAI Public Training and Development Dataset./workdir/
stores intermediate results, such as preprocessed images and annotations./workdir/results/[model name]/
stores model checkpoints/weights during training (enables the ability to pause/resume training).
/output/
stores training output, such as trained model weights and preprocessing plan.
Data Preparation
Unless specified otherwise, this tutorial assumes that the PI-CAI: Public Training and Development Dataset will be downloaded and unpacked. Before downloading the dataset, read its documentation and dedicated forum post (for all updates/fixes, if any). To download and unpack the dataset, run the following commands:
# download all folds
curl -C - "https://zenodo.org/record/6624726/files/picai_public_images_fold0.zip?download=1" --output picai_public_images_fold0.zip
curl -C - "https://zenodo.org/record/6624726/files/picai_public_images_fold1.zip?download=1" --output picai_public_images_fold1.zip
curl -C - "https://zenodo.org/record/6624726/files/picai_public_images_fold2.zip?download=1" --output picai_public_images_fold2.zip
curl -C - "https://zenodo.org/record/6624726/files/picai_public_images_fold3.zip?download=1" --output picai_public_images_fold3.zip
curl -C - "https://zenodo.org/record/6624726/files/picai_public_images_fold4.zip?download=1" --output picai_public_images_fold4.zip
# unzip all folds
unzip picai_public_images_fold0.zip -d /input/images/
unzip picai_public_images_fold1.zip -d /input/images/
unzip picai_public_images_fold2.zip -d /input/images/
unzip picai_public_images_fold3.zip -d /input/images/
unzip picai_public_images_fold4.zip -d /input/images/
In case unzip
is not installed, you can use Docker to unzip the files:
docker run --cpus=2 --memory=8gb --rm -v /path/to/input:/input joeranbosma/picai_nnunet:latest unzip /input/picai_public_images_fold0.zip -d /input/images/
docker run --cpus=2 --memory=8gb --rm -v /path/to/input:/input joeranbosma/picai_nnunet:latest unzip /input/picai_public_images_fold1.zip -d /input/images/
docker run --cpus=2 --memory=8gb --rm -v /path/to/input:/input joeranbosma/picai_nnunet:latest unzip /input/picai_public_images_fold2.zip -d /input/images/
docker run --cpus=2 --memory=8gb --rm -v /path/to/input:/input joeranbosma/picai_nnunet:latest unzip /input/picai_public_images_fold3.zip -d /input/images/
docker run --cpus=2 --memory=8gb --rm -v /path/to/input:/input joeranbosma/picai_nnunet:latest unzip /input/picai_public_images_fold4.zip -d /input/images/
Please follow the instructions here to set up the Docker container.
Also, collect the training annotations. This can be done via the following command:
cd /input
git clone https://github.com/DIAGNijmegen/picai_labels
After cloning the repository with annotations, you should have a folder structure like this:
/input/picai_labels
├── anatomical_delineations
│ ├── ...
├── clinical_information
│ └── marksheet.csv
└── csPCa_lesion_delineations
├── ...
Cross-Validation Splits
We have prepared 5-fold cross-validation splits of all 1500 cases in the PI-CAI: Public Training and Development Dataset. We have ensured there is no patient overlap between training/validation splits. You can load these splits as follows:
from picai_baseline.splits.picai import train_splits, valid_splits
for fold, ds_config in train_splits.items():
print(f"Training fold {fold} has cases: {ds_config['subject_list']}")
for fold, ds_config in valid_splits.items():
print(f"Validation fold {fold} has cases: {ds_config['subject_list']}")
Additionally, we prepared 5-fold cross-validation splits of all cases with an expert-derived csPCa annotation. These splits are subsets of the splits above. You can load these splits as follows:
from picai_baseline.splits.picai_nnunet import train_splits, valid_splits
When using picai_eval
from the command line, we recommend saving the splits to disk. Then, you can pass these to picai_eval
to ensure all cases were found. You can export the labelled cross-validation splits using:
python -m picai_baseline.splits.picai_nnunet --output "/workdir/splits/picai_nnunet"
Data Preprocessing
We follow the nnU-Net Raw Data Archive
format to prepare our dataset for usage. For this, you can use the picai_prep
module. The picai_prep
module allows to resample all cases to the same resolution (you can resample each case indivudually to the same resolution between the different sequences, or choose to resample the full dataset to the same resolution). For details on the available options to convert the dataset in /input/
into the nnU-Net Raw Data Archive
format, and store it in /workdir/nnUNet_raw_data
, please see the instructions provided here. Below we give the conversion as performed for the baseline semi-supervised nnU-Net. For the U-Net baseline, please see the U-Net tutorial for extra instructions.
Note, the picai_prep
module should be automatically installed when installing the picai_baseline
module, and is installed within the picai_nnunet
and picai_nndetection
Docker containers as well.
python src/picai_baseline/prepare_data_semi_supervised.py
For the baseline semi-supervised U-Net algorithm, specify the dataset-wise resolution: --spacing 3.0 0.5 0.5
.
To adapt/modify the preprocessing pipeline or its default specifications, either check out the various command like options (use flag -h
to show these) or make changes to the prepare_data_semi_supervised.py
script.
Alternatively, you can use Docker to run the Python script:
docker run --cpus=2 --memory=16gb --rm \
-v /path/to/input/:/input/ \
-v /path/to/workdir/:/workdir/ \
-v /path/to/picai_baseline:/scripts/picai_baseline/ \
joeranbosma/picai_nnunet:latest python3 /scripts/picai_baseline/src/picai_baseline/prepare_data_semi_supervised.py
If you don't want to include the AI-generated annotations, you can also use the supervised data preparation script: prepare_data.py
.
Baseline Algorithms
We provide end-to-end training pipelines for csPCa detection/diagnosis in 3D. Each baseline includes a template to encapsulate the trained AI model in a Docker container, and uploading the same to the grand-challenge.org platform as an "algorithm".
U-Net
We include a baseline U-Net to provide a playground environment for participants and kickstart their development cycle. The U-Net baseline generates quick results with minimal complexity, but does so at the expense of sub-optimal performance and low flexibility in adapting to any other task.
→ Read the full documentation here.
nnU-Net
The nnU-Net framework [1] provides a performant framework for medical image segmentation, which is straightforward to adapt for csPCa detection.
→ Read the full documentation here.
nnDetection
The nnDetection framework is geared towards medical object detection [2]. Setting up nnDetection and tweaking its implementation is not as straightforward as for the nnUNet or UNet baselines, but it can provide a strong csPCa detection model.
→ Read the full documentation here.
References
[1] Fabian Isensee, Paul F. Jaeger, Simon A. A. Kohl, Jens Petersen and Klaus H. Maier-Hein. "nnU-Net: a self-configuring method for deep learning-based biomedical image segmentation". Nature Methods 18.2 (2021): 203-211.
[2] Michael Baumgartner, Paul F. Jaeger, Fabian Isensee, Klaus H. Maier-Hein. "nnDetection: A Self-configuring Method for Medical Object Detection". International Conference on Medical Image Computing and Computer-Assisted Intervention. Springer, Cham, 2021.
[3] Joeran Bosma, Anindo Saha, Matin Hosseinzadeh, Ilse Slootweg, Maarten de Rooij, Henkjan Huisman. "Semi-supervised learning with report-guided lesion annotation for deep learning-based prostate cancer detection in bpMRI". arXiv:2112.05151.
[4] Joeran Bosma, Natalia Alves and Henkjan Huisman. "Performant and Reproducible Deep Learning-Based Cancer Detection Models for Medical Imaging". Under Review.
If you are using this codebase or some part of it, please cite the following article:
If you are using the AI-generated annotations (i.e., semi-supervised learning), please cite the following article: ● J. S. Bosma, A. Saha, M. Hosseinzadeh, I. Slootweg, M. de Rooij, and H. Huisman, "Semisupervised Learning with Report-guided Pseudo Labels for Deep Learning–based Prostate Cancer Detection Using Biparametric MRI", Radiology: Artificial Intelligence, 230031, 2023. doi:10.1148/ryai.230031
BibTeX:
@article{PICAI_BIAS,
author={Anindo Saha, Jasper J. Twilt, Joeran S. Bosma, Bram van Ginneken, Derya Yakar, Mattijs Elschot, Jeroen Veltman, Jurgen Fütterer, Maarten de Rooij, Henkjan Huisman},
title={{Artificial Intelligence and Radiologists at Prostate Cancer Detection in MRI: The PI-CAI Challenge (Study Protocol)}},
year={2022},
doi={10.5281/zenodo.6667655}
}
@article{Bosma23,
author={Joeran S. Bosma, Anindo Saha, Matin Hosseinzadeh, Ivan Slootweg, Maarten de Rooij, and Henkjan Huisman},
title={Semisupervised Learning with Report-guided Pseudo Labels for Deep Learning–based Prostate Cancer Detection Using Biparametric MRI},
journal={Radiology: Artificial Intelligence},
pages={e230031},
year={2023},
doi={10.1148/ryai.230031},
publisher={Radiological Society of North America}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file picai_baseline-0.8.5.tar.gz
.
File metadata
- Download URL: picai_baseline-0.8.5.tar.gz
- Upload date:
- Size: 858.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98607665c1e127acede0689da2f56c6c2d142fa0737414e5c4bebf950571c6f4 |
|
MD5 | c205d9af800f7b8c65e5a7a88803957e |
|
BLAKE2b-256 | 83be3463dd900bd4871c5ac49444c25ae2b585406511ce1eb68176d491b7397c |
File details
Details for the file picai_baseline-0.8.5-py3-none-any.whl
.
File metadata
- Download URL: picai_baseline-0.8.5-py3-none-any.whl
- Upload date:
- Size: 907.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5ebe5de6f68d2222e95a2a648a7a36d50f266ed50b83da3b79588b098c81eea |
|
MD5 | 58528528760f598bc61108f7100bb46a |
|
BLAKE2b-256 | 32b27d3f98f66bd1b35ebd7fa165a94f3ca5aeabb7d4c0d7da4018c94b61a491 |