Package: picai-baseline
Baseline AI Models for Prostate Cancer Detection in MRIThis 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 thePI-CAI challenge. As of now, the following three models will be provided and supported:U-NetnnU-NetnnDetectionAll three solutions share the same starting point, with respect to their expectedfolder structureanddata preparationpipeline.IssuesPlease feel free to raise any issues you encounterhere.Installationpicai_baselinecan be pip-installed:pipinstallpicai_baselineAlternatively,picai_baselinecan be installed from source:gitclonehttps://github.com/DIAGNijmegen/picai_baselinecdpicai_baseline
pipinstall-e.This 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-eoption. Furthermore, this ensures the latest version is installed.General SetupWe define setup steps that are shared between the different baseline algorithms. To follow the baseline algorithm tutorials, this setup must be completed first.Folder StructureWe define three main folders that must be prepared apriori:/input/contains one of thePI-CAI datasets. This can be the Public Training and Development Dataset, the Private Training Dataset, the Hidden Validation and Tuning Cohort, or the Hidden Testing Cohort./input/images/contains the imaging files. For the Public Training and Development Dataset, these can be retrievedhere./input/picai_labels/contains the annotations. For the Public Training and Development Dataset, these can be retrievedhere./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 PreparationUnless specified otherwise, this tutorial assumes that thePI-CAI: Public Training and Development Datasetwill be downloaded and unpacked. Before downloading the dataset, read itsdocumentationanddedicated forum post(for all updates/fixes, if any). To download and unpack the dataset, run the following commands:# download all foldscurl-C-"https://zenodo.org/record/6624726/files/picai_public_images_fold0.zip?download=1"--outputpicai_public_images_fold0.zip
curl-C-"https://zenodo.org/record/6624726/files/picai_public_images_fold1.zip?download=1"--outputpicai_public_images_fold1.zip
curl-C-"https://zenodo.org/record/6624726/files/picai_public_images_fold2.zip?download=1"--outputpicai_public_images_fold2.zip
curl-C-"https://zenodo.org/record/6624726/files/picai_public_images_fold3.zip?download=1"--outputpicai_public_images_fold3.zip
curl-C-"https://zenodo.org/record/6624726/files/picai_public_images_fold4.zip?download=1"--outputpicai_public_images_fold4.zip# unzip all foldsunzippicai_public_images_fold0.zip-d/input/images/
unzippicai_public_images_fold1.zip-d/input/images/
unzippicai_public_images_fold2.zip-d/input/images/
unzippicai_public_images_fold3.zip-d/input/images/
unzippicai_public_images_fold4.zip-d/input/images/In caseunzipis not installed, you can use Docker to unzip the files:dockerrun--cpus=2--memory=8gb--rm-v/path/to/input:/inputjoeranbosma/picai_nnunet:latestunzip/input/picai_public_images_fold0.zip-d/input/images/
dockerrun--cpus=2--memory=8gb--rm-v/path/to/input:/inputjoeranbosma/picai_nnunet:latestunzip/input/picai_public_images_fold1.zip-d/input/images/
dockerrun--cpus=2--memory=8gb--rm-v/path/to/input:/inputjoeranbosma/picai_nnunet:latestunzip/input/picai_public_images_fold2.zip-d/input/images/
dockerrun--cpus=2--memory=8gb--rm-v/path/to/input:/inputjoeranbosma/picai_nnunet:latestunzip/input/picai_public_images_fold3.zip-d/input/images/
dockerrun--cpus=2--memory=8gb--rm-v/path/to/input:/inputjoeranbosma/picai_nnunet:latestunzip/input/picai_public_images_fold4.zip-d/input/images/Please follow theinstructions hereto set up the Docker container.Also, collect the training annotations. This can be done via the following command:cd/input
gitclonehttps://github.com/DIAGNijmegen/picai_labelsAfter 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 SplitsWe have prepared 5-fold cross-validation splits of all 1500 cases in thePI-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:frompicai_baseline.splits.picaiimporttrain_splits,valid_splitsforfold,ds_configintrain_splits.items():print(f"Training fold{fold}has cases:{ds_config['subject_list']}")forfold,ds_configinvalid_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 anexpert-derived csPCa annotation. These splits are subsets of the splits above. You can load these splits as follows:frompicai_baseline.splits.picai_nnunetimporttrain_splits,valid_splitsWhen usingpicai_evalfrom the command line, we recommend saving the splits to disk. Then, you can pass these topicai_evalto ensure all cases were found. You can export the labelled cross-validation splits using:python-mpicai_baseline.splits.picai_nnunet--output"/workdir/splits/picai_nnunet"Data PreprocessingWe follow thennU-Net Raw Data Archiveformat to prepare our dataset for usage. For this, you can use thepicai_prepmodule. Note, thepicai_prepmodule should be automatically installed when installing thepicai_baselinemodule, and is installed within thepicai_nnunetandpicai_nndetectionDocker containers as well.To convert the dataset in/input/into thennU-Net Raw Data Archiveformat, and store it in/workdir/nnUNet_raw_data, please follow the instructionsprovided here, or set your target paths inprepare_data.pyand execute it:pythonsrc/picai_baseline/prepare_data.pyTo adapt/modify the preprocessing pipeline or its default specifications, please make changes to theprepare_data.pyscript accordingly.Alternatively, you can use Docker to run the Python script:dockerrun--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:latestpython3/scripts/picai_baseline/src/picai_baseline/prepare_data.pyBaseline AlgorithmsWe 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 thegrand-challenge.orgplatform as an"algorithm".U-NetWe include a baselineU-Netto 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-NetThe 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.nnDetectionThe nnDetection framework is geared towards medical object detection[2]. Setting up nnDetection and tweaking its implementation is not as straightforward as for thennUNetorUNetbaselines, 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:●A. Saha, J. J. Twilt, J. S. Bosma, B. van Ginneken, D. Yakar, M. Elschot, J. Veltman, J. J. Fütterer, M. de Rooij, H. Huisman, "Artificial Intelligence and Radiologists at Prostate Cancer Detection in MRI: The PI-CAI Challenge (Study Protocol)", DOI: 10.5281/zenodo.6667655BibTeX:@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}
}