Structural MRI

From relaxation times to cortical thickness.

A structural scan is the anatomical backbone of nearly every study: the image other modalities are aligned to, the source of tissue volumes and cortical thickness, and the thing a radiologist actually reads. Its pipeline is shorter than diffusion's but every step is reused by the others.

01

Where contrast comes from

MRI does not image tissue directly. It tips the magnetisation of hydrogen nuclei out of alignment and listens to them relax back. Two time constants describe that relaxation and differ by tissue: T1, how fast longitudinal magnetisation recovers, and T2, how fast transverse magnetisation decays. A third quantity, proton density, is simply how much water is there.

A sequence chooses how much each of these matters through its timing. For a spin echo:

S = PD · (1 − exp(−TR / T1)) · exp(−TE / T2)

Short TR punishes tissue with slow T1 recovery, long TE punishes tissue with fast T2 decay. White matter has the fastest T1, cerebrospinal fluid by far the slowest, which is why the same head can look like a negative of itself between two scans acquired minutes apart.

Try it

Dial in a contrast

CSF: T1 4000 · T2 2000 ms → 0.12
Gray matter: T1 1330 · T2 110 ms → 0.24
White matter: T1 830 · T2 80 ms → 0.27
Same slice, same tissue, different timing. Short TR and TE make tissue with fast T1 recovery (white matter) bright: T1-weighted. Long TR and TE let slow-T2 tissue (CSF) keep its signal: T2-weighted. Inversion recovery with the right TI nulls CSF entirely: FLAIR, which is why lesions next to ventricles become visible.

Most research protocols acquire a high-resolution 3D T1-weighted image (MPRAGE or similar, around 1 mm isotropic) as the anatomical reference. T2-weighted and FLAIR scans are added when lesions, edema, or ventricles are the question. FLAIR is T2 contrast with the CSF signal nulled by an inversion pulse, so a bright periventricular lesion no longer hides next to bright ventricles.

Tools: contrast is fixed at acquisition; the choice lives in the sequence protocol, not in software.

02

From k-space to image

The scanner samples spatial frequencies, not pixels. Each readout traverses a line of k-space, and the image is the inverse Fourier transform of the full grid. Resolution is set by how far out in k-space you sample; field of view by how finely. Three artifacts that every analyst meets live here.

Try it

Where artifacts come from: the k-space view

Effective matrix: 128 × 128
Effective voxel: 2.0 mm (nominal 2 mm)
The scanner never records the image; it records its spatial frequencies. Keep fewer of them and edges ring (Gibbs ringing). Add noise and it spreads everywhere. Move during a few phase-encode lines and the whole image ghosts. Each one is a separate preprocessing step later.
  • Gibbs ringing at sharp edges, from truncating the sampled frequencies. On T1 images it shows up as faint stripes parallel to the skull and ventricles.
  • Motion during acquisition corrupts phase-encode lines and ghosts the whole image. Structural scans take five to eight minutes, so this is the most common reason a scan is unusable. Prospective motion correction and quick quality ratings catch it.
  • Noise, which for parallel-imaging reconstructions is also spatially varying, denser where the coils see less.

Reconstruction happens on the scanner and produces DICOM files; the first software step in any pipeline is converting them to NIfTI, a single header plus voxel array with an affine matrix that says where in the scanner each voxel sits. That affine is the thread every later step depends on.

Tools: dcm2niix for conversion, MRIQC for automated quality metrics.

03

Bias field and skull stripping

The receive coil is closer to some parts of the head than others, so the same tissue is brighter near the coil elements and darker in the centre. The result is a smooth multiplicative bias field across the image. Human eyes ignore it. Intensity classifiers do not. Bias correction estimates that smooth field, usually by iteratively sharpening the intensity histogram, and divides it out.

Skull stripping removes everything that is not brain: scalp, skull, eyes, neck. It matters because the next steps are statistical, and fat in the scalp has a T1 signal that looks like white matter. Historically a source of endless manual fixing; deep learning tools have made it close to solved for healthy adult heads.

Skull stripping fails quietly at the inferior temporal lobes and the top of the cortex. Check the mask on every subject before anything is computed from it. The same goes for bias correction on scans with large lesions, where the "smooth field" assumption breaks.

Tools: N4BiasFieldCorrection (ANTs), bet (FSL), SynthStrip (FreeSurfer), HD-BET.

04

Segmentation and volumes

With a clean, bias-corrected T1 image, voxels can be assigned to tissue. The simplest approach is to cluster intensities: on a T1 image, CSF is darkest, gray matter in the middle, white matter brightest. Real tools add two things on top of that: a spatial prior (an atlas saying how likely each tissue is at each location) and a model of partial volume, since a 1 mm voxel at the cortical boundary contains both gray and white matter.

Try it

Segmenting tissue by intensity, and why bias correction comes first

Dice vs truth · CSF 0.00 · GM 0.00 · WM 0.00
Classifying voxels by brightness alone works when each tissue has one brightness. A receive-coil bias field makes one side of the brain brighter than the other, so white matter on the dark side gets labelled gray. Correct the field and the same simple classifier recovers.

From the segmentation come the numbers people report: total intracranial volume, gray and white matter volume, ventricle volume, and, via a very different surface-based pipeline, cortical thickness. The surface approach fits a mesh to the white-matter boundary and another to the pial surface and measures the distance between them, which sidesteps the voxel grid entirely and is far more sensitive to thinning than volume is.

Volumes depend on the scanner, the sequence, the software version, and the head size. Compare within a study processed identically, normalise by intracranial volume when the question is relative, and never mix FreeSurfer versions in one cohort.

Tools: fast (FSL), SPM's unified segmentation, FreeSurfer's recon-all for surfaces and thickness, FastSurfer and SynthSeg for fast deep-learning equivalents.

05

Registration and templates

Almost every multi-subject analysis needs voxels to correspond across people, and almost every multi-modal analysis needs a subject's diffusion or functional data aligned to their own anatomy. Both are registration: find the transform that maps one image onto another by minimising a cost function.

Try it

Registration as an optimisation problem

Cost (MSE): 0.00e+0
Accepted steps: 0
True misalignment: -9, 6 px · -14°
Two images of the same head, one moved. Registration searches for the transform that makes them agree, by scoring every candidate with a cost function and walking downhill. Here the cost is mean squared difference and the search is a naive coordinate descent. Real tools use smarter metrics (mutual information, cross-correlation), multi-resolution pyramids, and far more degrees of freedom.

The demo uses six parameters (really three, in 2D). Real registration climbs a ladder:

  • Rigid: rotation and translation. Same person, different session.
  • Affine: adds scaling and shear. Gross size differences between people.
  • Nonlinear (deformable): a smooth warp field with millions of parameters, regularised so it stays plausible. This is what maps individual anatomy onto a template such as MNI152.

The cost function matters as much as the transform. Mean squared difference only works when intensities match; mutual information handles different contrasts, which is how a T1 and a b=0 diffusion image can be aligned at all. Everything downstream, from voxel-based morphometry to the TBSS skeleton in the diffusion walkthrough, inherits whatever misalignment survives this step.

Tools: flirt and fnirt (FSL), ANTs antsRegistration (the usual accuracy benchmark), SPM normalise, bbregister for boundary-based functional-to-anatomical alignment.

Try it on real data

Segment your own T1

Load a structural NIfTI and run a three-class segmentation in the browser. See where intensity alone gets it right and where it needs priors.

Open the viewer