Image data

Biomedical Image Analysis in Python

Stephen Bailey

Instructor

Biomedical imaging: more than a century of discovery

$$1895$$

By Wilhelm Röntgen. - [1], Public Domain, https://commons.wikimedia.org/w/index.php?curid=5059748

$$2017$$

By Mikael Häggström - Own work, CC0, https://commons.wikimedia.org/w/index.php?curid=61722886

Biomedical Image Analysis in Python

Course objectives

Image Workflow

Toolbox

  • ImageIO
  • NumPy
  • SciPy
  • matplotlib
Biomedical Image Analysis in Python

Loading images

  • imageio: read and save images
  • Image objects are NumPy arrays.
import imageio
im = imageio.imread('body-001.dcm')

type(im)
imageio.core.Image
im
Image([[125, 135, ..., 110],
       [100, 130, ..., 100],
        ...,
       [100, 150, ..., 100]], 
          dtype=uint8)
Biomedical Image Analysis in Python

Loading images

  • Slice the array by specifying values along each available dimension.
im[0, 0]
125
im[0:2, 0:2]
Image([[125, 135],
       [100, 130]], 
       dtype=uint8)
Biomedical Image Analysis in Python

Metadata

  • Metadata: the who, what, when, where and how of image acquisition

  • Accessible in Image objects through the meta dictionary attribute

im.meta
im.meta['Modality']
im.meta.keys()
Dict([('StudyDate', '2017-01-01'),
      ('Modality', 'MR'),
      ('PatientSex', F),
      ...
      ('shape', (256, 256)])
'MR'
odict_keys(['StudyDate', 
            'SeriesDate', 
            'PatientSex',
             ...
             'shape'])
Biomedical Image Analysis in Python

Plotting images

  • Matplotlib's imshow() function displays 2D image data

  • Many colormaps available but often shown in grayscale (cmap='gray')

  • Axis ticks and labels are often not useful for images

import matplotlib.pyplot as plt

plt.imshow(im, cmap='gray')
plt.axis('off')
plt.show()

coronal-slice

Biomedical Image Analysis in Python

Let's practice!

Biomedical Image Analysis in Python

Preparing Video For Download...