Medicine · Physics · Signal Processing
📅 March 2026 ⏱ ≈ 14 min read 🎯 Intermediate

How MRI Works — Nuclear Magnetic Resonance and Medical Imaging

Every year, over 100 million MRI scans are performed worldwide — producing detailed 3-D images of soft tissue without a single X-ray photon. The machine exploits a curious quantum-mechanical property of atomic nuclei: their spin. This article traces the physics from a proton's magnetic moment all the way to the image on a radiologist's screen.

1. Proton Spin and Magnetic Moments

Every proton (hydrogen nucleus) has an intrinsic angular momentum called spin. Although spin is a quantum property with no classical analogue, it behaves macroscopically like a tiny bar magnet: each proton carries a magnetic moment μ aligned along its spin axis.

μ = γ · ℏ · I γ (gyromagnetic ratio for ¹H) = 2.675 × 10⁸ rad s⁻¹ T⁻¹ ℏ = reduced Planck constant = 1.055 × 10⁻³⁴ J·s I = spin quantum number = ½ for ¹H

The human body is ~60% water (H₂O), making hydrogen by far the most abundant NMR-active nucleus. Clinical MRI therefore primarily images proton density and tissue relaxation properties.

2. Alignment in a Strong Static Field (B₀)

Outside a magnetic field proton spins point in random directions and cancel out. Inside the bore of an MRI scanner, a superconducting magnet generates a powerful static field B₀ (typically 1.5 T or 3 T — up to 50,000 times Earth's field).

Quantum mechanics allows only two energy states for a spin-½ nucleus in field B₀:

Parallel (low energy, spin-up): E₊ = −½ γ ℏ B₀ Anti-parallel (high energy, spin-down): E₋ = +½ γ ℏ B₀ Energy difference: ΔE = γ ℏ B₀ At body temperature, there is a small Boltzmann excess of ~7 spins per million in the lower-energy (parallel) state. This tiny imbalance creates a net macroscopic magnetization M₀ pointing along B₀. M₀ ∝ N · γ² ℏ² B₀ / (4 k_B T) (Curie law) N = proton number density, k_B = Boltzmann constant, T = temperature

The net magnetization M₀ is what the scanner ultimately measures. It is proportional to field strength B₀ — one reason why a 3 T scanner produces sharper images than a 1.5 T scanner.

3. The RF Pulse and Larmor Resonance

To produce a detectable signal, the scanner tips the net magnetization M₀ away from the B₀ axis using a brief radiofrequency (RF) pulse. The key is resonance: the pulse frequency must exactly match the Larmor frequency ω₀.

ω₀ = γ · B₀ (Larmor equation) For ¹H at 1.5 T: ω₀ = 2.675×10⁸ × 1.5 ≈ 64 MHz For ¹H at 3.0 T: ω₀ ≈ 128 MHz For ¹H at 7.0 T: ω₀ ≈ 298 MHz (FM radio band)

A 90° pulse tips M₀ entirely into the transverse (x-y) plane. The magnetization then precesses around B₀ at ω₀, sweeping past the receive coil and inducing a sinusoidal voltage — the Free Induction Decay (FID) signal.

Bloch equations describe the magnetization vector M(t) under combined static field B₀, RF field B₁, and relaxation:

dMx/dt = γ(My·Bz − Mz·By) − Mx/T2
dMy/dt = γ(Mz·Bx − Mx·Bz) − My/T2
dMz/dt = γ(Mx·By − My·Bx) − (Mz − M₀)/T1

4. T1 and T2 Relaxation — Where Contrast Comes From

After the RF pulse is switched off, the magnetization returns to equilibrium through two independent processes. These characteristic time constants are the primary source of tissue contrast in MRI.

Longitudinal (T1) Relaxation — Spin-Lattice

The z-component of magnetization (Mz) recovers exponentially back to M₀ as spins release energy to the surrounding molecular lattice:

Mz(t) = M₀ · [1 − e^(−t/T1)] Typical T1 values at 1.5 T: White matter: ~780 ms Grey matter: ~920 ms Fat: ~260 ms Water (CSF): ~2400 ms

T1 depends on how efficiently molecules tumble at the Larmor frequency. Lipids tumble at just the right rate, giving fat a short T1 (fast recovery, appears bright on T1-weighted images).

Transverse (T2) Relaxation — Spin-Spin

The transverse magnetization (Mxy) decays as individual spins dephase due to tiny local field variations from neighboring nuclei:

Mxy(t) = Mxy(0) · e^(−t/T2) Typical T2 values at 1.5 T: White matter: ~90 ms Grey matter: ~100 ms Fat: ~80 ms Water (CSF): ~1800 ms Tumors: often elevated T2 (more free water)

T2 is always ≤ T1. Free water has long T1 and T2 (slow tumbling, poor energy transfer); bound water in tissue has short T2. Tumors and edema often appear hyperintense on T2-weighted images because pathological processes increase tissue water content.

T2* (T2-star) is a faster decay including field inhomogeneities (ΔB₀). A spin-echo sequence refocuses T2* effects using a 180° pulse, recovering true T2 signal. Gradient-echo sequences retain T2* sensitivity — exploited in fMRI BOLD imaging.

Pulse Sequences Control Contrast

By choosing TR (repetition time) and TE (echo time) the radiologist suppresses or emphasises T1 and T2 contributions:

5. Gradient Coils and Spatial Encoding

After the RF pulse, all protons produce signal at the same Larmor frequency — the scanner cannot yet tell where the signal came from. Three sets of gradient coils (Gx, Gy, Gz) add small, linear variations to B₀ that encode spatial position into frequency and phase.

Slice Selection

A Gz gradient is applied during the RF pulse, making B₀ vary along z. Only the slice where the local field matches the pulse frequency is excited:

ω(z) = γ · [B₀ + Gz · z] Slice position: z₀ = (ω_RF − γ·B₀) / (γ·Gz) Slice thickness: Δz = BW_pulse / (γ·Gz) BW_pulse = RF bandwidth; thinner slice → narrower BW or stronger gradient

Frequency Encoding

During signal readout, a Gx gradient is applied. Protons at different x positions precess at different frequencies; the received signal is a superposition of sinusoids:

ω(x) = γ · [B₀ + Gx · x] Signal(t) = ∫ ρ(x) · e^(iγGx·x·t) dx → Fourier transform of proton density ρ(x)!

Phase Encoding

A Gy gradient is applied for a brief period before readout. This imparts a phase shift proportional to y position — encoding the second spatial dimension. The entire sequence is repeated with different Gy amplitudes to fill a 2-D k-space matrix.

6. k-Space and the 2-D Fourier Transform

The raw data collected by the scanner is stored in a 2-D matrix called k-space. Each point [kx, ky] represents a specific spatial frequency of the image:

kx(t) = γ/(2π) · Gx · t (frequency-encode direction) ky(n) = γ/(2π) · Gy(n) · τ_pe (phase-encode direction, n = 1…N) S(kx, ky) = ∫∫ ρ(x,y) · e^(−i2π(kx·x + ky·y)) dx dy → S(kx, ky) is exactly the 2-D Fourier transform of proton density ρ(x,y)! Image reconstruction: ρ(x,y) = 2D-IFFT{ S(kx, ky) }

The center of k-space (low kx, ky) contains low spatial frequencies — overall brightness and contrast. The periphery contains high spatial frequencies — edges and fine detail. This is why partial k-space acquisitions (sampling only the center) are faster but blurrier.

// Simplified k-space → image reconstruction
function reconstructMRI(kSpaceData) {
  // kSpaceData: 2-D complex array [Nky][Nkx]
  const N = kSpaceData.length;

  // Step 1: 2-D inverse FFT (row-by-row, then column-by-column)
  const temp = kSpaceData.map(row => ifft1D(row));       // IFFT each row
  const image = transposeAndIFFT(temp);                   // IFFT each column

  // Step 2: magnitude image (discard phase)
  return image.map(row =>
    row.map(c => Math.sqrt(c.re**2 + c.im**2))
  );
}

// k-space properties exploited in fast sequences:
// Partial Fourier: acquire 60% of k-space, zero-fill rest (homodyne)  
// Parallel imaging (GRAPPA/SENSE): undersample with multi-channel coil
// Compressed sensing: incoherent undersampling + sparse reconstruction
EPI (Echo Planar Imaging) fills all of k-space after a single RF pulse by rapidly oscillating Gx and Gy gradients in a zigzag pattern. Acquisition time: ~50 ms per slice — fast enough for fMRI (brain activity changes over seconds) and cardiac imaging.

7. Contrast Mechanisms and Common Sequences

Gadolinium Contrast Agents

Gadolinium (Gd³⁺) is strongly paramagnetic — it dramatically shortens T1 of nearby protons. Injected intravenously, Gd accumulates where the blood-brain barrier is disrupted (active tumors, inflammation), creating bright spots on T1-weighted images.

fMRI — Blood Oxygen Level Dependent (BOLD)

Deoxy-hemoglobin is paramagnetic and shortens T2*; oxy-hemoglobin is diamagnetic and does not. Active brain regions have higher blood oxygenation → longer T2* → brighter signal on gradient-echo sequences. This BOLD contrast is the basis of functional MRI — mapping brain activity without radioactive tracers.

Diffusion Tensor Imaging (DTI)

By applying strong gradient pulses in multiple directions, DTI measures how water molecules diffuse through tissue. In white matter axon bundles, diffusion is anisotropic — faster along the axon than across it. DTI reveals neural fiber tracts and detects early axonal damage in stroke and MS.

Apparent Diffusion Coefficient: ADC = −(1/b) · ln(S/S₀) b-value: b = γ² G² δ² (Δ − δ/3) [s/mm²] G = gradient strength, δ = duration, Δ = spacing High b (1000 s/mm²) → sensitive to restricted diffusion (acute stroke: bright DWI)

MR Spectroscopy (MRS)

Without spatial gradients, the NMR spectrum reveals the chemical signature of metabolites. NAA (N-acetyl-aspartate) is a neuronal marker; its reduction signals neuronal loss. Choline rise indicates membrane turnover (tumors). Lactate appears in anaerobic metabolism (ischemia).

8. Safety, Field Strengths, and the Limits of MRI

Why MRI Is Safe (for most patients)

Unlike CT or PET, MRI uses no ionizing radiation. The RF energy deposited (SAR — Specific Absorption Rate) is limited to 4 W/kg by safety guidelines. The main hazards are:

Field Strength Trends

Gradient-induced peripheral nerve stimulation (PNS) limits how fast gradient coils can be switched. Fast switching (high dB/dt) induces currents in the body — a tingling sensation that caps EPI and diffusion sequence performance in high-field systems.
🔬 Explore Medicine & Biophysics Simulations →