Saturday, 20 December 2014

Medical Image Analysis IPython Tutorials

As the Christmas break approaches and the Autumn term will soon be over, I am glad that I've been given the opportunity to feature on this blog the teaching material for the course Medical Image Computing that was newly introduced this year at Imperial College. This course, taught by Prof. Daniel Rueckert and Dr. Ben Glocker, aims to provide MSc students with the necessary skills to carry out research in medical image computing: visualisation, image processing, registration, segmentation and machine learning. The lectures were accompanied by tutorials in the form of IPython notebooks developped by Ozan Oktay, using SimpleITK to process medical images in Python and scikit-learn for Machine Learning. These tutorials are made available on github. They provide an introduction to medical imaging in Python that complements SimpleITK's official notebooks.

There are 4 tutorials:
  1. Basic manipulation of medical image, image filtering, contrast enhancement, and visualisation
  2. Image registration, multi-modal registration, Procrustes analysis
  3. EM segmentation and gaussian mixtures models, atlas prior, Otsu thresholding
  4. Machine learning: classification, regression and PCA.

Image registration is the process of aligning images (rigid registration) and warping them (non-rigid registration) in order to compare or combine images. A typical application is a patient being scanned twice at a few months interval and the two scans are registered in order to assess the evolution of a disease. Another application illustrated below (see tutorial 2) is a patient having an MRI and a CT scan, each modality highlighting different characteristics of a patient's anatomy, and a registration process is required before the doctors can overlay both images.

Image registration:
the CT scan (red) and the MRI scan (green) are registered in order to be combined in a single image.

Image segmentation is the process of assigning a label to each pixel in the image, namely giving a name to distinct parts of the image. This can be done manually, semi-automatically where the user initialises and/or correct an automated process, or fully automatically, such as in the gaussian mixture model illustrated below (see tutorial 3). Image registration is a key step for image segmentation methods that use a database of manually segmented images in order to automatically segment a new image. Such a database is called an atlas. For instance, the atlas can provide a spatial prior to guide the segmentation process as in the second part of tutorial 3.

Image segmentation:
the MR image has been automatically labelled into 4 classes using a gaussian mixture model: white matter (black), grey matter (dark blue), cerebrospinal fluid (light blue) and background (green).

The 4 gaussians that have been fitted to the image data in order to obtain a segmentation are overlayed on the histogram of pixel intensities.

If you would like to know more on medical imaging, a next step could be SimpleITK's official notebooks as well as The ITK Software Guide. If you are looking for images to play with, there is a head MR scan in VTK data and some files that accompany ITK's examples. If you are really motivated, then take a look at some past (or current) MICCAI challenges, download the data and if you are successful at solving the proposed tasks, submit your solutions!


  1. Hello and thanks for the information.
    I tried to check the tutorials but the links don't work.
    Is there a way I can acquire these tutorials?

    Thank you very much,


  2. Hello!
    Does anyone here knows a place where I can find these tutorials? the links are broken :/

  3. ok, I think I found a link with the tutorials that works :)
    Maybe this can save other people some time.

    1. Thanks for your help. I am learning brain tumor segmentation. May I talk about some questions with you? My email:

  4. Thank you for sharing this information.