Diffusion MRI

From water molecules to white-matter statistics.

Diffusion MRI measures how far water travels in a few tens of milliseconds. Because axons get in the way, that measurement carries the orientation and integrity of white matter. Getting from the raw signal to a defensible result takes eight steps. Every one of them has a demo you can break.

01

What the scanner measures

A diffusion-weighted sequence applies two strong, brief magnetic field gradients separated by a short delay. The first one tags each water molecule with a phase that depends on its position. The second one undoes that tag, but only for molecules that have not moved. Molecules that diffused during the delay end up with a leftover phase, and their signals no longer add up coherently. The more motion along the gradient direction, the more signal is lost.

How aggressively the sequence probes diffusion is summarised by the b-value, in s/mm². It combines gradient strength, duration, and the delay between the two pulses. For simple Gaussian diffusion the measured signal is

S(b) = S₀ · exp(−b · D)

where D is the apparent diffusion coefficient along the gradient direction. In the brain, D is about 3 µm²/ms in cerebrospinal fluid, under 1 in gray matter, and in white matter it depends on where you look: roughly 1.7 along a bundle and 0.3 across it. That directional dependence is the entire reason the method works.

Try it

How much signal survives a diffusion gradient

0.000.250.500.751.000100020003000b (s/mm²)S / S₀
■ CSF: 0.05
■ Gray matter: 0.45
■ White matter, gradient 0° to fiber: 0.18
Effective D along gradient in WM: 1.70 µm²/ms
Signal falls exponentially with b-value, faster where water moves more freely. Along an axon bundle water travels far (strong attenuation); across it, membranes get in the way. That gap is the whole basis of diffusion MRI.

Typical clinical research protocols use b = 1000 s/mm² with 30 to 64 gradient directions. Multi-shell protocols add b = 2000 or 3000 to support richer models. Higher b means more contrast between fiber populations and less signal overall, so the two are always traded against each other.

02

What a diffusion dataset looks like

A diffusion acquisition is not one image. It is a stack: a few images with no diffusion weighting (the b=0 volumes, which look like a blurry T2-weighted scan), then one volume per gradient direction. Each of those is the same slice with signal removed wherever water moved along that particular direction. The dataset arrives as a 4D NIfTI file plus two text files, .bval and .bvec, listing the b-value and the unit gradient vector for every volume.

Try it

A single diffusion-weighted image

Mean WM signal, b=0: 0.00
Mean WM signal, b=1000: 0.00
Attenuation: NaN
Left: the b=0 image, essentially T2-weighted. Right: the same slice after a diffusion gradient. Rotate the gradient and watch the fiber bundles brighten when they run across it and darken when they run along it. Ventricles go dark first: free water.

Look at the two vertical bundles when the gradient points straight up: they darken, because water slides freely along the axons. Turn the gradient horizontal and they brighten, because membranes hinder motion across the fibers. The curved bundle shows the same effect but in a direction that changes along its length. A single voxel's signal across all directions is what every later model works from.

The .bvec file is written in the scanner's or converter's coordinate frame, not necessarily the image's. A sign flip in one axis produces tracts that look plausible and are completely wrong. Always check the gradient table visually, for example by confirming the corpus callosum is red (left–right) on a direction-encoded map.

Tools: dcm2niix converts DICOM to NIfTI and writes the bval/bvec files. dwigradcheck in MRtrix3 tests the gradient table by running short tractography with each possible flip.

03

Artifacts, and where they come from

Diffusion images are acquired with echo-planar imaging, which reads an entire slice in about 50 ms to freeze motion. The price is that EPI is fragile. Three artifacts show up in almost every dataset, and all three are easiest to understand in k-space, the grid of spatial frequencies the scanner actually samples. The image is the inverse Fourier transform of that grid.

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.

Noise

Diffusion weighting throws signal away on purpose, so these are among the noisiest images in MRI. Worse, the magnitude operation turns zero-mean Gaussian noise into a Rician distribution with a positive floor, which biases every later estimate upward at low signal. Modern pipelines denoise first, usually with Marchenko–Pastur PCA, which separates the noise eigenvalues of a local patch from the signal ones.

Gibbs ringing

The scanner only samples k-space out to some maximum frequency. Truncating a Fourier series makes sharp edges overshoot and ring. Around the ventricles the ringing can push a white-matter voxel's b=0 signal below its diffusion-weighted signal, producing a negative diffusivity. Partial Fourier acquisitions make it worse. The standard fix shifts the image by sub-voxel amounts to find the position that minimises the oscillation.

Motion

If the head moves during a few phase-encode lines, those lines carry the wrong phase, and the reconstruction smears copies of the brain along the phase-encode axis. Within a single EPI shot this is rare, but slow drift between volumes is universal and is handled in the next step.

Tools: dwidenoise and mrdegibbs (MRtrix3), Patch2Self (DIPY).

04

Preprocessing: making the volumes agree

Every model in the next steps assumes that voxel (x, y, z) refers to the same piece of tissue in all 60-odd volumes. Three things break that assumption.

  • Eddy currents. Switching the diffusion gradients on and off induces currents in the scanner's conductors, which produce their own small, slowly decaying fields. Each gradient direction induces a different one, so each volume is stretched, sheared, and shifted slightly differently along the phase-encode axis.
  • Subject motion. A diffusion scan takes five to fifteen minutes. People drift. Each volume ends up in a slightly different position, and the gradient table needs rotating to match.
  • Susceptibility distortion. Air in the sinuses and ear canals warps the main field, and EPI's slow phase-encode direction turns that into stretching and pile-up of signal near the frontal and temporal poles. It is the same in every volume, so it is fixed separately, usually from a pair of b=0 images acquired with opposite phase-encode directions.
Try it

Why eddy-current and motion correction come first

Mean FA in head: 0.000
Corrected reference: ≈0.33
Each diffusion-weighted volume is warped slightly differently, because each gradient induces its own eddy currents, and the subject drifts between volumes. Fit a tensor to misaligned volumes and you get bright rims and smeared directions at every tissue edge. Correction aligns the volumes before any model is fit.

Notice what misalignment does to the fit: FA lights up around every edge, because the model sees a signal that changes between volumes and attributes it to anisotropy. The directions in the color map become noisy. None of this is subtle, and none of it is reversible once a model has been fit. Preprocessing is not optional.

Tools: topup and eddy (FSL), dwifslpreproc (MRtrix3 wrapper), QSIPrep (an end-to-end preprocessing pipeline), SynB0-DisCo for distortion correction without a reverse-phase scan.

05

Fitting a model: the diffusion tensor

With clean, aligned volumes, each voxel has one signal value per gradient direction. The oldest and still most common model, diffusion tensor imaging, assumes diffusion is Gaussian but can differ by direction, which is exactly a 3×3 symmetric matrix D. The signal model becomes

S(b, g) = S₀ · exp(−b · gᵀ D g)

Taking the logarithm makes this linear in the six unknown elements of D plus ln S₀, so with at least seven measurements (one b=0 and six directions) it is an ordinary least-squares problem. In practice 30 or more directions are used to beat down noise. Decomposing D into eigenvalues and eigenvectors gives everything the field reports:

  • Mean diffusivity (MD): the average of the three eigenvalues. Overall mobility.
  • Fractional anisotropy (FA): how unequal the eigenvalues are, from 0 (sphere) to 1 (line). The most-reported number in the field.
  • Axial and radial diffusivity: the largest eigenvalue, and the mean of the other two.
  • The principal eigenvector: the estimated fiber direction, shown as red–green–blue for left–right, front–back, up–down.
Try it

The diffusion tensor as a shape

λ₁λ₂λ₃drag to rotate
FA: 0.799
MD: 0.77 µm²/ms
Axial (λ₁): 1.70 · Radial ((λ₂+λ₃)/2): 0.30
A tensor is an ellipsoid whose radii are the root-mean-square distances water travels along each axis. Long and thin means coherent fibers. A sphere means nothing is organized, or everything is organized in every direction, which is the problem the next demo is about.

FA is not a measure of "white-matter integrity", however often the phrase appears. It drops when fibers cross, when axons fan, when a bundle is partial-volumed with cortex, and when SNR falls. It rises in the ventricle edge voxels that Gibbs ringing corrupts. Interpreting an FA change requires knowing which of those changed.

Tools: dtifit (FSL), dwi2tensor (MRtrix3), DIPY's TensorModel, DSI Studio's reconstruction step.

06

Beyond the tensor: crossing fibers

A 2 mm voxel contains hundreds of thousands of axons, and in most of the white matter they do not all point the same way. Where the corpus callosum passes through the corticospinal tract, or where association bundles fan into cortex, a single ellipsoid cannot describe what is there. The tensor fit does not fail loudly; it returns a flattened disc with a low FA and a principal direction that points between the bundles.

Try it

Two bundles in one voxel

true ODFsingle tensor fit
Fitted FA: 0.599 (each bundle alone: 0.84)
Angular error of e₁: 29.7°
MD: 0.72 µm²/ms
Teal: the true orientation distribution of a voxel containing two fiber populations. Amber: the single tensor a DTI fit returns for it. At wide crossing angles the tensor becomes a flattened disc pointing between the bundles, with low FA, even though both bundles are perfectly healthy. Roughly a third of white-matter voxels look like this.

Models that handle this estimate an orientation distribution function, a function on the sphere with a peak for each fiber population, instead of a single direction. The main families:

  • Constrained spherical deconvolution (CSD) assumes every bundle has the same response function, measured from the most coherent voxels, and deconvolves it out of the signal to leave the fiber orientation distribution.
  • Q-ball and generalized q-sampling imaging (GQI) reconstruct the diffusion ODF more directly from the signal without assuming a response function. GQI is what DSI Studio uses, and it works on any sampling scheme.
  • Multi-compartment models such as NODDI or ball-and-stick fit explicit tissue compartments and report their volume fractions, at the cost of stronger assumptions.

These need more and higher-b measurements than a tensor, which is why modern protocols are multi-shell. For scalar metrics GQI gives quantitative anisotropy (QA) per fiber peak rather than one FA per voxel, which is what makes tract-specific statistics possible later.

07

Tractography

Tractography reconstructs the long-range path of bundles by following local fiber directions from voxel to voxel. The deterministic version is nothing more than numerical integration: start at a seed, read the direction, step a fraction of a voxel, read again. Three parameters govern nearly everything about the result.

  • Step size: smaller follows curves better and takes longer.
  • Angular threshold: the sharpest turn allowed between steps. Too permissive and streamlines jump between bundles; too strict and they stop in curved ones.
  • Termination threshold: stop when anisotropy drops, which keeps streamlines out of gray matter and CSF but also kills them in crossings if the metric is FA.
Try it

Streamline tractography, step by step

Streamlines: 0
Mean length: 0 mm
Start at a seed, read the fiber direction in that voxel, take a small step, repeat. Stop when the direction turns too sharply or anisotropy falls too low. With one tensor per voxel the streamlines die or jump where the arc crosses the vertical bundles. Switch to multi-fiber peaks and they pass through.

Probabilistic tractography samples the direction from the ODF instead of taking its peak, producing thousands of slightly different streamlines whose density reflects uncertainty. It finds more of the true pathways and also more false ones. Either way, the output is a set of polylines, and the step that matters most is the one after: filtering, by anatomical constraints, by whether a streamline connects plausible endpoints, or by whether its path is consistent with the signal (SIFT, LiFE).

A streamline is a hypothesis, not an axon. Tractography has a known tendency to generate many more false-positive bundles than false negatives, and the count of streamlines between two regions is not a measure of connection strength. Treat tracts as regions of interest for measuring something else, not as the measurement itself.

Tools: tckgen and tcksift (MRtrix3), DSI Studio's fiber tracking with its automatic tract recognition, DIPY's LocalTracking, TrackVis.

08

Group analysis: turning maps into a claim

Every subject now has a map of FA, QA, or whatever metric the model produced, and a set of tracts. The research question is almost always comparative: does the metric differ between groups, change over time, or correlate with a score? Three strategies dominate.

  • Region or tract averaging. Define a bundle, average the metric inside it, get one number per subject, run an ordinary test. Robust, low-powered, and blind to where along the bundle the effect sits.
  • Voxel-wise and skeleton-based comparison (TBSS). Warp every subject's map to a template, project onto a white-matter skeleton to limit misalignment, test every skeleton voxel. The multiple-comparison problem is enormous, so inference is permutation-based.
  • Connectometry and correlational tractography. Instead of testing voxels, test local fiber segments and track along the ones whose metric correlates with the variable of interest. The result is a tract, not a blob, and significance comes from permuting the variable and tracking again to see how long a spurious tract can get.
Try it

Finding a group difference along a tract, honestly

group Agroup Bmean FA|t| per positionuncorrectedpermutation FWEposition along tract
Uncorrected: 14 positions, 2 outside the true span
Permutation FWE: 2 positions, 0 outside
Thresholds: |t| > 2.05 vs 3.83
Top: mean FA along a tract for two groups, with a real difference planted in the shaded span. Bottom: the t-statistic at each position. The dashed line is the usual p < 0.05 cutoff applied 60 separate times; the solid line is the threshold from permuting group labels and recording the largest statistic each time. Permutation keeps false positives honest, which is why connectometry and TBSS both use it.

The common thread is permutation. Every method above runs the analysis many times on shuffled labels and asks how extreme the real result is against that distribution. It is slow, it is honest, and it is the only part of the pipeline that directly controls how often you publish noise.

Before any of this works, subjects must be in a common space. For diffusion data that means either warping scalar maps with a nonlinear registration or, in DSI Studio's case, building a population-average template of the ODFs themselves so that fiber orientations, not just intensities, align across people.

Tools: randomise and TBSS (FSL), DSI Studio connectometry, fixelcfestats (MRtrix3's fixel-based analysis), TractSeg for automatic bundle segmentation.

Try it on real data

Fit a tensor to your own scan

Load a NIfTI file with its bval and bvec in the browser and get FA, MD, and a direction map. Nothing is uploaded.

Open the viewer