An MRI scanner never measures an image directly: it samples the Fourier transform of the
transverse magnetisation — k-space. This app simulates the chain from tissue physics to image reconstruction.
1 · Tissue contrast
A procedural axial brain slice (scalp, diploë, CSF, folded cortex, white matter, basal ganglia, ventricles and an
optional tumour with oedema) is stored as partial-volume tissue fractions. Each tissue has proton density and relaxation times at 1.5 T:
SE : S = PD·(1 − e^(−TR/T1))·e^(−TE/T2)
IR : S = PD·|1 − 2e^(−TI/T1) + e^(−TR/T1)|·e^(−TE/T2)
GRE: S = PD·sinα·(1 − E1)/(1 − cosα·E1)·e^(−TE/T2*)
Short TR/TE → T1-weighting; long TR/TE → T2-weighting. FLAIR chooses TI ≈ T1CSF·ln 2 to null
fluid, STIR nulls fat.
2 · k-space
The complex image (with a smooth coil/B₀ phase) is transformed with a centred 2-D FFT. The centre of k-space holds
contrast, the periphery holds edges. Every phase-encode line costs one TR, so scan time = lines × TR.
3 · Sampling & artefacts
- Low-pass → blur and Gibbs ringing · high-pass → edge image.
- Uniform R× undersampling → fold-over aliasing (what parallel imaging unfolds).
- Random variable-density → incoherent, noise-like aliasing that sparsity priors can remove.
- Radial spokes → streaks; partial Fourier → exploits Hermitian symmetry.
- A single corrupted sample (RF spike) gives a herring-bone pattern; line-to-line phase errors from motion give ghosts along the phase-encode direction.
4 · Reconstruction
Zero-filled: inverse FFT with missing samples set to zero. Compressed sensing: FISTA on
min ½‖M·F·x − y‖² + λ‖Ψx‖₁ (Ψ = 4-level Haar wavelet)
where each iteration enforces data consistency in k-space and soft-thresholds wavelet coefficients.
POCS fills unmeasured partial-Fourier lines using the phase of a low-resolution centre.
Things to try
- Click FLAIR: CSF goes dark and the oedema lights up.
- Pick “Uniform undersampling”, R = 3 — then switch to random sampling and CS.
- Brush-erase the centre of k-space and watch the contrast disappear.
- Simulate a T2 acquisition and note the scan time.