Spatial processing

You can click here download two sample programs that demonstrate some of the common spatial processing for neuroimaging. These concepts are describe in my neuroimaging lectures.

Spatial Transformations

During MRI analysis, we often coregister our images – i.e. we will warp different images to look similar to each other. In particular, we will need to conduct two types of coregistration – motion correct (where the series of fMRI images are aligned to adjust for the participant moving their head during the scanning) and normalization (where we align images from different people to allow group inferences to be made). Regardless of whether you are using SPM, FSL’s FLIRT or another tool, much of the coregistration is done by applying a linear spatial transformation matrix to warp the images. This transformation matrix can encode rotations, translations, zooms (streching or shrinking) and shear transforms. My simple demo allows you to see how a single matrix can encode multiple linear transformations. Note the sample software allows you to manipulate a 2D image (using a 3×3 matrix), while FLIRT manipulates 3D images (using a 4×4 matrix), but the prinicples are identical. The demo also allows you to see the influence of nearest neighbor, linear and sinc interpolations (FSL uses a windowed sinc filter, while SPM uses higher-order b-splines for similar high-quality filtering).

Affine Transforms

Spatial Smoothing

fMRI data is typically smoothed before we compute statistics. By blurring the data, we can eliminate high frequency noise, and ensure that our data is relatively normaly distributed. In neuroimaging, we classically apply a 3D gaussian smooth, where we adjust the Full Width Half Maximum. My demo software allows you to interactively apply a gaussian smooth to a 2D bitmap image. You can interactively adjust the FWHM (defined in pixels). The program initially displays a white rectangle on a black background, but you can load any image you wish. The source image is shown in the upper left, and the smoothed output is shown in the upper right corner. The lower images show image intensity histograms along the middle line of the source and smoothed images. Note that with a large smoothing kernel you can not distinguish the broad-low contrast left side of the rectangle from the narrow high contrast right side. This demonstrates why it is difficult to determine if smoothed fMRI activation shows recruitment of a larger area of cortex or whether it reflects more activation within the same region of cortex.

The pull-down menu allows you to choose different image processing functions: blurring, fisheye effect, intensity gradient, gaussian noise, and median filtering. For most of these functions, adjusting the number shown on the upper left of the window influences adjusts how extreme these functions are.

The “Open BMP” button allows you to change the source image. The “Copy” button copies the destination image to the clipboard, and the “Save” button saves the destination image as a bitmap image.

Smooth Demo