Magnetic resonance imaging (MRI) is a neat example of putting together physics and engineering principles to benefit medicine. One particular neat feature of MRI is that it uses electromagnetic (EM) waves of meter-long wavelength to achieve millimeter resolution. For example, most US hospitals are equipped with 1.5T and 3T MRI scanners, which correspond to EM frequencies of about 64MHz (wavelength 4.7 meter) and 128MHz (wavelength 9.4 meter). This is made possible by clever encoding tricks to trade time cost for spatial resolutions. In this post I will explain how it works. My focus will be more on the signal processing side and less on the physics side.

The physics used in MRI is nuclear magnetic resonance(NMR), which basically means atoms and molecules can be turned into EM wave sources. In fact, this is all we need to know to understand the imaging process. NMR itself is a very rich field with long history and is still under active research. So far there are 3 Nobel prizes awarded to NMR research

NMR basically defines the “language” of quantum physics for atoms. About 20 years ago, NMR was the leading technology to build quantum computer as well. Even though NMR quantum computer is less popular now due to its scalability issues, the language and tricks in NMR physics still benefit other quantum computer architectures since any quantum object is effectively an artificial atom.

## signal formation and decoding

EM waves can be described by 3 parameters: amplitude, frequency, and phase. It has compact mathematical form

$A e^{i(\omega t + \phi)}$

where $$A$$ is the amplitude, $$\omega$$ is the frequency, $$\phi$$ is the initial phase, $$i=\sqrt{-1}$$ is the imaginary unit, and $$t$$ is time.

Pictorially, it can be represented by a rotating arrow where the length of the arrow is $$A$$, the rotating angular frequency is $$\omega$$, and the instantaneous rotating angle is $$\omega t + \phi$$. For simplicity, I will drop the initial phase $$\phi$$ from now on.

Suppose there are two EM wave sources in space, the overall signal we detect is approximately

$s(t) = A_1 e^{i\omega_1 t} + A_2 e^{i\omega_2 t}$

(Strictly speaking, there are extra phase factors and damping factors depending on the relative positioning of the sources and detector. I ignore all that for simplicity.)

Here the amplitudes are the unknowns, and NMR physics allows us to set the frequencies for each source. Given this, it’s easy to get the amplitudes. For example, we can set the two sources to unequal frequencies and pick two sampling times such that

$s(t_0) = A_1 + A_2 \\ s(t_1) = A_1 - A_2$

In matrix form,

$\mathbf S = F \mathbf A$

where bold face symbols denote vectors and $$F$$ is a matrix. Here $$F$$ is given by

$\begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}$

It is the Hadamard matrix $$H_2$$, or the Fourier transform matrix $$DFT_2$$.

To get the amplitudes, all we need to do is one matrix inversion

$\mathbf A = F^{-1} \mathbf S$

Now it’s easy to see what to do when there are $$n$$ EM sources: we set different frequencies for each source and pick $$n$$ sampling times to form the corresponding encoding matrix $$F$$.

In principle, there are infinite ways to choose frequencies and sampling times, as long as $$F$$ is invertible. Practically, there are concerns on hardware feasibility, imaging time constraints, noise propagation, imaging reconstruction speed, etc. Typically, Fourier encoding is used for reconstruction efficiency, thanks to the $$O(n\log n)$$ fast Fourier transform (FFT) algorithm (generic matrix inversion is basically $$O(n^3)$$ complexity).

## spacial frequency encoding

In the previous section, we learned how to resolve the amplitudes of EM sources with unique frequencies. But how do we know their spacial locations? The answer is to set the frequency depending on the spacial location. To understand it, we need to know a little bit more on NMR physics. I mentioned that atoms and molecules can behave as EM sources. More specifically, their frequencies are controlled by a simple relationship

$\omega = \gamma B$

where $$B$$ is the magnetic field we apply, and $$\gamma$$ is a constant known as the gyromagnetic ratio. In NMR jargon, the frequency $$\omega$$ is known as the Larmor frequency. The value of $$\gamma$$ varies depending on the atoms or molecules. In MRI, the atom of interest is hydrogen because the human/animal/plant body is full of water. And hydrogen’s gyromagnetic ratio is $$42.58MHz/T$$.

To encode the spacial information, we can set up magnetic field gradient in space (say linear gradient in all 3 dimensions). Then the hydrogen atoms at different spacial locations will emit EM waves with different frequencies. And we can apply 3D FFT to resolve the density of hydrogen atoms in space.

So far I assume the hydrogen atoms are static. If they move, their motion would leave trace in the phase of the emitted EM waves, and it is possible to reconstruct the flow information as well.

## limitations

Comparing to the other medical imaging techniques, the biggest limitation of MRI is the time cost: higher resolution takes longer to acquire. For 3D imaging, doubling the resolution requires 8 times the temporal data, i.e., 8 times the imaging time. For static object such as brain or foot, it is not a big problem, but if we are interested in heart, or liver, acceleration in sampling is a must.