---
title: "Diffusion encoding: how a gradient pair measures how far water moves"
description: "Two opposed gradient pulses rephase still water but not moving water. Derive the exponential decay from a random walk, compute b, and see membranes slow it."
canonical_url: "https://sandboxphysics.com/stories/mri-spatial-encoding/diffusion-encoding/"
language: "en"
page_type: "story"
alternate_languages:
  zh-CN: "https://sandboxphysics.com/zh/stories/mri-spatial-encoding/diffusion-encoding/"
last_modified: "2026-10-29"
---

[MRI spatial encoding](https://sandboxphysics.com/stories/mri-spatial-encoding/)

L3 · Chapter 7

# Diffusion encoding: how a gradient pair measures how far water moves

Sandbox Physics · 2026-10-29

The earlier chapters used gradients to encode position. The same gradients can measure motion. Put one identical gradient pulse on each side of the 180° pulse of a spin echo. Water that has not moved returns to its original phase after the second pulse; water that has moved keeps a phase proportional to how far it went. The more spread out those phases, the weaker the echo. This chapter derives the echo attenuation from a random walk, computes the b-value used in clinical scans, and looks at what happens when membranes block the water.

## Before you begin

The spin echo from Chapter 2, the gradient phase from Chapter 3 and the variance of a Gaussian distribution. The random walk is introduced from scratch in the second section.

- Explain why a pulsed-gradient spin echo is sensitive only to displacement, and write the net phase of one water molecule.
- Derive the exponential echo attenuation from a random walk and compute the b-value from the gradient waveform.
- Explain how membranes slow the echo attenuation and make the apparent diffusion coefficient depend on the pulse separation, and why the diffusion time must be reported.

## A gradient pair: still water returns, moving water keeps a phase

Hrabe and co-workers explain the principle with a diagram. A water molecule at $x$ gains the phase $\gamma Gx\delta$ during the first gradient pulse of duration $\delta$. After a wait, an equal and opposite gradient is applied. If the molecule did not move in between, all phase differences are reversed and the magnetization is fully restored.

In a spin-echo sequence the second pulse has the same sign as the first, but the 180° pulse between them flips every phase, which has the same effect as reversing the gradient. With short pulses, a molecule that moves from $x_1$ to $x_2$ ends with a phase that depends only on its displacement. Define $q=\gamma G\delta$, which is $2\pi$ times the spatial frequency $k$ of Chapter 4: the gradient pair walks out to $q$ in k-space and back to the origin.

The coil measures the average over all molecules. A uniform shift of everything changes no magnitude; only the spread of displacements makes the phases cancel. So the diffusion-weighted echo is sensitive only to random motion.

$$
\varphi=\gamma G\delta\,(x_1-x_2)=q\,(x_1-x_2),\qquad \frac{S}{S_0}=\left|\left\langle e^{i\varphi}\right\rangle\right|
$$

The net phase of one molecule for narrow pulses, and the ratio of the echo with gradients to the echo without.

Pulsed-gradient spin echo. Two equal gradient pulses of duration $\delta$ start $\Delta$ apart, one on each side of the 180° pulse. Water that stays put returns to its starting phase at the echo; water that moves from $x_1$ to $x_2$ keeps the phase $q(x_1-x_2)$. Original schematic, not to scale.

Source: J. Hrabe · F. Szczepankiewicz and J. Hutter

## A random walk and the echo attenuation

Hrabe and co-workers start from the simplest random walk: every $\Delta t$ a molecule jumps $\Delta x$ to the left or right with equal probability. After $n$ steps the variance of its position is $2Dn\Delta t$, with $D=\Delta x^2/(2\Delta t)$. Letting $\Delta t\to0$ with $D$ fixed gives continuous diffusion with $\sigma^2=2Dt$.

Each jump changes the phase by $\pm q\Delta x$. The $n$ jumps are independent, so the average phase factor over all molecules is $\cos^n(q\Delta x)$. Substituting $\Delta x=\sqrt{2D\Delta t}$ and letting $n\to\infty$ gives the exponential decay $e^{-bD}$, where $b=q^2\tau$ for narrow pulses.

The course benchmark checks both steps. The discrete walk, with 40,000 molecules and 20, 50 and 200 steps, agrees with $\cos^n$ to within 1.04 standard errors. In the continuous limit with $bD=1.07$, $n=10\,000$ steps give 0.342995 against the limit 0.343009.

$$
\frac{S}{S_0}=\cos^n\!\left(\sqrt{\frac{2bD}{n}}\right)\;\xrightarrow{\,n\to\infty\,}\;e^{-bD}
$$

Eqs. (14) to (16) of Hrabe and co-workers.

Source: J. Hrabe · F. Szczepankiewicz and J. Hutter

## The b-value from the gradient waveform

When the pulses are not short, molecules also move during them, and $b$ has to be computed from the whole waveform. The ISMRM 2019 problem set gives the general definition: $q(t)$ is the gradient area accumulated up to time $t$ (times $\gamma$), and $b$ is the time integral of $q^2$. For two rectangular pulses the integral splits into three parts: each pulse contributes $q^2\delta/3$ and the gap between them $q^2(\Delta-\delta)$, which adds up to the Stejskal–Tanner formula.

The answer key also notes that the diffusion time has no simple definition, because it depends on the tissue architecture; experiments on time-dependent diffusion should report the whole waveform, such as $\Delta$ and $\delta$. When all three gradient axes play the same waveform, the gradient grows by $\sqrt3$ and $b$ by 3, to about $1.6\,\mathrm{ms/\mu m^2}$.

The diffusion-encoding experiment accumulates each molecule’s phase step by step and does not use the $b$ formula; the benchmark integrates the experiment’s timing numerically and agrees with the closed form above to $7.7\times10^{-13}$ or better.

$$
b=\int_0^{T}q(t)^2\,dt,\qquad q(t)=\gamma\int_0^{t}G(t')\,dt'
$$

The general definition of problem A2 of the ISMRM 2019 set. The 180° pulse is written as a sign flip of the effective gradient.

$$
b=\gamma^2G^2\delta^2\left(\Delta-\frac{\delta}{3}\right)
$$

Rectangular pulses; $\Delta$ is the separation between the starts of the two pulses.

Source: F. Szczepankiewicz and J. Hutter · J. Hrabe

## Worked example: 40 mT/m, 10 ms, 50 ms

Problem: the settings of the ISMRM problem and the default of the diffusion-encoding experiment. A 40 mT/m gradient, 10 ms pulses 50 ms apart, and free water with $D=2.0\,\mathrm{\mu m^2/ms}$ (the value the experiment assumes). Find $q$, $b$, the echo ratio, the standard deviation of the phase and the typical displacement between the pulses.

$\gamma G=2.675\times10^8\times0.04=1.07\times10^7\,\mathrm{rad\,s^{-1}m^{-1}}$, or $0.0107\,\mathrm{rad\,ms^{-1}\mu m^{-1}}$, the number in the problem set. Then $q=0.0107\times10=0.107\,\mathrm{rad/\mu m}$: a molecule must move 59 µm for its phase to turn once. $b=0.107^2\times(50-10/3)=0.534\,\mathrm{ms/\mu m^2}=534\,\mathrm{s/mm^2}$; the answer key gives 0.53.

The echo ratio is $e^{-bD}=e^{-1.0686}=0.3435$. The phase is close to Gaussian with variance $2bD$, so its standard deviation is $\sqrt{2.137}=1.46\,\mathrm{rad}$. The typical displacement along the gradient is $\sqrt{2D\Delta}=\sqrt{200}=14.1\,\mathrm{\mu m}$, about one cell, yet enough to cut the echo to a third.

The experiment simulates 6000 molecules and reads an echo ratio of 0.356 with a standard error of 0.012, about one standard error from 0.3435; fitting nine gradient strengths gives an apparent diffusion coefficient of $1.94\,\mathrm{\mu m^2/ms}$. The benchmark checks 20,000 molecules at six gradient strengths, with a largest deviation of 0.64 standard errors.

Source: F. Szczepankiewicz and J. Hutter · J. Hrabe

## Water between membranes: the echo decays more slowly

Hrabe and co-workers recall that Tanner and Stejskal first proposed measuring restricted diffusion by varying the delay between the pulses: the signal from water held in by cell walls decays less than that from free water, and they used this to estimate the diameter of yeast cells. Hrabe and co-workers also note that with a very short diffusion time most molecules hit no wall and the process is close to free diffusion; a longer time lets molecules explore the structure. Results from different diffusion times cannot be mixed, and the diffusion time should always be reported.

The diffusion-encoding experiment models this with parallel membranes a distance $L$ apart that reflect any molecule hitting them. With the default gradient and $L=20\,\mu\mathrm m$, the echo ratio rises from 0.3435 for free water to 0.739 and the apparent diffusion coefficient falls to 0.588. Lengthening the separation to 90 ms would take free water down to 0.137, but water between membranes only to 0.713, and the apparent diffusion coefficient to 0.367. With membranes 5 µm apart the echo ratio is 0.995, almost no decay.

Under restriction a single exponential no longer fits. The experiment holds out the largest usable $b$ and predicts it from an exponential fitted to the other points: the miss is 2.5% for free water, −5.1% between membranes and −12.6% after the longer wait. When the wait is very long, a molecule’s positions at the two pulses are independent and each is uniform between the membranes, so the echo ratio tends to $\operatorname{sinc}^2(qL/2)$. This derivation is the course’s own. The benchmark checks it with $L=10\,\mu\mathrm m$, 0.2 ms pulses and a 100 ms separation: the largest difference is 0.0045, and the root-mean-square displacement is 4.081 µm against the limit $L/\sqrt6=4.082\,\mu\mathrm m$.

$$
\frac{S}{S_0}\;\xrightarrow{\,\Delta\gg L^2/D\,}\;\left[\frac{\sin(qL/2)}{qL/2}\right]^2
$$

The limit for narrow pulses, reflecting membranes and a wait much longer than the time to cross between them.

Source: J. Hrabe · F. Szczepankiewicz and J. Hutter

## Try it in the Lab

### [Let the gradient pair measure how far water moves](https://sandboxphysics.com/labs/mri-diffusion-encoding/)

1. In the “Free water, a clinical b-value” preset, watch the phase distribution spread out and read the 0.356 echo ratio and the $534\,\mathrm{s/mm^2}$ b-value.
2. Choose “Double the gradient: four times b”. Predict an echo ratio of $e^{-4.27}$, about 0.014. The experiment shows about 0.03; compare it with the 0.013 standard error and think about why an echo ratio near zero reads high.
3. Choose “Water between membranes”, then “Wait longer: walls matter more”. Predict that b grows, the echo ratio hardly changes and the apparent diffusion coefficient falls. Check against the 0.588 and 0.367 readouts.

## Exercises with explained answers

1. Only the pulse separation changes, from 50 ms to 15 ms. What are $b$ and the free-water echo ratio?

   Show the answer

   $b=0.107^2\times(15-10/3)=0.134\,\mathrm{ms/\mu m^2}$ and the echo ratio is $e^{-0.267}=0.766$. The “Pulses close together” preset of the experiment reads 0.760 with a standard error of 0.008.

2. With the gradient doubled the theory gives an echo ratio of 0.0139, but the experiment reads about 0.030. Why?

   Show the answer

   The echo ratio is the magnitude of a complex average. The average over 6000 molecules keeps a random remainder of order 0.01, and taking the magnitude cannot cancel it to zero, so a very small true value reads high. That is why the fit of the apparent diffusion coefficient uses only points with an echo ratio above 0.15 and above four standard errors.

3. Membranes are $L=5\,\mu\mathrm m$ apart and the wait is long enough. What is the root-mean-square displacement between the two pulses?

   Show the answer

   It is the difference of two independent uniform distributions, with variance $2\times L^2/12=L^2/6$ and root mean square $5/\sqrt6=2.04\,\mu\mathrm m$. The “Tightly packed membranes” preset of the experiment reads 2.05 µm.

[Previous: Undersampled reconstruction: why random skipping can be repaired and regular skipping cannot](https://sandboxphysics.com/stories/mri-spatial-encoding/undersampling-and-regularized-reconstruction/) [Next: Reading the 2007 Sparse MRI paper by Lustig, Donoho and Pauly](https://sandboxphysics.com/stories/mri-spatial-encoding/reading-lustig-2007/)

## Sources and what we recomputed

1. [J. Hrabe, G. Kaur and D. N. Guilfoyle, Principles and limitations of NMR diffusion measurements, Journal of Medical Physics 32(1), 34–42 (2007), doi:10.4103/0971-6203.31148](https://pmc.ncbi.nlm.nih.gov/articles/PMC3003887/)

   Read in full (PubMed Central). Introduction: Hahn’s 1950 observation, the Stejskal–Tanner pulsed gradients and Eqs. 1–3. Eqs. 4–10 (the binomial random walk, D from Eq. 7, Einstein’s relation in Eqs. 8 and 10). Eq. 11 (Larmor frequency, with 2π × 42.576 MHz/T for the proton). Eqs. 12–14 (signal of the lattice walk, the b-value of Eq. 13 and the discrete Stejskal–Tanner form) and Eqs. 15–17 (the continuous limit). The pitfalls section: imaging gradients, local gradients, dependence on the diffusion time and tissue compartments. The 1950 and 1965 papers it cites were not opened.

2. [F. Szczepankiewicz and J. Hutter, Diffusion MRI acquisition basics, problems and answers, ISMRM 2019 educational session](https://www.ismrm.org/dmff-uploads/2s.pdf)

   Read in full. Problem A1 and its answer (Eqs. 2–4): two 40 mT/m, 10 ms pulses with onsets 50 ms apart give 0.53 ms/µm², and three axes together triple b. Problem A2 and its answer (Eqs. 1 and 5–7): b as the time integral of q squared and its closed form for rectangular pulses. Part B: the echo-time budget of a spin-echo diffusion sequence. The value of γ used there is 2.68 × 10⁸ per second per tesla.
