Installation

Start using MONAI Label locally and run installlation with your familiar visualization tools. Stable version software represents the currently tested and supported visualization tools with latest release of MONAI Label.

Current Milestone Release of MONAI Label:

MONAI Label Supported Stable Visualization Tools:

Start using MONAI Label with just three steps!

MONAI Label Instllation steps

————— Install MONAI Label ——————– Guide of Visualization Tools ———————— Add Plugins —————–

Install MONAI Label

Prerequisites

MONAI Label supports both Ubuntu and Windows OS with GPU/CUDA enabled.

Make sure you have python 3.8/3.9 version environment with PyTorch and CUDA installed. MONAI Label features on other python version are not verified.

  • Install Python

  • Install the following Python libraries

python -m pip install --upgrade pip setuptools wheel

# Install latest stable version for pytorch
pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113

# Check if cuda enabled
python -c "import torch; print(torch.cuda.is_available())"

On Ubuntu only, python3-dev, which contains the header files for the Python C API, is not bundled with Python and needs to be installed separately.

sudo apt install python3-dev

Install From PyPI

Milestone release

To install the current milestone release:

pip install monailabel

The milestone versions are currently planned and released every few months. As the codebase is under active development, you may want to install MONAI from GitHub for the latest features

From GitHub

To install latest from github main branch

pip install git+https://github.com/Project-MONAI/MONAILabel#egg=monailabel

Note

If you have installed the PyPI release version using pip install monailabel, please run pip uninstall monailabel before using the commands from this section. Because pip by default prefers the milestone release.

This will not build/include OHIF by default. To include OHIF as part of this setup/build, make sure YARN is installed and export OHIF_BUILD=true before running the above command.

From DockerHub

To install latest from DockerHub:

docker run -it --rm --gpus all --ipc=host --net=host -v ~:/workspace/ projectmonai/monailabel:latest bash

MONAI Label CLI

Simple monailabel command will help user to download sample apps, datasets and run server.

monailabel --help

Downloading Sample Apps or Datasets

You can download sample apps and datasets from monailabel CLI.

# Download Sample Apps
monailabel apps # List sample apps
monailabel apps --download --name radiology --output apps

# Download MSD Datasets
monailabel datasets # List sample datasets
monailabel datasets --download --name Task09_Spleen --output datasets

Starting Server

You can start server using monailabel CLI

# Run Deepedit Model.
# Options can be (deepedit|deepgrow|segmentation|segmentation_spleen|all) in case of radiology app.
# You can also pass comma separated models like --conf models deepedit,segmentation

monailabel start_server --app apps/radiology --studies datasets/Task09_Spleen/imagesTr --conf models deepedit

Note

Once you start the MONAI Label Server, by default it will be up and serving at http://127.0.0.1:8000/. Open the serving URL in browser. It will provide you the list of Rest APIs available.

Deployment

MONAI Label Server uses Uvicorn which is a lightning-fast ASGI server implementation. However user can deploy the application in any server that supports ASGI specification

There are multiple choices available for Uvicorn to run as Development Server vs Standalone Server vs Production.

Deploying MONAI Label server for production use is out of project scope.

Run MONAI Label server in ssl mode:

You can run MONAILabel server in https mode. .. code-block:

# Create self-signed ssl cert
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout uvicorn-selfsigned.key -out uvicorn-selfsigned.crt

# Start server in ssl mode
monailabel start_server --app apps/radiology --studies datasets/Task09_Spleen/imagesTr --conf models deepedit --ssl_keyfile uvicorn-selfsigned.key --ssl_certfile uvicorn-selfsigned.crt

However for basic production deployment, you might need to run Uvicorn independently. In such cases, you can following these simple steps.

# dryrun the MONAI Label CLI for pre-init and dump the env variables to .env or env.bat
monailabel start_server --app apps/radiology --studies datasets/Task09_Spleen/imagesTr --host 0.0.0.0 --port 8000 --dryrun

# Linux/Ubuntu
source .env
uvicorn monailabel.app:app \
  --host 0.0.0.0 \
  --port 8000 \
  --log-config apps/radiology/logs/logging.json \
  --no-access-log


# Windows
call env.bat
uvicorn monailabel.app:app ^
  --host 0.0.0.0 ^
  --port 8000 ^
  --log-config apps\radiology\logs\logging.json ^
  --no-access-log

For more options about Uvicorn (concurrency, SSL etc..) refer: https://www.uvicorn.org/#command-line-options

Guide of Visualization Tools

MONAI Label supports the most adopted open-source viewers for Radiology and Pathology

3D Slicer

3D Slicer, a free and open-source platform for analyzing, visualizing and understanding medical image data. In MONAI Label, 3D Slicer is most tested with radiology studies and algorithms, develpoment and integration.

MONAI Label is most currently tested and supported with stable release of 3D Slicer every version. Preview version of 3D Slicer is not fully tested and supported.

To install stable released version of 3D Slicer, see 3D Slicer installation.

Currently, Windows and Linux version are supported.

MITK

The Medical imaging Interaction ToolKit (MITK) is an open source, standalone, medical imaging platform. MONAI Label is partially integrated to MITK Workbench, a powerful and free application to view, process, and segment medical images. The MONAI Label tool in MITK is mostly tested for inferencing using radiology and bundle apps allowing for Auto and Click-based interactive models.

To install MITK, see MITK download.

OHIF (Web-based)

The Open Health Imaging Foundation (OHIF) Viewer is an open source, web-based, medical imaging platform. It aims to provide a core framework for building complex imaging applications.

At this point OHIF can be used to annotate the data in the DICOM server via the MONAI Label server.

To use OHIF web-based application, refer to extensible web imaging platform

QuPath

Quantitative Pathology & Bioimage Analysis (QuPath)

QuPath is an open, powerful, flexible, extensible software platform for bioimage analysis.

To install stable released version of QuPath, see QuPath installation.

Currently, Windows and Linux version are supported. Detailed documentation can be found QuPath Doc

Add Plugins

3D Slicer Plugin

Note

To avoid accidentally using an older Slicer version, you may want to uninstall any previously installed 3D Slicer package.

Install 3DSlicer Preview Version with in-built MONAI Label plugin

  • Download and Install 3D Slicer version 5.0 or later.

  • Start 3DSlicer

  • On the menu bar navigate View -> Extension Manager -> Active Learning -> MONAI Label

    3DSlicer Extensions Manager
  • Install MONAI Label plugin (click “Install”)

  • Restart 3D Slicer (click “Restart” in the same dialog box)

To add the MONAI Label icon shortcut on the 3DSlicer toolbar

  • Navigate Edit -> Application Settings

  • Under the Modules panel drag MONAI Label into Favorite Modules

    MONAI Label Favorite Module
  • Restart 3DSlicer

  • Look for the MONAI Label module icon MLIcon in the 3DSlicer toolbar

Refer 3D Slicer plugin for other options to install and run MONAI Label plugin in 3D Slicer.

MITK Plugin

MITK comes pre-built with the MONAI Label plugin. The tool interface can be found in both MITK’s Segmentation View > 2D tools and also in Segmentation View > 3D tools. As the the name suggests, the hosted MONAI Label app’s 2D models are featured in 2D tools and vice versa. Refer MITK Documentation to know more using MONAI Label in MITK.

OHIF Plugin

MONAI Label comes with pre-built plugin for OHIF Viewer. To use OHIF Viewer, you need to provide DICOMWeb instead of FileSystem as studies when you start the server.

monailabel start_server --app apps/radiology --studies http://127.0.0.1:8042/dicom-web --conf models deepedit

If you have authentication set for dicom-web then you can pass the credentials using environment variables while running the server.

export MONAI_LABEL_DICOMWEB_USERNAME=xyz
export MONAI_LABEL_DICOMWEB_PASSWORD=abc
monailabel start_server --app apps/radiology --studies http://127.0.0.1:8042/dicom-web --conf models deepedit

If you are using only OHIF, it is recommended to disable DICOM to NIFTI conversion for faster performance.

export MONAI_LABEL_DICOMWEB_CONVERT_TO_NIFTI=false
monailabel start_server --app apps/radiology --studies http://127.0.0.1:8042/dicom-web --conf models deepedit

Note

Please install Orthanc before using OHIF Viewer.

For Ubuntu 20.x, Orthanc can be installed as apt-get install orthanc orthanc-dicomweb. However, you have to upgrade to latest version by following steps mentioned here

You can use PlastiMatch to convert NIFTI to DICOM

OHIF Viewer will be accessible at http://127.0.0.1:8000/ohif/

QuPath Plugin

For pathology usecase, you can install QuPath and basic monailabel extension in QuPath. You can download sample whole slide images from https://portal.gdc.cancer.gov/repository

# start server using pathology over downloaded whole slide images
monailabel start_server --app apps/pathology --studies wsi_images

Refer QuPath Plugin for installing and running MONAILabel plugin in QuPath.

Digital Slide Archive (DSA)

If you have DSA setup running, you can use the same for annotating Pathology images using MONAILabel.

# start server using pathology connecting to DSA server
monailabel start_server --app apps/pathology --studies http://0.0.0.0:8080/api/v1

Refer DSA Plugin for running a sample pathology use-case in MONAILabel using DSA.