How to Visualize ToothFairy2

Explore the CBCT scans and their 42-class annotations in your browser, in Napari, or straight from Python.

1

In your browser

No installation: rotate a sample volume and toggle each structure right on this page.

2

In Napari

Open any scan with its labels in a fast, interactive desktop viewer for Python users.

3

From Python

Load scans and labels as NumPy arrays with a few lines of SimpleITK code.

In your browser

The viewer below shows a sample ToothFairy2 volume with its annotations. Drag to rotate, scroll to zoom, and use the label list to show or hide single structures such as teeth, canals or sinuses.

Labels

Napari

When dealing with 3D medical volumes you need a tool that lets you explore them interactively. Among the many available, we recommend Napari: it is open source, integrates seamlessly with Python, ships with many helpful features out of the box, and can be extended with plugins.

ToothFairy2 is distributed in the nnU-Net format: every scan is an .mha file in imagesTr/, its annotation has the same name (without _0000) in labelsTr/, and dataset.json maps label values to class names.

The Napari interface

Open a volume in four steps

  1. Install Napari together with the ITK reader plugin, which opens .mha files:
    pip install "napari[all]" napari-itk-io
  2. Launch it by typing napari in a terminal.
  3. Choose File > Open File(s)... and select a scan, e.g. imagesTr/ToothFairy2F_001_0000.mha, and its annotation labelsTr/ToothFairy2F_001.mha.
  4. Napari opens every file as an image. Right-click the annotation layer and choose Convert to Labels to see each class in its own colour.
Converting a layer to labels in Napari

From Python

To work with the data programmatically, read the files with SimpleITK (pip install SimpleITK) and hand the arrays to Napari, keeping the physical voxel spacing:

import json
import napari
import SimpleITK as sitk

root = "Dataset112_ToothFairy2"
case = "ToothFairy2F_001"

scan = sitk.ReadImage(f"{root}/imagesTr/{case}_0000.mha")
labels = sitk.ReadImage(f"{root}/labelsTr/{case}.mha")
spacing = scan.GetSpacing()[::-1]  # (z, y, x) in mm

# label value -> class name, e.g. names[3] == "Left Inferior Alveolar Canal"
names = {v: k for k, v in json.load(open(f"{root}/dataset.json"))["labels"].items()}

viewer = napari.Viewer()
viewer.add_image(sitk.GetArrayFromImage(scan), name="CBCT", colormap="gray", scale=spacing)
viewer.add_labels(sitk.GetArrayFromImage(labels), name="Labels", scale=spacing)
napari.run()

ToothFairy annotator plugin

The ToothFairy annotator plugin in Napari

The volumes of the ToothFairy2 challenge were annotated with our own Napari plugin, designed to visualize and annotate 3D CBCT volumes in the most comprehensive and user-friendly way possible. It is freely available to the medical and research community:

pip install napari-toothfairy-annotator

Source code, issues and updates are on the GitHub repository.

Other viewers

Prefer a stand-alone application? 3D Slicer and ITK-SNAP open .mha files natively: load the scan as a volume and the matching file from labelsTr/ as a segmentation.