2009 Blair Bohannan: Difference between revisions
imported>Psych 204 No edit summary |
imported>Psych 204 No edit summary |
||
| Line 38: | Line 38: | ||
== Cell III. Artifact 1: DC offset == | == Cell III. Artifact 1: DC offset == | ||
The DC offset is a constant, positive shift in amplitude. It results in a large peak at frequency zero. This can be derived from the equation for the DFT. Given that the DFT is defined as | The DC offset is a constant, positive shift in amplitude. It results in a large peak at frequency zero. This can be derived from the equation for the DFT. Given that the DFT is defined as | ||
:<math>X_k=\sum_{n=0}^{N-1} x_n e^{-frac{j 2 \pi}{N} k n}\quad \quad k = 0, \dots, N-1 </math> | :<math>X_k=\sum_{n=0}^{N-1} x_n e^{-\frac{j 2 \pi}{N} k n}\quad \quad k = 0, \dots, N-1 </math> | ||
Revision as of 08:23, 9 December 2009
Back to Psych 204 Projects 2009
Project Title - MATLAB image processing tutorial
This page accompanies a MATLAB tutorial which simulates some artifacts that might be found in MR images. Their causes, and in some cases corrections, are demonstrated in the code. One- and two-dimensional examples are provided.
Image artifacts in this tutorial include DC Offset, Quadrature Ghosting, RF Noise, Gradient, and Frequency-Sampling Jitter. Information on the first four topics can be found in Hornak, Joseph P. The Basics of MRI, Chapter 11. More information on the mathematical derivations can be found in Smith, Julius O. Mathematics of the Discrete Fourier Transform (DFT). A full reference list can be found at the end of this page.
About the tutorial
This tutorial consists of a MATLAB (.m) script and some image files. Unzip the files to a folder and either add to path or set the MATLAB workspace to this folder before starting the tutorial.
The tutorial uses cells, and each section below corresponds to a cell in the tutorial. To evaluate a cell in the tutorial, first navigate into it. Ctrl+Enter evaluates the current cell, and Ctrl+Shift+Enter evaluates and moves to the next cell. Variables are re-used throughout the tutorial, so start at the first cell and work through the tutorial in order.
The tutorial package contains a selection of image files. Those titled "stimulus##.tif" (including the one used on this page) are from an image set prepared by Roozbeh Kiani. The associated publication can be found here. Used with permission.
Tutorial
Cell I. Loading images for analysis
The first cell simply loads an image, converts it to grayscale, and sets the size of the image. nPix, the variable setting the number of pixels in the x and y dimensions, should be a power of 2 for faster FFT calculation.
This figure contains the image in grayscale. It has nPix x nPix pixels (in this case, 256 x 256).
Cell II. Using fftshift
The fftshift function is helpful for visualing Fourier transforms in a familiar format. In the 1-dimensional N-point Fourier transform (like the transform of an audio signal), it takes points N/2+1 to N (containing the Nyquist and negative frequency components) and moves them to the beginning of the array. See Oppenheim and Schafer, Chapter 4, if you want to know why this can happen. Thus, the fftshifted function causes the poisitive and negative frequencies to be symmetric about the zero-frequency point. This being the case, it's helpful to keep in mind that the zero-frequency sample is at sample N/2+1.
Here is a 1-dimensional example. The red dot is the zero-frequency component of the transform of the sinusoid in the top subplot.
In the 2-dimensional case, fftshift swaps quadrants 1 and 3, and also 2 and 4 of the Fourier transform. Thus, the low-frequency information is moved to the center of the image, with the [0,0] frequency point moving from matrix index [1,1] to [nPix/2+1,nPix/2+1]. The fftshifted Fourier transform of an image is what we are used to looking at when we talk about k-space.
Here is a 2-d Fourier transform without fftshift. Note the bright spots (high amplitudes) in the outer corners of the image; these are the low frequencies.
Here is the same transform, with fftshift applied to it. Now the low-frequency, high-amplitude information is in the center of the image.
Cell III. Artifact 1: DC offset
The DC offset is a constant, positive shift in amplitude. It results in a large peak at frequency zero. This can be derived from the equation for the DFT. Given that the DFT is defined as