Voxel-space and World-space#

In the first part of this lesson we are going to be focusing on spatial transformations. We will spend more time discussing this form of image processing as spatial methods are relevant to a much wider variety of analysis steps. Spatial transformations are also where more errors will occur, and so warrant more of our attention.

Data Matrix Indices#

We can conceptualise an MRI image as a 3D matrix (like a big cube), where we can refer to any voxel within the cube using an index along each dimension. Typically we refer to these dimensions as \(x\), \(y\) and \(z\), where \(x\) corresponds to the row, \(y\) corresponds to the column and \(z\) corresponds to the slice. An index into an image is therefore a triplet of values that indicates how far along each of the dimensions we need to travel in order to find the value we want.

As an example, the MATLAB code below shows the process of loading an image (which you can download from here) and then extracting a value using the voxel coordinates \(x = 180\), \(y = 180\) and \(z = 110\). This tells MATLAB that we want to travel \(180\) voxels along the \(x\) dimension, \(180\) voxels along the \(y\) dimension, \(110\) voxels along the \(z\) dimension and then extract the value found at that location.

image = spm_data_read('example_image.nii');
voxel = image(180,180,110)
voxel = 347.0026

Alternatively, we can think of the image more like a stack of cards, where we first extract the matrix at slice \(110\)

slice = image(:,:,110);

and then find the value at row \(180\) and column \(180\)

slice(180,180)
ans = 347.0026

Voxel-space#

The approach of indexing the data matrix directly can be thought of as representing the image in voxel-space. This means that the voxels themselves form the coordinate system. The image dimensions are given in voxels, we index the image using voxel coordinates and the origin of the coordinate system is simply the first voxel saved in the image file.

Perhaps most notable about voxel-space is that the orientation of the image is based on the storage-order of the data on disk. This is usually dictated by the scanner and can differ from image to image. As such, there are no guarantees about which direction in the image correspond to which dimensions of the data matrix. For example, if we display a single slice of the example image we loaded above, we get

figure;
imagesc(image(:,:,110)'); % transpose so x = columns and y = rows
set(gca,'YDir','normal'); % make sure y-axis is bottom -> top
colormap('gray');
_images/894b1e4aa13a5a09c2e6c1ce2c6992a9e558ad162693743f6b5bf4832a221a51.png

Here, we are displaying the \(x\)-axis and \(y\)-axis of the image with the \(z\)-axis fixed at slice 110 (i.e. image(:,:,110)). We orient the image so that the \(x\)-axis runs horizontally and the \(y\)-axis runs vertically. From this, we can see that the \(x\)-axis corresponds to anterior-posterior, the \(y\)-axis corresponds to inferior-superior and the slices through \(z\) run left-right. This goes against the typical convention in neuroimaging, as we will see below, but is entirely determined by how the scanner chooses to collect and save the data.

Fig. 5 gives another example using a functional image displayed in voxel-space. This time, in order to achieve the same orientation as the anatomical example, we have to slice along the \(x\)-axis of the image. As such, the \(x\)-axis is fixed at slice 40, with the \(y\)-axis displayed horizontally and the \(z\)-axis displayed vertically. This highlights not only how the orientation depends upon the storage order, but also how the axes of the display and the axes of the image are two different concepts.

_images/voxel-space-func.png

Fig. 5 Example of a functional slice displayed in voxel-space.#

Voxel-space is the most basic coordinate system we can use with an image and is the only way we can index the actual values inside the data matrix. This means that no matter what we do, we always need to get back to voxel-space eventually. However, this does not mean that we have to work in voxel-space exclusively.

World-space#

As mentioned already, one issue with the voxel-space representation is that we have no correspondence between the dimensions of the data matrix and the different physical directions in an image. For instance, the anatomical example from above had the \(x\)-dimension running anterior-posterior, whereas as the functional example has the \(x\)-dimension running left-right. Another issue is that a voxel is not a standard unit of measurement and can be a variety of sizes depending on the scanning sequence. If you say that an image of an object is 100 voxels wide, that information says nothing about how big that object is in the real world. As such, a coordinate systems based on voxels is only useful when our image processing does not need to know about the physical location of the voxels in space. Generally speaking, most filtering operations can be performed in voxel-space, but any spatial transformations need more knowledge about the physical sizes of voxels as well as the physical interpretation of the image dimensions.

In order to get information about the physical location of a voxel in space, we can convert the voxel coordinates to millimetre coordinates. We will cover how this is done later in the lesson, but for now just note that by doing this we effectively transform the coordinate system of the image into a real-world representation. Traditionally, we consider the \(x\)-dimension to refer to left-right, the \(y\)-dimension to refer to anterior-posterior and the \(z\)-dimension to refer to inferior-superior. The origin of these axes corresponds to the coordinates \(\left[0, 0, 0\right]\), and is usually placed within the brain at a specific anatomical point. This means the coordinates can be considered millimetre shifts relative to the origin. For instance, a negative \(x\) coordinate means the left side of the brain and a positive \(x\) coordinates means the right side of the brain. This is illustrated in Fig. 6.

_images/axis-orientation.png

Fig. 6 Illustration of the interpretation of the axes in world-space.#

This alternative world-space coordinate system is shown in Fig. 7. Compared to the voxel-space image, we can see that the scale of the axes has changed to reflect the fact that, in this image, 1 voxel is equivalent to 3mm. In addition, the origin has been placed in its typical location of the anterior commissure, meaning the coordinate system now has a meaningful anatomical interpretation. For example, the coordinates shown in Fig. 7 can be interpreted as 60mm posterior and 30mm superior to the anterior commissure.

_images/world-space-func.png

Fig. 7 Example of a functional slice displayed in world-space.#

Viewing Different Spaces in SPM#

The video below will introduce the SPM Display facility which can be used to view images in both voxel-space and world-space. Click here to download the example image used in the video.