MONAI: The PyTorch-Based Framework for Medical Imaging AI

Jul 10, 2025

Introduction

Developing deep learning models for healthcare is notoriously difficult due to the unique geometry, physics, and privacy requirements of medical data. MONAI (Medical Open Network for AI) is an open-source framework that solves these challenges by providing a domain-specific toolkit built on top of PyTorch. With thousands of stars on GitHub and widespread adoption by researchers and clinicians, MONAI transforms the way medical AI is built, trained, and deployed, replacing the need for developers to write complex, error-prone preprocessing pipelines from scratch.

What Is MONAI?

MONAI is a PyTorch-based, open-source framework for deep learning in healthcare imaging that serves as a standardized foundation for the medical AI community. It is maintained by a consortium including NVIDIA, King’s College London, and the National Institutes of Health (NIH), and is licensed under the Apache License 2.0.

The framework is designed to handle the specificities of medical imaging, such as multi-dimensional data (2D, 3D, 4D), specialized file formats like DICOM and NIfTI, and the need for high-precision transformations. By extending PyTorch, MONAI provides a high-level interface for the entire medical AI lifecycle—from data labeling and preprocessing to model training and clinical deployment.

Why MONAI Matters

Before MONAI, medical AI researchers often worked in silos, creating custom, non-reproducible scripts for data loading and augmentation. This led to a “re-invention of the wheel” where every lab implemented its own version of a 3D UNet or a DICOM loader, often with subtle bugs that affected the validity of research results.

MONAI matters because it establishes a common language and a standardized set of tools. It provides optimized, peer-reviewed implementations of networks, losses, and evaluation metrics specifically for medical imaging. This standardization allows researchers to share models via the MONAI Model Zoo and ensures that a model trained in one institution can be reliably reproduced in another.

Furthermore, the framework’s focus on performance—including GPU-accelerated I/O and smart caching—reduces training times from days to hours, making the iterative process of AI development in healthcare significantly more efficient.

Key Features

  • Flexible Pre-processing: Specialized transforms for multi-dimensional medical imaging data, including intensity scaling, orientation normalization, and spatial transforms.
  • Domain-Specific Implementations: Pre-built, optimized versions of networks (e.g., UNet, SegResNet), loss functions, and evaluation metrics tailored for healthcare imaging.
  • Compositional & Portable APIs: Modular design that allows for easy integration into existing PyTorch workflows without requiring a complete rewrite of the codebase.
  • Multi-GPU/Multi-Node Support: Native support for data parallelism across multiple GPUs and nodes, enabling the training of massive 3D volumes that would otherwise exceed single-GPU memory.
  • MONAI Label: An intelligent image labeling tool that uses AI assistance to accelerate the annotation of new medical datasets.
  • MONAI Deploy: An App SDK that enables developers to package AI models into MAP (MONAI Application Package) containers for seamless integration into clinical IT networks (DICOM, HL7, FHIR).
  • MONAI Model Zoo: A centralized repository of pre-trained models in the MONAI Bundle format, allowing researchers to start from a state-of-the-art baseline.
  • C++/CUDA Optimized Modules: Experimental but high-performance implementations of heavy computations like Resamplers and Conditional Random Fields (CRF) to maximize throughput.

How MONAI Compares

Feature MONAI TorchIO SimpleITK
Primary Focus End-to-End Medical AI Lifecycle Preprocessing & Augmentation Image Processing & Registration
PyTorch Integration Native / Deep Native / Deep External / Wrapper
Model Zoo Yes (Bundles) No No
Clinical Deployment Yes (Deploy SDK) No No
3D Volume Support Comprehensive Comprehensive Comprehensive

While TorchIO and SimpleITK are exceptional tools, they serve different purposes. SimpleITK is a powerful library for traditional image processing and registration, but it lacks the deep learning training loop integration found in MONAI. TorchIO is highly specialized for the efficient loading and augmentation of 3D medical images, often acting as a complementary tool that can be used alongside MONAI to handle extremely large datasets that exceed memory limits.

MONAI’s primary differentiator is its scope. It is not just a preprocessing library; it is a full-stack framework. By providing everything from the labeling tool (MONAI Label) to the deployment SDK (MONAI Deploy), it bridges the gap between a research prototype and a clinical application. For developers who need a standardized, reproducible way to build a medical AI pipeline, MONAI is the industry standard.

Getting Started: Installation

MONAI can be installed via several methods depending on your environment and whether you need the experimental C++/CUDA extensions.

Standard Installation

The simplest way to install the current stable release is via pip:

pip install monai

Installation with Optional Dependencies

To install MONAI with specific support for common medical imaging libraries like Nibabel and Scikit-image, use the extras syntax:

pip install "monai[nibabel,skimage]"

Docker Installation

For those who want a pre-configured environment with GPU support and the latest dev branch, the official Docker image is available on DockerHub:

docker run --gpus all --rm -ti --ipc=host projectmonai/monai:latest

Editable Installation (for Contributors)

If you plan to modify the source code, clone the repository and install it in editable mode:

git clone https://github.com/Project-MONAI/MONAI.git
cd MONAI/
python setup.py develop

Prerequisites: MONAI requires a supported version of Python and depends directly on NumPy and PyTorch. Ensure you have the correct PyTorch version installed for your CUDA version before installing MONAI.

How to Use MONAI

The basic workflow in MONAI typically involves defining a series of transforms, creating a dataset, and then training a model using a PyTorch-style training loop. Because MONAI is compositional, you can use its components in any PyTorch project.

The most common starting point is the Compose transform. This allows you to chain together multiple preprocessing steps—such as loading the image, ensuring the channel dimension is first, and scaling the intensity—into a single pipeline. This pipeline is then passed to a Dataset object, which applies these transforms to the data as it is loaded.

If you are using a model from the Model Zoo, you can leverage the MONAI Bundle format,AI-driven workflows that allow you to load a pre-trained model and its configuration in a single command, significantly reducing the setup time for inference or fine-tuning.

Code Examples

Below are examples of how to implement a basic medical imaging pipeline using MONAI. These examples are simplified versions of the official tutorials.

Basic Preprocessing Pipeline

This snippet shows how to define a medical-specific transformation pipeline for a 2D image classification task.

from monai.transforms import Compose, LoadImaged, ResizeD, ScaleIntensityD, EnsureChannelFirstD
from monai.data import Dataset, DataLoader

# Define the transformation pipeline
trains = Compose([
    LoadImaged(keys=["image"]),
    EnsureChannelFirstD(keys=["image"]),
    ResizeD(keys=["image"], spatial_size=(224, 224)),
    ScaleIntensityD(keys=["image"]),
])

# Mock dataset
data_list = [{"image": "path/to/image1.nii.gz", "label": 0}, {"image": "path/to/image2.nii.gz", "label": 1}]

# Create the dataset and loader
 train_ds = Dataset(data=data_list, transform=trains)
 train_loader = DataLoader(train_ds, batch_size=4, shuffle=True)

In this example, LoadImaged handles the medical file format, EnsureChannelFirstD ensures the data is in the correct format for PyTorch, and ScaleIntensityD normalizes the pixel values, which is critical for medical scans.

3D Segmentation Model Setup

This snippet demonstrates how to initialize a medical-optimized UNet for 3D segmentation.

from monai.networks.nets import UNet
import torch

# Initialize a 3D UNet
model = UNet(
    spatial_dims=3,
    in_channels=1,
    out_channels=2,
    channels=(16, 32, 64, 128, 256),
    strides=(2, 2, 2, 2),
    num_res_units=2,
)

# Move model to GPU
model = model.to("cuda")

The spatial_dims=3 argument tells MONAI to create a 3D version of the network, which is essential for volumetric data like CT or MRI scans.

Real-World Use Cases

MONAI is used across radiology, oncology, and cardiology to automate the analysis of medical images. Here are a few concrete scenarios where the framework shines:

  • Organ Segmentation in CT Scans: A radiology team can use MONAI’s pre-built UNet and Spleen dataset transforms to automatically delineate the boundaries of organs, reducing the manual labeling time for clinicians.
  • Disease Detection in X-Rays: An AI research group can implement a binary classification model (e.g., Normal vs. Pneumonia) using a pre-trained DenseNet from the Model Zoo, fine-tuning it on a small, specialized dataset.
  • Interactive Labeling with MONAI Label: A clinical researcher can use MONAI Label to start an AI-assisted labeling session. The AI suggests segmentations, the clinician corrects them, and the model is re-trained in real-time, creating a high-quality ground truth dataset.
  • Clinical Deployment via MONAI Deploy: A hospital’s IT department can package a trained segmentation model into a MAP container and integrate it into their PACS (Picture Archiving and Communication System) using DICOM orchestration, allowing the model to run as part of a clinical workflow.

Contributing to MONAI

MONAI is a community-driven project. If you are a developer or researcher, you can contribute to the core framework, the tutorials, or the research contributions repository.

To get started, look for GitHub issues labeled good first issue or Contribution wanted. The project follows a strict contribution process to ensure code quality and reproducibility. New contributions should be created as draft pull requests early in the development cycle to allow for the community to track progress. All contributions must follow the project’s American English spelling conventions (e.g., normalize instead of normalise).

For those who have published research, the research-contributions repository is a fast track for sharing the official implementation of a peer-reviewed paper using MONAI components, providing visibility to the rest of the community.

Community and Support

MONAI has a robust support ecosystem. Technical discussions and bug reports are handled through GitHub Discussions and the GitHub Issue Tracker. For real-time collaboration and chat, the community uses a Slack Channel.

Learning materials are extensive. The official MONAI Tutorials repository contains a large collection of Jupyter Notebooks that cover everything from basic transforms to advanced distributed training. The MONAI YouTube Channel provides archived bootcamps and walkthrough guides for new users.

The project is also supported by the launcing partners like NVIDIA and King’s College London, ensuring that the framework remains a state-of-the-art tool for healthcare imaging AI.

Conclusion

MONAI is the definitive framework for anyone building AI for medical imaging. By providing a domain-specific extension of PyTorch, it eliminates the redundant effort of building preprocessing pipelines and model architectures from scratch. Its comprehensive nature—covering labeling, training, and deployment—makes it the right choice for researchers who want to move from a prototype to a clinical application.

Whether you are a data scientist specializing in healthcare or a clinician-developer, MONAI provides the standardized tools needed to ensure that medical AI is safe, reproducible, and robust. Star the repo, try the quickstart, and join the community to start building the next generation of healthcare imaging AI.

What is MONAI and what problem does it solve?

MONAI (Medical Open Network for AI) is a PyTorch-based open-source framework specifically designed for deep learning in healthcare imaging. It solves the problem of non-standardized, non-reproducible preprocessing pipelines and model architectures in medical AI, providing a domain-specific toolkit that handles the unique requirements of 3D medical data and DICOM/NIfTI formats.

How do I install MONAI?

The fastest way to install MONAI is via pip using the command pip install monai. For users who need specific dependencies like Nibabel or Scikit-image, they can use pip install "monai[nibabel,skimage]", or use the official Docker image projectmonai/monai:latest for a pre-configured GPU environment.

How does MONAI compare to TorchIO?

While both are built on PyTorch, MONAI is a full-stack framework covering the entire AI lifecycle from labeling (MONAI Label) to deployment (MONAI Deploy), whereas TorchIO is a specialized library focused primarily on the efficient loading and augmentation of 3D medical images.

Can I use MONAI for 2D X-ray classification?

Yes, MONAI supports both 2D and 3D imaging. It provides specialized transforms and networks that can be configured for 2D tasks, such as using a 2D DenseNet or ResNet for chest X-ray classification.

Is MONAI free for commercial use?

Yes, MONAI is licensed under the Apache License 2.0, which allows for both personal and commercial use of the framework and its pre-trained models.

What is the MONAI Model Zoo?

The MONAI Model Zoo is a centralized repository of pre-trained models in the MONAI Bundle format, which allows researchers to share and reproducible results by providing the model weights, configuration, and training hyperparameters.

What is MONAI Label?

MONAI Label is an intelligent image labeling tool that uses AI assistance to accelerate the annotation process by suggesting segmentations, which clinicians can then refine, followed by active-learning based re-training of the model.

[/et_pb_column] [/et_pb_row]