# Multidimensional image stacks#

Multi-dimensionsal image data data can be handled in a similar way as multi-channel image data.

## Three-dimensional image stacks#

There are also images with three spatial dimensions: X, Y, and Z. You find typical examples in microscopy and in medical imaging. Let’s take a look at an Magnetic Resonance Imaging (MRI) data set:

from skimage.io import imread
from pyclesperanto_prototype import imshow

imshow(image_stack) This MRI dataset looks unusal, because we are looking at a maximum intensity projection. pyclesperanto visualized the three-dimensional image like this. We can quickly check the image size like this:

image_stack.shape

(192, 256, 256)


## Image slicing#

We can inspect individual image slices by specifying them behing our 3D numpy array:

import matplotlib.pyplot as plt
fig, axs = plt.subplots(1, 3, figsize=(15,15))

# show three planar images
axs.imshow(image_stack, cmap='Greys_r')
axs.imshow(image_stack, cmap='Greys_r')
axs.imshow(image_stack, cmap='Greys_r')

<matplotlib.image.AxesImage at 0x7ff660784fd0> As all three dimensions are spatial dimensions, we can also make slices orthogonal to the image plane and corresponding to Anatomical planes. To orient the images correctly, we can transpose their axes by adding .T by the end.

saggital = image_stack[:,:,128].T
coronal = image_stack[:,128,:].T
transverse = image_stack

import matplotlib.pyplot as plt
fig, axs = plt.subplots(1, 3, figsize=(15,15))

# show orthogonal planes
axs.imshow(saggital, cmap='Greys_r')
axs.set_title('Saggital')

axs.imshow(coronal, cmap='Greys_r')
axs.set_title('Coronal')

axs.imshow(transverse, cmap='Greys_r')
axs.set_title('Transverse')

Text(0.5, 1.0, 'Transverse') ## Videos#

If an image dataset has a temporal dimension, we call it a video. Processing videos works similar to multi-channel images and image stacks. Let’s open a microscopy dataset showing yeast cells rounding over time. (Image data courtesy of Anne Esslinger, Alberti lab, MPI CBG)

from skimage.io import imread, imshow

print(video.shape)

(64, 512, 512)

import matplotlib.pyplot as plt
fig, axs = plt.subplots(1, 4, figsize=(15,15))

# show three planar images
axs.imshow(video, cmap='Greys_r')
axs.imshow(video, cmap='Greys_r')
axs.imshow(video, cmap='Greys_r')
axs.imshow(video, cmap='Greys_r')

<matplotlib.image.AxesImage at 0x7ff6607f11f0> ## n-dimensional data#

High-dimensional data are pretty common in microscopy. To process them correctly, one must study carefully what dimensions an image dataset has. We can explore possibilities using the mitosis dataset:

from skimage.io import imread, imshow

print(mitosis.shape)

(51, 5, 2, 196, 171)


Hint: Open the dataset in ImageJ/Fiji to understand what these numbers stand for. You can see there that the mitosis dataset has

• 51 frames,

• 5 Z-slices,

• 2 channels and

• is 171 x 196 pixels large.

We grab now channels 1 and 2 of the first time point (index 0) in the center plane (index 2):

timepoint = 0
plane = 2

channel1 = mitosis[timepoint, plane, 0]
channel2 = mitosis[timepoint, plane, 1]

import matplotlib.pyplot as plt
fig, axs = plt.subplots(1, 2, figsize=(15,15))

axs.imshow(channel1, cmap='Greys_r')
axs.imshow(channel2, cmap='Greys_r')

<matplotlib.image.AxesImage at 0x7ff680c4a850> ## Exercise#

Open the mitosis dataset, select three timepoints and show them side-by-side. The resulting figure should have three columns and two rows. In the first row, channel1 is displayed and the second channel below.