How to use Deep Learning for Medical Imaging using MONAI and Pytorch

What My Brother and I Learned Applying Deep Learning to Solve Medical Imaging Problems in the Healthcare Industry

Nour Islam Mokhtari
3 min readJul 18, 2022

Medical Imaging

image from Unsplash

We’ve all had to do some type of medical scan at some point in our lives. Some known types of scans include but not limited to :

  • Computed tomography (CT scanner).
  • Magnetic resonance imaging (MRI scanner).
  • Positron emission tomography (PET scanner).
  • Ultrasound scanner.

Using these scans, many companies and startups are trying to build models to extract insights and help both doctors and patients make better informed decisions.

Many of these models are currently being built using deep learning.

Deep Learning for Medical Imaging

Deep learning has revolutionized the field just like it did with many other fields. Many applications seemed extremely difficult, borderline impossible before deep learning.

Below is a figure that showcases some of the medical imaging tasks that were enabled by deep learning.

image from paper [1]

From left to right:

  1. Mammographic mass classification.
  2. Segmentation of lesions in the brain.
  3. Leak detection in airway tree segmentation.

To address these problems, many different approaches are used ranging from pure classification models to object detection models to image segmentation models.

Examples of neural networks used for these tasks:

  • InceptionV5 and VGG16 : CNN models for image classification.
  • U-Net : a semantic segmentation architecture that uses an encoder-decoder paradigm.
  • Mask-RCNN : an instance segmentation architecture that’s an extension of Faster-RCNN.
  • YOLOv5 : an object detection architecture based on one-stage paradigm.

MONAI : A Pytorch based DL framework

image from MONAI website

MONAI is one of the leading frameworks for addressing medical imaging problems. It stands for : Medical Open Network for Artificial Intelligence.

It’s in fact an umbrella of a set of tools that you can use to develop deep learning models for medical imaging. Some of these tools are :

  • MONAI Core : A PyTorch-based, open-source framework for deep learning in healthcare imaging used to create state-of-the-art, end-to-end training workflows.
  • MONAI Label : An intelligent open-source medical image labeling and learning tool that enables you to create annotated datasets and build AI annotation models quickly.
  • MONAI Deploy : A framework and associated tools to design, verify and analyze the performance of AI-driven applications in the healthcare domain.

Example of MONAI workflow

Data labeling

You can use MONAI to build full AI systems for the healthcare industry. Just like with any deep learning project, you would start by collecting and labeling data. MONAI Label can help you do that.

The figure below shows an example of using MONAI Label to label some 3D NIFTII images.

image from MONAI github repo

Building and training your model

Depending on the type of task that you’re trying to tackle, MONAI has many different architectures that are prebuilt and that you can use in your program.

MONAI is based on Pytorch framework so your programs will follow similar patterns as programs used with pure Pytorch. Below is a sample code that shows the training loop in a MONAI.

code from MONAI github repo

Deploying your model

MONAI has a tool for deploying deep learning models easily, it’s called MONAI Deploy. It basically creates a Docker image around your deep learning model. To create such an image, a simple command is used :

code from MONAI Deploy website

Then to test your model from within the Docker image, you can do something like this:

code from MONAI Deploy website

References

[1]​ GeertLitjens et al. “A survey on deep learning in medical image analysis”

[2] https://docs.monai.io/

Is your company or organization looking to build full Deep Learning pipelines for Medical Imaging?

Then contact us at: contact@pycad.co

--

--

Nour Islam Mokhtari

Machine Learning and Computer Vision Engineer | Newsletter for ML practitioners at: newsletter.aifee.co