This repository hosts the MONAI tutorials.
Most of the examples and tutorials require matplotlib and Jupyter Notebook.
These can be installed with:
python -m pip install -U pip
python -m pip install -U matplotlib
python -m pip install -U notebook
Some of the examples may require optional dependencies. In case of any optional import errors, please install the relevant packages according to MONAI's installation guide. Or install all optional requirements with:
pip install -r https://raw.githubusercontent.com/Project-MONAI/MONAI/master/requirements-dev.txt
Most of the Jupyter Notebooks have an "Open in Colab" button. Please right-click on the button, and select "Open Link in New Tab" to start a Colab page with the corresponding notebook content.
To use GPU resources through Colab, please remember to change the runtime type to GPU
:
- From the
Runtime
menu selectChange runtime type
- Choose
GPU
from the drop-down menu - Click
SAVE
This will reset the notebook and may ask you if you are a robot (these instructions assume you are not).
Running:
!nvidia-smi
in a cell will verify this has worked and show you what kind of hardware you have access to.
2D classification
This notebook shows how to easily integrate MONAI features into existing PyTorch programs. It's based on the MedNIST dataset which is very suitable for beginners as a tutorial. This tutorial also makes use of MONAI's in-built occlusion sensitivity functionality.
2D segmentation
Training and evaluation examples of 2D segmentation based on UNet and synthetic dataset. The examples are standard PyTorch programs and have both dictionary-based and array-based versions.
3D classification
Training and evaluation examples of 3D classification based on DenseNet3D and IXI dataset. The examples are PyTorch Ignite programs and have both dictionary-based and array-based transformation versions.
Training and evaluation examples of 3D classification based on DenseNet3D and IXI dataset. The examples are standard PyTorch programs and have both dictionary-based and array-based transformation versions.
3D segmentation
Training and evaluation examples of 3D segmentation based on UNet3D and synthetic dataset. The examples are PyTorch Ignite programs and have both dictionary-base and array-based transformations.
Training and evaluation examples of 3D segmentation based on UNet3D and synthetic dataset. The examples are standard PyTorch programs and have both dictionary-based and array-based versions.
This tutorial shows how to construct a training workflow of multi-labels segmentation task based on MSD Brain Tumor dataset.
This notebook shows how MONAI may be used in conjunction with the PyTorch Lightning framework.
This notebook is an end-to-end training and evaluation example of 3D segmentation based on MSD Spleen dataset. The example shows the flexibility of MONAI modules in a PyTorch-based program:
- Transforms for dictionary-based training data structure.
- Load NIfTI images with metadata.
- Scale medical image intensity with expected range.
- Crop out a batch of balanced image patch samples based on positive / negative label ratio.
- Cache IO and transforms to accelerate training and validation.
- 3D UNet, Dice loss function, Mean Dice metric for 3D segmentation task.
- Sliding window inference.
- Deterministic training for reproducibility.
This notebook shows how MONAI may be used in conjunction with the Catalyst framework.
This notebook is an end-to-end training & evaluation example of 3D segmentation based on synthetic dataset. The example is a PyTorch Ignite program and shows several key features of MONAI, especially with medical domain specific transforms and event handlers.
This folder provides a simple baseline method for training, validation, and inference for COVID-19 LUNG CT LESION SEGMENTATION CHALLENGE - 2020 (a MICCAI Endorsed Event).
federated learning
The example show how to execute the 3d segmentation torch tutorial on a federated learning platform, Substra.
acceleration
The examples show how to execute distributed training and evaluation based on 3 different frameworks:
- PyTorch native
DistributedDataParallel
module withtorch.distributed.launch
. - Horovod APIs with
horovodrun
. - PyTorch ignite and MONAI workflows.
They can run on several distributed nodes with multiple GPU devices on every node.
And compares the training speed and memory usage with/without AMP.
This notebook compares the performance of Dataset
, CacheDataset
and PersistentDataset
. These classes differ in how data is stored (in memory or on disk), and at which moment transforms are applied.
This tutorial compares the training performance of pure PyTorch program and optimized program in MONAI based on NVIDIA GPU device and latest CUDA library.
The optimization methods mainly include: AMP
, CacheDataset
and Novograd
.
This notebook is a quick demo for devices, run the Ignite trainer engine on CPU, GPU and multiple GPUs.
Demonstrates the use of the ThreadBuffer
class used to generate data batches during training in a separate thread.
Illustrate reading NIfTI files and test speed of different transforms on different devices.
modules
Training and evaluation examples of 3D segmentation based on UNet3D and synthetic dataset with MONAI workflows, which contains engines, event-handlers, and post-transforms. And GAN training and evaluation example for a medical image generative adversarial network. Easy run training script uses GanTrainer
to train a 2D CT scan reconstruction network. Evaluation script generates random samples from a trained network.
The examples are built with MONAI workflows, mainly contain: trainer/evaluator, handlers, post_transforms, etc.
This notebook demonstrates the transformations on volumetric images.
This tutorial uses the MedNIST hand CT scan dataset to demonstrate MONAI's autoencoder class. The autoencoder is used with an identity encode/decode (i.e., what you put in is what you should get back), as well as demonstrating its usage for de-blurring and de-noising.
This tutorial shows how to train 3D segmentation tasks on all the 10 decathlon datasets with the reimplementation of dynUNet in MONAI.
This tutorial shows how to integrate 3rd party transforms into MONAI program. Mainly shows transforms from BatchGenerator, TorchIO, Rising and ITK.
This notebook introduces how to easily load different formats of medical images in MONAI and execute many additional operations.
This notebook illustrates the use of MONAI for training a network to generate images from a random input tensor. A simple GAN is employed to do with a separate Generator and Discriminator networks.
This notebook shows the GanTrainer
, a MONAI workflow engine for modularized adversarial learning. Train a medical image reconstruction network using the MedNIST hand CT scan dataset. Dictionary version.
This notebook shows the GanTrainer
, a MONAI workflow engine for modularized adversarial learning. Train a medical image reconstruction network using the MedNIST hand CT scan dataset. Array version.
This tutorial shows how to leverage EnsembleEvaluator
, MeanEnsemble
and VoteEnsemble
modules in MONAI to set up ensemble program.
Illustrate reading NIfTI files and iterating over image patches of the volumes loaded from them.
This tutorial shows how to train 3D segmentation tasks on all the 10 decathlon datasets with the reimplementation of dynUNet in MONAI.
This notebook shows the usage of several post transforms based on the model output of spleen segmentation task.
This notebook shows how to quickly set up training workflow based on MedNISTDataset
and DecathlonDataset
, and how to create a new dataset.
This notebook demonstrates the image transformations on histology images using the GlaS Contest dataset.