Standalone Slides Main Simulator
COMPUTATIONAL MRI PHYSICS // INTERACTIVE STUDY MODULES

The Physical Foundations of Magnetic Resonance

An interactive computational examination of precession dynamics, gradient spatial encoding, resonant RF nutation, and 2D k-space image reconstruction using MRIjs.

Abstract & Computational Framework This computational document presents a rigorous interactive analysis of fundamental magnetic resonance physics. Theoretical formulations, spin isochromat trajectories, and frequency spectra are evaluated dynamically via numerical integration of the Bloch equations directly within the client environment. The module provides quantitative investigation of Larmor precession proportionality, gradient-induced phase dispersion, resonant radiofrequency nutation dynamics, and spatial frequency encoding in two-dimensional Cartesian k-space.
Section 01

Static Field Strength (B₀) and Nuclear Precession Frequency Dynamics

Atomic nuclei containing an odd number of protons or neutrons exhibit an intrinsic quantum mechanical angular momentum known as nuclear spin (\(\vec{I}\)). Proportional to this angular momentum is the magnetic dipole moment \(\vec{\mu} = \gamma \vec{I}\), where \(\gamma\) is the gyromagnetic ratio unique to each nuclide.

When placed into a powerful static main magnetic field \(\vec{B}_0 = B_0 \hat{z}\), the magnetic moment experiences a mechanical torque \(\vec{\tau} = \vec{\mu} \times \vec{B}_0\). Because angular momentum is conserved, this torque causes the vector to undergo gyroscopic precession around \(\hat{z}\) at the angular frequency given by the Larmor Equation:

$$\omega_0 = \gamma B_0 \quad (\text{rad/s}) \qquad \Longleftrightarrow \qquad f_0 = \frac{\gamma}{2\pi} B_0 \quad (\text{MHz})$$ Equation 1: The Larmor relationship establishing linear proportionality between field strength B₀ and precession frequency f₀.

In our current live model, with the main field set to B₀ = 1.50 T, hydrogen protons (¹H, γ/2π ≈ 42.576 MHz/T) precess at 63.864 MHz, completing one full revolution every 15.66 ns. Because electron clouds slightly shield nuclei from B₀, protons in different chemical environments precess at shifted frequencies. For example, water and lipid protons exhibit a 3.5 ppm chemical shift separation (Δf = 3.5 × 10⁻⁶ × f₀), resulting in an offset of 223.5 Hz.

Live Computational Figure 1: Larmor Dynamics & Reference Frames
LIVE MODEL
Off-resonance ($\Delta \omega$): 2.0 Hz
Larmor Frequency ($f_0$) 63.864 MHz Linear with $B_0$
Precession Period ($T_0$) 15.66 ns Time per revolution
Water-Fat Shift ($\Delta f$) 223.5 Hz Chemical shielding
Spin Excess Polarization 4.8 ppm Thermal equilibrium at 300K
Figure 1 Explanation: The left panel illustrates the Laboratory Frame where transverse magnetization rotates at MHz speed. The right panel transforms into the Rotating Frame (rotating at \(\omega_0\)), where on-resonance magnetization appears static and small frequency differences \(\Delta\omega\) become slow, observable phase drift.
Active Learning Checkpoint 01: Predict & Verify
Predict: A clinic upgrades from a 1.5 T MRI scanner to a 7.0 T ultra-high-field research scanner. What happens to the water-fat chemical shift frequency separation (Δf)?
Listing 1: Simulating Chemical Shift Interference with MRIjs
const BlochSimulator = window.BlochSimulator || require('./bloch.js');

// Define two isochromats: water (w = 0) and fat (w = 40 Hz offset)
const isochromats = [
    { id: 'water', x: 0, T1: 800, T2: 200, PD: 1.0, w: 0 },
    { id: 'fat',   x: 0, T1: 300, T2: 120, PD: 1.0, w: 40 }
];

const sim = new BlochSimulator(isochromats, 80, 0.2, 'rotating', 'FID', { flipAngle: 90 });
const results = sim.run();
Live Output: Chemical Shift Interference Beat Signal
Section 02

Spatial Position Encoding via Linear Magnetic Field Gradients

Because an RF receiver coil detects only the integrated voltage induced across the whole sample, a uniform magnetic field yields zero spatial discrimination. To resolve anatomy, we introduce linear magnetic field gradients:

$$\vec{B}(\vec{r}) = \left(B_0 + \vec{G} \cdot \vec{r}\right) \hat{z} = \left(B_0 + G_x x + G_y y + G_z z\right) \hat{z}$$ Equation 2: The gradient magnetic field points along $\hat{z}$, but its magnitude varies linearly across space.

Consequently, the local Larmor frequency varies with coordinate \(x\): \(\omega(x) = \omega_0 + \gamma G_x x\). Spins at position \(x\) accumulate phase according to \(\phi(x, t) = \int_0^t \gamma G_x(\tau) x d\tau\).

In our live model below, with gradient G_x = 20 mT/m applied for 5.0 ms, edge isochromats diverge in frequency by ±851.5 kHz, causing the collective net transverse signal to dephase down to 18.4%.

Live Computational Figure 2: Linear Field Profile & Spatial Isochromat Dephasing
LIVE MODEL
Max Spatial Frequency Offset ±851.5 kHz At coordinate edges x = ±1
Net Transverse Signal (|Σ Mxy|) 18.4% Coherent vector sum
Figure 2 Explanation: The top plot shows the linear magnetic field slope \(B_z(x) = B_0 + G_x x\). The bottom row displays 11 individual spin isochromats distributed across space: positive \(x\) spins advance in phase while negative \(x\) spins lag, causing destructive interference of the collective net signal.
Active Learning Checkpoint 02: Predict & Verify
Predict: After applying a dephasing gradient lobe for duration \(\tau\), the transverse magnetization drops to near zero. How can we completely refocus the isochromats to form an echo without using an RF pulse?
Listing 2: Simulating Gradient Echo (GRE) Rephasing with MRIjs
// Model spatial isochromats across space under a Gradient Echo sequence
const isochromats = [-1.0, -0.6, -0.2, 0.2, 0.6, 1.0].map((x, i) => ({
    id: `spin_${i}`, x: x, T1: 800, T2: 300, PD: 1.0, w: 0
}));

const sim = new BlochSimulator(isochromats, 80, 0.2, 'rotating', 'GRE', { flipAngle: 90, TE: 40, TR: 100 });
const results = sim.run();
Live Output: Gradient Waveform & Echo Rephasing Peak at TE = 40 ms
Section 03

Resonant Radiofrequency Excitation and B₁ Nutation Dynamics

To tip the longitudinal net magnetization \(M_z\) into the transverse plane, an alternating RF current is applied perpendicular to \(\vec{B}_0\) at the Larmor frequency, creating a dynamic magnetic field \(\vec{B}_1(t)\).

In the rotating reference frame (moving at \(\omega_{\text{rf}} = \omega_0\)), \(\vec{B}_0\) is eliminated. The net magnetization undergoes steady gyroscopic nutation around \(\vec{B}_1\) through a tip angle \(\alpha\):

$$\alpha = \int_0^{T_{rf}} \gamma B_1(t) \, dt \qquad \stackrel{\text{Rectangular Pulse}}{\Longrightarrow} \qquad \alpha = \gamma B_1 T_{rf}$$ Equation 3: Flip angle $\alpha$ as a function of RF field amplitude $B_1(t)$ and duration $T_{rf}$.

Currently, for a flip angle of α = 90° and pulse duration 2.0 ms, the required peak RF amplitude is 2.9 µT. When paired with a slice-selection gradient (G_z), shaped pulses (such as sinc pulses) produce rectangular frequency profiles, yielding an excitation slice thickness of 1.47 mm (Δz = Δf / (γ G_z)).

Physical Insight: Counter-Rotating Field & The Bloch-Siegert Shift: A linearly polarized RF pulse decomposes into two circularly polarized components: a co-rotating field at $+\omega_0$ and a counter-rotating field at $-\omega_0$. While the counter-rotating field is too far off-resonance ($2\omega_0$) to tip the spins directly, quantum perturbation induces a small second-order frequency shift: $$\Delta \omega_{BS} = \frac{(\gamma B_1)^2}{2\omega_0}$$ Known as the Bloch-Siegert shift, this phenomenon is actively exploited in modern clinical MRI for fast, phase-based transmit sensitivity ($B_1^+$) mapping!
Live Computational Figure 3: 3D Vector Nutation & RF Slice Selection Profile
LIVE MODEL
Required $B_1$ Field 2.9 µT Peak RF amplitude
RF Bandwidth ($\Delta f$) 1250 Hz Excitation bandwidth
Slice Thickness ($\Delta z$) 1.47 mm $\Delta z = \Delta f / (\gamma G_z)$
Post-Pulse Vector Mxy=1.00, Mz=0.00 Longitudinal vs Transverse
Figure 3 Explanation: Left: 3D Bloch sphere vector nutation trajectory tipping \(\vec{M}\) around \(B_1\). Right: Time-domain pulse envelope \(B_1(t)\) alongside its Fourier frequency excitation profile \(|M_{xy}(f)|\), demonstrating how sinc pulses generate slice profiles with sharp boundaries.
Active Learning Checkpoint 03: Predict & Verify
Predict: In rapid Gradient Echo imaging with very short repetition time (\(TR \ll T_1\)), what happens if we repeatedly apply 90° excitation pulses instead of smaller Ernst angle pulses (~15°–35°)?
Listing 3: Simulating Flip Angle Nutation & Recovery with MRIjs
const spin = [{ id: 'gray_matter', x: 0, T1: 600, T2: 120, PD: 1.0, w: 0 }];
const sim = new BlochSimulator(spin, 60, 0.1, 'rotating', 'FID', { flipAngle: 60 });
const results = sim.run();
Live Output: Magnetization Dynamics $M_{xy}(t)$ and $M_z(t)$
Section 04

Signal Reception, 2D k-Space Formalism, and Image Reconstruction

During signal acquisition, the received voltage S(t) represents the spatial integration of transverse magnetization over the sample. By applying orthogonal gradients, we trace a trajectory through k-space (spatial frequency space):

$$S(t) = \int \int \rho(x, y) \, e^{-i 2\pi [k_x(t) x + k_y(t) y]} \, dx \, dy$$ Equation 4: The fundamental MRI signal equation demonstrating that raw data is the continuous 2D Fourier Transform of spin density \(\rho(x, y)\).

The coordinates in spatial frequency space (\(\vec{k}(t)\)) are dictated by gradient integrals: \(k_x(t) = \frac{\gamma}{2\pi}\int_0^t G_x(\tau)d\tau\) and \(k_y(t) = \frac{\gamma}{2\pi}\int_0^t G_y(\tau)d\tau\). To form the anatomical picture, the computer computes the 2D Inverse Discrete Fourier Transform (2D IDFT):

$$\rho(x, y) = \int \int S(k_x, k_y) \, e^{+i 2\pi [k_x x + k_y y]} \, dk_x \, dk_y$$ Equation 5: 2D Inverse Fourier reconstruction mapping spatial frequency samples into real-space tissue contrast.

In the interactive studio below, notice that under Full k-Space, the central 6 × 6 region contains 96.2% of total signal power. Low-pass filtering preserves bulk contrast while blurring edges; high-pass filtering produces edge detection with zero contrast; undersampling induces wrap-around aliasing ghosts.

Live Computational Figure 4: Real-Time 2D k-Space & Image Reconstruction Studio
2D IDFT ENGINE
Active Sampling State Full k-Space (100% data) Filter status
Central Energy Fraction 96.2% Within radius < 6 px
k-Space Raw Data $|S(k_x, k_y)|$ (Log Scale)
Reconstructed Image $|\rho(x, y)|$ (2D IDFT)
Figure 4 Explanation: The left panel displays log-scaled magnitude k-space raw data \(|S(k_x, k_y)|\). The right panel shows the complex 2D inverse Fourier transform (2D IDFT). Notice how central k-space governs contrast and bulk shape, while outer k-space delivers sharp spatial edges and resolution.
Active Learning Checkpoint 04: Predict & Verify
Predict: If high-frequency raw data in the periphery of k-space (\(|k| \gg 0\)) is filtered out or corrupted, what happens to the reconstructed clinical image?
Cartesian k-Space Trajectory (Line-by-Line Rastering)
Listing 4: Simulating 1D Projection Reconstruction with MRIjs
// Define a 1D spatial phantom with 3 discrete objects along the x-axis
const phantomSpins = [
    { id: 'obj1', x: -0.6, T1: 1000, T2: 500, PD: 1.0, w: 0 },
    { id: 'obj2', x:  0.0, T1: 1000, T2: 500, PD: 0.5, w: 0 },
    { id: 'obj3', x:  0.5, T1: 1000, T2: 500, PD: 0.8, w: 0 }
];

const sim = new BlochSimulator(phantomSpins, 60, 0.2, 'rotating', 'GRE', { flipAngle: 90, TE: 30, TR: 100 });
const results = sim.run();
const spatialProfile = compute1D_FFT(results.signals.map(s => s.Mxy));
Live Output: 1D Reconstructed Spatial Object Profile $|\rho(x)|$
MRIjs Educational Suite

The Physical Foundations of Magnetic Resonance

An Interactive Computational Presentation

Use Space or Arrow Keys to navigate slides. Every widget on every slide is completely interactive.

Presentation Outline

  • Module 1: $B_0$ & Precession (The Larmor Relationship)
  • Module 2: Gradients & Spatial Encoding (Phase & Frequency)
  • Module 3: RF Pulses & $B_1$ Magnetic Field (Resonant Nutation)
  • Module 4: Image Formation & k-Space (2D Fourier Transform)
Module 01

Nuclear Precession & The Larmor Equation

Nuclei with non-zero spin have a magnetic moment $\vec{\mu} = \gamma \vec{I}$. In a static field $\vec{B}_0 = B_0 \hat{z}$, torque $\vec{\tau} = \vec{\mu} \times \vec{B}_0$ induces precession:

$$\omega_0 = \gamma B_0 \quad (\text{rad/s}) \qquad f_0 = \frac{\gamma}{2\pi} B_0 \quad (\text{MHz})$$

For hydrogen protons ($^1\text{H}$), $\frac{\gamma}{2\pi} \approx 42.576\text{ MHz/T}$. Frequency scales linearly with field strength.

Interactive Larmor Calculator

Larmor Frequency63.864 MHz
Period (T₀)15.66 ns
Water-Fat Shift223.5 Hz
Thermal Polarization4.8 ppm

Laboratory vs. Rotating Frame

Live Simulation: Chemical Shift Beat Signal

BlochSimulator (FID, Water w=0, Fat w=40Hz)
Module 02

Magnetic Gradients & Spatial Encoding

To localize signals, small linear gradient fields are superimposed along $\hat{z}$:

$$\vec{B}(x) = (B_0 + G_x x)\hat{z} \implies \omega(x) = \omega_0 + \gamma G_x x$$

Each coordinate position $x$ precesses at a distinct frequency. Phase accumulates as $\phi(x, t) = \gamma G_x x t$.

Spatial Isochromat Array Simulator

Net: 18.4%

Live Simulation: Gradient Echo (GRE)

Dephasing (-G) and Rephasing (+G) forming Echo at TE
Module 03

RF Pulses & The $B_1$ Magnetic Field

An oscillating field $\vec{B}_1(t) = 2 B_1^e(t) \cos(\omega_{rf} t)\hat{x}$ creates a resonant torque in the transverse plane. In the rotating frame at $\omega_{rf} = \omega_0$:

$$\alpha = \int_0^{T_{rf}} \gamma B_1(t) \, dt \quad \stackrel{\text{Rect}}{\Longrightarrow} \quad \alpha = \gamma B_1 T_{rf}$$

By engineering RF amplitude $B_1$ and duration $T_{rf}$, any flip angle $\alpha$ ($90^\circ$ excitation, $180^\circ$ refocusing) is generated.

Interactive 3D Nutation & Slice Profiler

Live Simulation: Magnetization Dynamics

Bloch Relaxation & Recovery post Flip
Module 04

Image Formation & 2D k-Space

The received signal $S(t)$ is the continuous 2D Fourier Transform of the object spin density $\rho(x, y)$:

$$S(k_x, k_y) = \iint \rho(x, y) e^{-i 2\pi [k_x x + k_y y]} dx dy$$

Reconstruction calculates the 2D Inverse Discrete Fourier Transform (2D IDFT) of k-space samples.

Live 2D k-Space Studio on Slide

k-Space $|S(k_x, k_y)|$
Reconstructed $|\rho(x, y)|$

Live Simulation: 1D Profile via 1D FFT

1D Multi-Object Echo Reconstruction
Summary

Key Takeaways

✓ $B_0$ establishes precession frequency $\omega_0 = \gamma B_0$ and chemical shift separations.

✓ Gradients encode spatial position into frequency and phase $\phi(x) = \gamma G_x x t$.

✓ RF Pulses tip magnetization via resonant nutation $\alpha = \gamma \int B_1(t) dt$.

✓ Image Formation maps spatial frequency raw data $S(k_x, k_y)$ into anatomy via 2D IDFT.