Visualize and Examine 3D Medical Images for Machine Learning Using ITK-SNAP

Mansi Parashar
Geek Culture
Published in
5 min readJan 28, 2021

--

There is a steep increase in the use of Machine Learning and Deep Learning techniques in Healthcare, especially in terms of using Medical Images like CT Scans, MRI Scans, PET Images to train algorithms for diagnosis prediction, ROI segmentation, and much more.

Before choosing the algorithm and building the model, one must be familiar with the data they are working with. Commonly, Medical data is obtained in NIfTI (.nii), or DICOM (.DCM) file format. 3D Images are difficult to visualize as compared to 2D images, and also contain metadata that can be extracted.

ITK-SNAP is one of the most popular tool to work with 3D Medical Images and supports majority of the file formats. It is free, open-source, and multi-platform.

Fig 1 : Visualization with ITK Snap [source]

SETTING UP ITK-SNAP

To work with ITK-SNAP, install the latest version from here. Choose the version according to your OS. After it is successfully installed, open the application.

Fig 2 : ITK-SNAP Installation

Next step would be uploading your 3D image to ITK-SNAP.

In this example, we use a COVID-19 affected lung CT Scan. You can download the NIfTI(.nii.gz) image from here. Because of their large size, they are usually available in the compressed form. ITK can automatically extract the NifTI file(.nii) from the compressed (.nii.gz) format.

UPLOADING A 3D IMAGE

  1. Open the image by
  • Using keyboard shortcut CTRL+G .
  • Navigating via File -> Open Main Image.
  • Directly using the “Open Image” button in the bottom right.
Fig 3: ITK-SNAP landing page

2. Browse the image on your local computer and press next. The format will be recognized automatically, however it can be adjusted if required.

Fig 4 : Selecting Image

3. You will be navigated to the Image Summary page. This gives us crucial information along with the image metadata.

Fig 5 : Image Summary

4. Once you go through the image information, click Finish. A window like one shown below will appear.

Fig 6 : 3D Visualization of Lung CT Scan

INTERPRETING THE VISUALIZATION

Now comes the interesting part. A 3D representation of an object is built by a collection of 2D slices acquired along an axis, close to each other.

  • Voxels : Every pixel in a slice represents the light intensity collected from a small volume: pixels become voxels.
  • Volume : A volume (3D) image, represents a physical quantity as a function of three spatial coordinates. In a digital volume image, each sample (voxel) represents this quantity measured at a specific location.
  • Slice : The image is made by a spatial sequence of 2D slices that include the object of interest. A slice is represented as an image matrix of pixels (X and Y coordinates). The slice number indicates the Z-coordinate.

In ITK-SNAP, as you can see from Fig 6, 4 panels are shown for each Volume.

  • Three of these panels show orthogonal slices through an image.
  • The fourth one, located at bottom left, shows the three-dimensional view of the segmentation.

Let’s focus our attention on the the slice windows. The three slice windows display three views of the image volume, in the orthogonal axial, coronal, and sagittal planes.

Notice that a scrollbar is located next to each slice window. Under each scrollbar is located a slice counter, which shows the index of the displayed slice and the total number of slices in the direction perpendicular to the slice.

  • Axial Plane: Also known as the transverse or horizontal planes, are parallel to the ground and divide the body into top and bottom parts. They are x-z planes.
Fig 7: Axial view of Lung
  • Sagittal Plane : Also known as the lateral plane, divides the body into left and right halves and is an y-z plane. That is, the sagittal plane goes right through the middle between the body’s left and right halve.
Fig 8: Sagittal view of Lung
  • Coronal Plane: Also the frontal plane, divides the body into front and back (also called dorsal and ventral or posterior and anterior) sections and are x-y planes.

The views are linked, navigating in one window also adjusts the corresponding positions in the other windows, giving a seamless experience.

In case your dataset provides you with masks or labels, they can be overlaid on the 3D scan and visualized appropriately. For example, you can download the airway label for our CT Scan from here.

Go to Segmentation -> open segmentation, browse and select your mask. If the mask is for the image in the workspace, the dimensions must be same. After confirming, the segmentation can be clearly visualized in the same workspace.

Fig 10 Segmented Trachea in all 3 views

In conclusion, ITK-SNAP helps us understand and explore the 3D data we are working with and aids the decision making process. If the task is of segmentation, generated masks can be tested using ITK-SNAP to see if the required Region of Interest is segmented appropriately.

--

--