NMR and MRI physics ยท Intermediate

Bloch equations: magnetisation vector over time

Written by SignalsLab

Early edition: these lessons are being reviewed.

Content

Summary

The Bloch equations describe how the nuclear magnetisation vector M evolves under a static field, a radiofrequency pulse, and relaxation. Precession at the Larmor frequency is combined with T1 recovery of longitudinal magnetisation and T2 decay of transverse magnetisation. This simulation animates M in the rotating frame as it is tipped, then relaxes.

Intuition

Think of ๐Œ as a spinning top made of billions of protons. The magnetic field makes it precess, like a top wobbling around the vertical. An RF pulse tips it away from the z axis. Afterwards two things happen independently: the z component slowly climbs back to its equilibrium value M0 (T1, energy exchange with the surroundings), while the xy component shrinks because spins dephase (T2, spin-spin interactions and field inhomogeneity). In the rotating frame, which spins at the Larmor frequency, the precession vanishes and ๐Œ simply tips and then spirals or shrinks back. Since T2 is shorter than or equal to T1, the tip of ๐Œ traces a path that loses its transverse part faster than it regains its longitudinal part.

Key equations

d๐Œdt=ฮณ๐Œร—๐โˆ’Mxx^+Myy^T2โˆ’(Mzโˆ’M0)z^T1
(1)

Full Bloch equation: precession plus T2 and T1 relaxation.

ฯ‰0=ฮณB0
(2)

Larmor frequency; for hydrogen ฮณ2ฯ€ is about 42.58 MHz per tesla.

Mz(t)=M0(1โˆ’eโˆ’t/T1)(after a 90ยฐ pulse)
(3)

Longitudinal recovery.

Mxy(t)=Mxy(0)eโˆ’t/T2
(4)

Transverse decay.

Derivation

  1. Start with torque on a magnetic moment: d๐Œdt=ฮณ๐Œร—๐.
  2. With B=B0z^, this gives dMxdt=ฮณB0My and dMydt=โˆ’ฮณB0Mx, which is rotation at ฯ‰0=ฮณB0.
  3. Add phenomenological relaxation: transverse components decay at rate 1/T2.
  4. Add longitudinal relaxation toward equilibrium: dMzdt=โˆ’(Mzโˆ’M0)T1.
  5. Go to the frame rotating at ฯ‰0: the B0 term cancels, leaving only the B1 pulse (about x) and relaxation.
  6. After the pulse (B1=0), the equations decouple: Mz=M0+(Mz(0)โˆ’M0)eโˆ’t/T1, Mxy=Mxy(0)eโˆ’t/T2.

Worked example

Problem

After a 90ยฐ pulse, tissue has T1=800 ms and T2=80 ms, with M0=1. Find Mz and Mxy at t=160 ms.

  1. After a 90ยฐ pulse, Mz(0) = 0 and Mxy(0) = 1.
  2. Mz = 1 - e^{-160/800} = 1 - e^{-0.2} = 1 - 0.819 = 0.181.
  3. Mxy = e^{-160/80} = e^{-2} = 0.135.

Answer Mzโ‰ˆ0.18M0 and Mxyโ‰ˆ0.14M0: the signal has largely decayed while recovery is only 18% complete.

Common mistakes

  • Thinking T1 and T2 are the same process; they are independent and T2 โ‰ค T1.
  • Assuming Mz recovers at the rate Mxy decays; Mxy decays about ten times faster here.
  • Forgetting that the 63% rule applies to recovery at t = T1, while decay leaves 37% at t = T2.
  • Confusing T2 with T2*, which also includes field inhomogeneity.
  • Ignoring that the rotating frame removes precession; the lab frame shows a spiral.

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(110 lines)
import sys
import numpy as np
from manim import *
from blocks import *

T1 = 1.0
T2 = 0.5
M0 = 1.0
DF = 1.5  # off-resonance in rad/s (rotating-frame frequency offset)
DT = 0.005
N_STEPS = 1200  # 6 s


def bloch_rhs(M, df=DF):
    """Bloch equations in the rotating frame, no RF."""
    mx, my, mz = M
    return np.array([
        df * my - mx / T2,
        -df * mx - my / T2,
        (M0 - mz) / T1,
    ])


def simulate():
    """RK4 integration with fixed step; returns array of states (N+1, 3)."""
    M = np.array([1.0, 0.0, 0.0])  # after a 90 degree pulse
    states = [M.copy()]
    for _ in range(N_STEPS):
        k1 = bloch_rhs(M)
        k2 = bloch_rhs(M + DT / 2 * k1)
        k3 = bloch_rhs(M + DT / 2 * k2)
        k4 = bloch_rhs(M + DT * k3)
        M = M + DT / 6 * (k1 + 2 * k2 + 2 * k3 + k4)
        states.append(M.copy())
    return np.array(states)


STATES = simulate()
TIMES = np.arange(N_STEPS + 1) * DT


class Main(Scene):
    def construct(self):
        # Title
        TitleCard(self, "Bloch equations", "Magnetisation after a 90ยฐ pulse")

        # Left: 2D plot of Mx, My, Mz over time
        axes = Axes(x_range=[0, 6, 1], y_range=[-1, 1, 0.5], x_length=7.2, y_length=3.8,
                    axis_config={"color": C_DIM, "include_tip": False})
        axes.to_edge(LEFT, buff=0.6).shift(0.1 * UP)
        xl = Text("t (s)", font_size=24).next_to(axes, DOWN, buff=0.15)
        step = 4
        idx = list(range(0, N_STEPS + 1, step))

        def curve(k, col):
            pts = [axes.c2p(TIMES[i], STATES[i, k]) for i in idx]
            return VMobject(color=col, stroke_width=4).set_points_as_corners(pts)

        cx, cy, cz = curve(0, C_MAIN), curve(1, C_ACCENT), curve(2, C_GOOD)
        legend = VGroup(
            Text("Mx", font_size=24, color=C_MAIN),
            Text("My", font_size=24, color=C_ACCENT),
            Text("Mz", font_size=24, color=C_GOOD),
        ).arrange(RIGHT, buff=0.4).next_to(axes, UP, buff=0.15)
        self.play(Create(axes), FadeIn(xl), FadeIn(legend))

        # Right: transverse plane view with the moving vector tip
        plane = Axes(x_range=[-1, 1, 0.5], y_range=[-1, 1, 0.5], x_length=3.4, y_length=3.4,
                     axis_config={"color": C_DIM, "include_tip": False})
        plane.to_edge(RIGHT, buff=0.8).shift(0.1 * UP)
        pl = Text("Mx-My plane", font_size=24).next_to(plane, UP, buff=0.15)
        arrow = Arrow(plane.c2p(0, 0), plane.c2p(STATES[0, 0], STATES[0, 1]),
                      buff=0, color=C_BAD, stroke_width=5)
        trail = VMobject(color=C_BAD, stroke_width=2)
        trail.set_points_as_corners([plane.c2p(s[0], s[1]) for s in STATES[::step]])
        self.play(Create(plane), FadeIn(pl), GrowArrow(arrow))

        eq = MathTex(r"\frac{dM_z}{dt}=\frac{M_0-M_z}{T_1}", font_size=30)
        eq.next_to(axes, DOWN, buff=0.5).shift(0.5 * RIGHT)
        self.play(Write(eq))

        # Animate with a tracker indexing recorded states
        tr = ValueTracker(0)

        def cur_state():
            return STATES[int(round(tr.get_value()))]

        arrow.add_updater(lambda a: a.become(
            Arrow(plane.c2p(0, 0), plane.c2p(cur_state()[0], cur_state()[1]),
                  buff=0, color=C_BAD, stroke_width=5)))
        self.add(arrow)
        self.play(Create(cx), Create(cy), Create(cz),
                  Create(trail),
                  tr.animate.set_value(N_STEPS),
                  run_time=9, rate_func=linear)
        arrow.clear_updaters()

        StepCaption(self, "Mxy spirals and decays with T2 while Mz recovers with T1.")
        self.wait(1.5)


if __name__ == "__main__" and "--selftest" in sys.argv:
    assert np.allclose(STATES[0], [1, 0, 0])
    # Mz analytic: M0 (1 - exp(-t/T1)) since Mz(0)=0
    assert abs(STATES[-1, 2] - M0 * (1 - np.exp(-TIMES[-1] / T1))) < 1e-6
    mxy = np.hypot(STATES[:, 0], STATES[:, 1])
    assert np.all(np.diff(mxy) < 1e-12)
    assert abs(mxy[-1] - np.exp(-TIMES[-1] / T2)) < 1e-6
    assert T2 <= T1
    print("selftest ok")

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.