## Prerequisites

Before starting this lesson, you should be familiar with:

## Learning Objectives

After completing this lesson, learners should be able to:
• Describe the different dimensions image data can have.

• View and slice images in different dimensions.

## Motivation

Apart from the X and Y dimensions, visible in the width and height of an image, image data can have additional dimensions. The most common additional dimensions include:

• the Z dimension, providing depth to image data,
• different channels, showing data recorded with different detectors or detector settings,
• the time dimension. Viewing such multi-dimensional data is challenging, because a computer monitor can only render a (multi-color) 2D representation of such data. Thus it is important to learn how to efficiently visualise subsets (“slices”) of such high-dimensional data.

## Concept map

graph TD ND("N-dimensional image") --> S("Slice") S --> M("2D image")

## Figure

The word ‘slice’ is often used in different ways. The different ‘layers’ in the z-dimension are referred to as z-slices. Slicing (or subsetting) image data means that part of the image data is selected and ‘sliced out’ to form a new image. This can include selecting one or more dimensions, or just part of a dimension, for example selecting slice 6-12 of the Z-dimension. You can also rotate the data in one of the spatial dimensions and resample the data set to see that data from a different angle, which is sometimes referred to as ‘reslicing’.

## Activities

• Open the 3D image xyz_8bit__chromsomes.tif.
• The data shows chromosomes wrapped around a spherical(!) nucleus; i.e. the data should look similar from all directions.
• View (slice) the data in XY, YZ, and XZ.
• Observe that the image is calibrated.
• Observe that the rendering in XZ and YZ is deformed with without taking the calibration into account.
• Open the 3D multi-channel image xyzc_8bit_beads_p_open.tif.
• Explore different options for rendering the channel dimension (e.g. gray-scale, color, composite).
• View the properties of this image. Are the XYZ dimensions isotropic or anisotropic?
• Subset the data such that a new image is created that contains only the green channel.
• Reslice the green channel, such that the bead is shown from the side.
• Explore different options of dealing with the anisotropy.

Show activity for:

## ImageJ GUI

• Open the 3D image xyz_8bit__chromosomes.tif.
• Slice the data in along x, y or z using [ Image > Stacks > Orthogonal Views ] or [Ctrl-Shift-H].
• Explore the effect of wrong calibration:
• Open image properties: [ Image > Properties… ] or [Ctrl-Shift-P].
• Change all dimensions to `1 pixel`.
• Observe that the cell now appears as an oval in the `Orthogonal Views`.
• Reopen the image in order to have the correct calibration.
• Slice the data at arbitrary angles using [Plugins > BigDataViewer > Open Current Image]
• `Shift-X/Y/Z`: slice along x,y,z.
• `Left button drag`: slice along arbitray plane
• `I`: toggle interpolation
• Open the 3D multi-channel image xyzc_8bit_beads_p_open.tif.
• Use the sliders to explore different dimensions in the data.
• Use [ Image > Adjust > Brightness/Contrast…] to adjust the display settings of the individual channels.
• Explore different viewing modes, using [ Image > Color > Channels Tool… ].
• Explore the voxel dimensions, using [ Image > Properties… ] or [Ctrl-Shift-P].
• Observe that the voxel dimensions are anisotropic.
• Crop out the green bead (i.e. “subset” the data).
• Select the rectangular selection tool and draw an ROI around the green bead.
• Duplicate the selection, using [ Image > Duplicate ] or [Ctrl-Shift-D].
• `Duplicate hyperstack`
• `Channels: 1`
• `Slices: 15-25`
• Create a side view of the green bead:
• [ Image > Stacks > Reslice] or press / to open the reslice menu.
• Select `Top`
• Click `OK`.
• Explore and understand the different parameters:
• `Left/Right/Top/Bottom`… as if looking from that direction onto the stack on your screen (e.g., `Top` does not mean to look on the stack from the top as in along the z-direction).
• `Output spacing`: the spacing of the pixels along the slicing direction.
• `avoid interpolation`
• uncheck this in order to apply the `output spacing` and create new pixel by interpolation.
• check this to ignore the output spacing argument and keep the original pixels.

### Additional information (move to main text?)

Since the voxels dimensions are anisotropic in this data set, reslicing it would yield rectangular pixels. However, on your screen pixels always appear as squares. Therefore there are two options:

• new pixels are added by interpolation to keep the proportions such that they follow the calibration of the image.
• the pixels are kept the same, but we keep in mind that the voxel size is larger in one dimension than in the other (this is stored in the calibration metadata)

With the ‘avoid interpolation’ box NOT selected, the resliced output of a calibrated image will contain new pixels (calculated by interpolation), such that the XYZ proportions in the image follow the image XYZ calibration. However, the resliced output image no longer contains the exact same pixels as the input image, and reslicing it back will give you a slightly different image than the input image that you started with. If you select the ‘avoid interpolation’ box, the output image will have the same number of pixels as the input image. In this case, reslicing it back again will return the exact same input image that you started with. However, the proportions that you see on your screen do not reflect the ‘real’ physical proportions that the original object had.

## Exercises

Show exercise/solution for:

## ImageJ GUI

• Are the voxels in this data isotropic or anisotropic?
• Reslice the image from different directions, such that you can view the image stack from the side, from the top, and from the front.

## Solution

• Use [Image > Properties ] to view the voxel dimensions. In this case the voxels are isotropic (pixel width = pixel height = voxel depth).
• [Image > Stacks > Reslice [/]…] or press / opens the Reslice menu.
• Select ‘Top’ in the ‘Start at:’ drop-down menu to reslice the image from the top and view the head from above.
• Select ‘Left’ in the ‘Start at:’ drop-down menu to reslice the image from the left and view the head from the front.

## ImageJ Macro

• Open the multidimensional image xyz_16bit_t1-head.tif.
• Reslice the image from different directions, such that you can view the image stack from the side, from the top, and from the front.
• How do you think one could see the head from 3/4 view? Tip: there is a function called ‘rotate’ in ImageJ ([Image > Transform > Rotate]).

## Solution

``````// This macro opens the head image stack and reslices it to view it from different angles (side, top, front, and 3/4 view)
// Close other open images
run("Close All");

// Reslice the head image stack to view the head from the top and from the side
run("Reslice [/]...", "output=1.500 start=Top"); // view head from the top
run("Reslice [/]...", "output=1.500 start=Left"); // view head from the front

// Rotate the head stack that is viewed from the top and reslice to obtain 3/4 view
run("Duplicate...", "duplicate");
run("Rotate... ", "angle=45 grid=1 interpolation=Bilinear enlarge stack"); // rotate the stack
run("Reslice [/]...", "output=1.500 start=Top");

run("Tile");
``````

## ImageJ Jython

• Open the multidimensional image xyz_16bit_t1-head.tif.
• Reslice the image from different directions, such that you can view the image stack from the side, from the top, and from the front.
• How do you think one could see the head from 3/4 view? Tip: there is a function called ‘rotate’ in ImageJ ([Image > Transform > Rotate]).

## Solution

``````# This jython script opens the head image stack and reslices it to view it from different angles (side, top, front, and 3/4 view)

# import classes
from ij import IJ
from ij.plugin import Slicer

# Close other open images
IJ.run("Close All")

# Reslice the head image stack to view the head from the top and from the side
IJ.run(head, "Reslice [/]...", "output=1.500 start=Left rotate") # view head from the front

# Rotate the head stack that is viewed from the top and reslice to obtain 3/4 view
IJ.run(head_top2, "Rotate... ", "angle=45 grid=1 interpolation=None enlarge stack") # rotate the stack

IJ.run("Tile")
``````

## Assessment

### Fill in the blanks

1. A set of 2D ____ placed on top of each other form a 3D ____.
2. An ____ voxel size can cause the image to appear ____ when viewing it at an angle.

## Solution

1. 2D slices placed on top of each other from a 3D stack.
2. An anisotropic voxel size can cause the image to appear deformed when viewing at a certain angle.

### True or False

1. Isotropic image data has voxels of equal XYZ dimensions.
2. Slicing is the process of sectioning the data, that has more than two dimensions, along defined axes and dimensions.
3. Reslicing is a term used to indicate repeated slicing.
4. Images can have 5 dimensions.

## Solution

1. True
2. True
3. False - Typically, the term reslicing refers to resampling volumetric data from a different direction, such that the resulting image stack is a rotated version of the original stack.
4. True - If we denote width by `x`, height by `y`, depth by `z`, time by `t` and channel by `c`, we could have images with dimensions such as: [`xy` -> 2D], [`xyz` -> 3D, `xyt` -> 3D: 2D time-lapse, `xyc` -> 3D: 2D multi-channel], or [`xyzt` -> 4D: 3D time-lapse, `xyzc` -> 4D: 3D multi-channel], or [`xyztc` -> 5D: 3D time-lapse multi-channel]

## Follow-up material

Recommended follow-up modules: