Welcome everyone to the first regular article of the new decade!

And as a result of recent medical testing, the subject that I have selected for today's entry is the mathematics of reconstructing medical magnetic resonance images - or MRIs.

Some of you may recall a pair of articles that I published last June on the qualitative meaning of the Fourier transform and how it applied to reconstructing medical computed tomography images. In those two articles I provided a very basic - and possibly oversimplified - explanation of how the average values of different regions in an image contain more useful information than the traditional array of pixels. I also demonstrated how x-rays could be used to measure these averages inside a living being, and provide doctors with vital medical information without the need to slice the patient into pieces first. For those of you who wish to review, the articles were "Fourier Transforms" and "Computed Tomography Reconstructions".

Today I will continue with this subject, but instead of the ubiquitous CT imaging, I will focus on the more modern and perhaps more versatile MRI, or magnetic resonance imaging. Of course the details of how an MRI works are quite interesting - earning its inventors the Nobel Prize - but I will leave that for another day. Instead I will focus solely on how the data generated by an MRI scan is reconstructed to form a usable image. 

As with my previous articles on this subject, I must also add a disclaimer that I am greatly simplifying some of the mathematics here in order to make the subject more accessible. I will endeavor to explain these simplifications as I go along, but the focus should be on the basic concepts rather than the technical details. I will also be describing a method known as a proton density scan, which is seldom used in medical applications but happens to be the easiest to understand for this introduction to the subject.

An MRI works because of the resonance properties of atomic nuclei. When a nucleus - or in this case a single proton - is placed in a magnetic field, it will align its spin axis with the magnetic field. However it can be forced to flip over, so that it is pointing in the opposite direction to the magnetic field in an excited state. In order to do this, the proton must absorb a radio wave with a very precise frequency, known as the resonance frequency. If the frequency is too high or too low, the proton will not change its orientation.

Once the patient is in the MRI machine, they are exposed to a very strong magnetic field, which causes a fraction of the hydrogen atoms in their body to align with the field. These atoms are present in water, fat, muscles, and almost every component of the human body. By varying the magnetic field so that it is stronger at the patient's head than at their feet, each slice of the patient's body will have a slightly different resonance frequency. An antenna in the MRI machine can then be used to excite the protons in a narrow slice of the body to be imaged. 

Depending on the intensity and duration of the radio pulse, these excited hydrogen atoms will create their own magnetic field that is perpendicular to the machine's magnetic field. It is this field that can then be measured by a radio receiver built into the MRI equipment. And it is the strength of this field, and its evolution over the course of the imaging that allows us to create an image of the patient's insides.



When the protons are first excited, the magnetic fields across this slice are all aligned and combine to form a strong field pointing in one direction - in this case they are all pointing to the right. By measuring the strength of this field, we can measure the average number of protons in this slice. We don't know anything about their location yet, but we know the average over the entire image. In the previous articles, this number was called F(0,0).

However the magnetic field in the MRI machine causes this field to rotate, and over time the field will oscillate between pointing the right and pointing to the left. If we vary the external magnetic field in the MRI machine, making it stronger on the right than on the left, then the magnetic field generated by the protons will rotate (or precess) at a different rate depending on their location. For example, our next measurement of the magnetic field could be taken when the magnetic field on the right is pointing right, and all of the magnetic fields on the left are pointing left. This measurement tells us the difference between the number of protons on the left and on the right, as the two magnetic fields will partially cancel out. In keeping with the notation of the previous articles, this number will be called F(1,0).


(At this point I must mention that this is an unrealistic simplification. In reality, the protons near the center will be a mix of left and right since they are precessing at a rate halfway between the two extremes, and will therefore contribute very little to the overall magnetic field. However the basic idea of averaging the two sides of the slice is still correct).
Next we take a measurement when the protons near the center are pointing right, and the protons at the edges are pointing left. This will occur when the protons on one side have completed an additional 360o of rotation relative to the protons on the other side, and the protons halfway between have only been rotated by 180o. This measurement tells us the average density of protons in the center relative to the edges, and is denoted by F(2,0).


And as we did before with CT image reconstruction, we can continue taking measurements of all values of F(k,0) and created a one dimensional reconstruction of the original image. But we need a two-dimensional image, and it simply isn't possible to use this same series of measurements to measure the density variations along the other direction. For that, we need to use phase encoding.

Fortunately phase encoding is actually very similar to the method we have been using thus far. All of the measurements that we have completed so far have used the average density of all protons in the (vertical) y-direction, and have only permitted the densities in the (horizontal) x-direction to precess at different rates. But now we are going to vary the y-direction as well.

Once we have measured as many values of F(k,0) as we require, we start over again with a new set of measurements. This time we will vary the MRI magnetic field from the front to the back of the patient, so that protons on one side precess faster than protons on the other (Note here that the front of the patient is the top of the image, and the back of the patient is the bottom of the image, and so I will be using the terms interchangeably). Without loss of generality, we will assume that the protons in the front half the patient are all rotating at the same rate, and that they are rotating faster than the protons in the back half of the patient. Once they are 180o out of phase, we can repeat all of the measurements that we did before in the x-direction.


Except this time the results will be slightly different. Instead of F(0,0) we will measure F(0,1) - which is the average of all protons in the top half minus the average density of all protons in the bottom half of the slice. Then the next measurement will give the average densities in the top left and bottom right, minus the average densities in the top right and bottom left. This is called F(1,1).


And the process continues for all values of F(k,1). Then we apply another phase encoding magnetic field, so that the center protons are aligned opposite to the protons at the top and bottom of the image, and we measure all of the values of F(k,2). Eventually we will have a large array of numbers of the form F(k,n), and by combining them in exactly the same way that we did with CT image reconstruction, we will end up with a grayscale map in which the brightness of each pixel corresponds to the density of protons in the corresponding location of the original target slice.

That is MRI reconstruction in a nutshell. 

Of course in a real MRI machine there are a few more complexities. As I previously mentioned, the magnetic field variations change gradually across the target slice, and so instead of definite regions and well defined orientations, we have a gradient. The proton density near the edges of each region will be less influential than those near the center. But the underlying technique is identical, with just the mathematics being a little more cumbersome. 

The other detail that warrants a mention is that proton density scans are rarely used in medical imaging, because they cannot discriminate between protons in water versus protons in fat or muscle or brain tissue or any number of other biological substances. Therefore in real world MRIs, you will hear terms like T1 or T2 weighted images, or FLAIR, DWI, or SWI images. However these are actually quite a simple modification of the methods described above. As it happens, after the protons have been initially excited by the radio wave pulse, they decay back into their ground state at different times depending on what substance they are contained in. Complex molecules lose their excitement quite quickly, while water and cerebrospinal fluid stay excited. So MRI technicians can delay the measurements by known periods of time to exclude certain substances, or they can apply multiple radio wave pulses to cause different substances to be excited for the measurements. After that, the exact same methods are used to collect the data and reconstruct the image. However such technical details are well beyond the scope of this articles.

That is the basis of magnetic resonance imaging. Using radio pulses and magnetic field gradients, protons can be placed into excited states and the resulting magnetic fields are then measured to determine their density and location. Add all the measurements together, and the final result is an cross-section of the patient's body that allows the medical teams to examine what would have required major exploratory surgery just half a century ago.

That is the power of the Fourier transform.