NMR and MRI physics · Advanced

Diffusion weighting: the Stejskal-Tanner pulsed-gradient spin echo

Written by SignalsLab

Early edition: these lessons are being reviewed.

Content

Summary

The Stejskal-Tanner pulsed-gradient spin echo (PGSE) sequence places two identical gradient pulses on either side of the 180-degree refocusing pulse. Static spins rephase perfectly, but spins that diffuse between the pulses acquire a net phase error, so the echo is attenuated by exp(-bD). The b-value summarizes the gradient strength, duration and spacing, and lets us measure the diffusion coefficient D.

Intuition

A gradient makes the Larmor frequency depend on position, so each spin accumulates phase according to where it is. The first gradient pulse winds up a position-encoded phase. The 180-degree pulse flips the sign of that phase, and the second identical pulse unwinds it. If a spin has not moved, the two contributions cancel exactly. If it has moved by random Brownian motion during the diffusion time, it sees a different gradient strength the second time, and the cancellation is incomplete. Across a voxel, these random leftover phases form a spread, and the vector sum of the transverse magnetization shrinks. Faster diffusion, larger gradients and longer diffusion times all give more signal loss. The simulation shows an ensemble of spin arrows fanning out as D or b increases.

Key equations

S=S0e−bD
(1)

Mono-exponential diffusion attenuation, with S_0 the signal at b=0 (including T2 decay).

b=γ2G2δ2(Δ−δ3)
(2)

Stejskal-Tanner b-value for rectangular pulses of amplitude G, duration δ, onset separation Δ.

ϕ=γ∫𝐆⋅𝐫(t)dt
(3)

Phase accumulated by a spin moving along a path r(t) in gradient G.

ln⁡(S/S0)=−bD
(4)

Linearized form; the slope of log signal against b gives D.

Derivation

  1. Take a spin at position 𝐫 in gradient 𝐆: its phase is γ𝐆⋅𝐫×time. Before the 180-degree pulse the phase is ϕ1=γ𝐆δ𝐫1 (taking 𝐫1 as the effective position during pulse 1).
  2. The 180-degree pulse inverts the phase, so after pulse 2 the net phase is ϕ=γGδ(r2−r1), which is zero for static spins.
  3. For free diffusion in 1D, the displacement r2 - r1 is Gaussian with zero mean and variance 2DΔ (to be exact, the effective variance is 2D(Δ - δ/3) once motion during the pulses is included).
  4. The phase is therefore Gaussian with variance σϕ2=γ2G2δ2⋅2D(Δ−δ/3).
  5. Averaging exp(i phi) over a Gaussian distribution gives exp(-sigma_phi^2 / 2).
  6. Hence S/S0=exp⁡(−γ2G2δ2(Δ−δ/3)D)=exp⁡(−bD).

Worked example

Problem

A PGSE experiment uses G = 40 mT/m, delta = 20 ms, Delta = 40 ms, for protons (gamma = 2.675e8 rad/s/T). Compute b, and the signal ratio S/S0 for free water with D = 2.0e-9 m^2/s.

  1. gamma G delta = 2.675e8 × 0.040 × 0.020 = 2.14e5 rad/m.
  2. Square it: (2.14e5)^2 = 4.58e10 rad^2/m^2.
  3. Effective time: Δ−δ/3=0.040−0.00667=0.03333 s.
  4. b = 4.58e10 × 0.03333 = 1.53e9 s/m^2 = 1530 s/mm^2.
  5. bD = 1.53e9 × 2.0e-9 = 3.05.
  6. S/S0=exp⁡(−3.05)=0.047.

Answer b is about 1.5×10^3 s/mm^2, and free water retains only about 5% of its signal.

Common mistakes

  • Forgetting the delta/3 correction and using b=γ2G2δ2Δ.
  • Mixing units: G in mT/m, times in ms, and D in mm^2/s versus m^2/s.
  • Thinking the signal loss is T2 decay; T2 weighting is the same in the b=0 image, so it cancels in the ratio S/S0.
  • Assuming the gradients must have opposite sign: with a 180-degree pulse between them they have the same sign.
  • Using mono-exponential D in tissue as the true diffusivity: restriction and perfusion make it an apparent coefficient (ADC).

Animation

Animation coming soon

The animated version of this lesson is being prepared for the web. In the Signals AI app, lessons are drawn step by step.

Code

scene.py(112 lines)
from manim import *
from blocks import *
from mri_blocks import *
import numpy as np
import sys

# ---- sequence timing (ms) ----
T_MAX = 70.0
TE = 60.0
DELTA_SMALL = 10.0      # gradient duration delta
G1 = 10.0               # first lobe start
G2 = G1 + 30.0          # second lobe start (Delta = 30 ms)
BIG_DELTA = G2 - G1
C_GRAD = 0.0115         # gamma*G in rad/(um*ms)
L_HALF = 60.0           # spins spread over [-L, L] um
DT = 0.25               # fixed time step (ms)


def b_value():
    """Stejskal-Tanner b = (gamma G delta)^2 (Delta - delta/3), in ms/um^2."""
    return (C_GRAD * DELTA_SMALL) ** 2 * (BIG_DELTA - DELTA_SMALL / 3)


def grad_on(t):
    """Gradient amplitude factor (0 or 1) at time t."""
    return 1.0 if (G1 <= t < G1 + DELTA_SMALL) or (G2 <= t < G2 + DELTA_SMALL) else 0.0


def simulate(D, n=2000, seed=1):
    """Random-walk spins through the PGSE; return times, |S|(t), phase history."""
    rng = np.random.default_rng(seed)
    x = rng.uniform(-L_HALF, L_HALF, n)
    phi = np.zeros(n)
    steps = int(round(TE / DT))
    ts, S, ph = [0.0], [1.0], [phi.copy()]
    for k in range(steps):
        t = k * DT
        phi = phi + C_GRAD * grad_on(t + DT / 2) * x * DT
        x = x + np.sqrt(2 * D * DT) * rng.standard_normal(n)
        if abs(t + DT - TE / 2) < 1e-9:   # 180 pulse inverts phase
            phi = -phi
        ts.append(t + DT)
        S.append(abs(np.mean(np.exp(1j * phi))))
        ph.append(phi.copy())
    return np.array(ts), np.array(S), np.array(ph)


D_WATER = 2.0  # um^2/ms


class Main(Scene):
    def construct(self):
        TitleCard(self, "Pulsed-gradient spin echo", "Stejskal-Tanner diffusion weighting")

        # timing diagram (upper part)
        seq = PulseSequenceDiagram(rows=("RF", "G", "ADC"), t_max=T_MAX, width=12, height=2.6)
        seq.move_to([0, 1.45, 0])
        parts = VGroup(
            seq.add_rf(0, 2, kind="hard", label="90°"),
            seq.add_rf(TE / 2 - 1.5, TE / 2 + 1.5, kind="hard", label="180°"),
            seq.add_gradient("G", G1, G1 + DELTA_SMALL, shape="rect", label="δ"),
            seq.add_gradient("G", G2, G2 + DELTA_SMALL, shape="rect", label="δ"),
            seq.add_adc(TE - 8, TE + 8),
            seq.add_marker(TE, "TE"),
        )
        self.play(FadeIn(seq), FadeIn(parts), run_time=1.2)
        cursor = seq.time_cursor()
        self.add(cursor)

        # simulations: diffusing water vs static spins
        ts, S, ph = simulate(D_WATER)
        _, S0, _ = simulate(0.0)

        fan = IsochromatFan(n=12, radius=0.95).move_to([-4.3, -2.05, 0])
        sp = SignalPlot(x_range=(0, 70, 10), y_range=(0, 1.0, 0.5), x_label="t (ms)",
                        y_label="|S|", width=6.5, height=1.8).move_to([2.6, -2.0, 0])
        legend = VGroup(Text("static", font_size=24, color=C_DIM),
                        Text("diffusing", font_size=24, color=C_ACCENT)).arrange(RIGHT, buff=0.4)
        legend.next_to(sp, UP, buff=0.1).shift(RIGHT * 1.5)
        self.play(FadeIn(fan), FadeIn(sp), FadeIn(legend), run_time=1)

        # step through key times: cursor, fan and signal move together
        stops = [G1, G1 + DELTA_SMALL, TE / 2, G2, G2 + DELTA_SMALL, TE]
        prev = 0.0
        for t in stops:
            k = int(round(t / DT))
            k0 = int(round(prev / DT))
            seg0 = sp.plot(ts[k0:k + 1], S0[k0:k + 1], color=C_DIM)
            seg = sp.plot(ts[k0:k + 1], S[k0:k + 1], color=C_ACCENT)
            self.play(seq.cursor_to(t), *fan.set_phases(ph[k][:12]),
                      Create(seg0), Create(seg), run_time=1.4)
            prev = t

        res = MathTex(r"S(TE)=%.2f\approx e^{-bD}=%.2f" % (S[-1], np.exp(-b_value() * D_WATER)),
                      font_size=30).next_to(sp, UP, buff=0.1).shift(LEFT * 1.5)
        self.play(Write(res))
        StepCaption(self, "Motion between the gradient lobes leaves phase unrefocused: S = S0 e^(-bD)")
        self.wait(1.5)


if __name__ == "__main__" and "--selftest" in sys.argv:
    ts, S, ph = simulate(D_WATER)
    _, S0, ph0 = simulate(0.0)
    k_after = int(round((G1 + DELTA_SMALL) / DT))
    assert S[0] == 1.0
    assert S0[k_after] < 0.15                      # dephased after first lobe
    assert np.max(np.abs(ph0[-1])) < 1e-9          # static spins refocus exactly
    assert abs(S0[-1] - 1.0) < 1e-9
    expected = np.exp(-b_value() * D_WATER)
    assert abs(S[-1] - expected) < 0.08, (S[-1], expected)
    assert S[-1] < S0[-1]
    print("selftest ok", S[-1], expected)

The Manim scene code that draws this lesson's animation in the Signals AI app (Python, Manim Community).

ccBYNC© 2026 SignalsLab. Lesson text shared as is under CC BY-NC 4.0.