sim_bloch

Contents

sim_bloch#

pypulseqpp.sim_bloch()[source]#

Simulate the Bloch equation without relaxation, in hard-pulse steps.

Each step rotates the magnetisation right-handedly about (Re b1, Im b1, bz) by 2 pi dt times that vector’s length.

Parameters:
  • b1_hz (array_like) – Complex transverse field per step, in Hz: (T,) shared by every position, or (P, T) per position (e.g. pTx channels summed through their B1 maps).

  • bz_hz (array_like) – Longitudinal field, in Hz: (P, T), or (P, 1) held throughout. Its rows define the positions.

  • dt (float) – Step, in s.

  • initial (array_like, default=None) – Starting magnetisation, (3,) or (P, 3); +z by default.

Returns:

Final magnetisation, (P, 3).

Return type:

numpy.ndarray

Raises:

ValueError – If the fields’ shapes disagree on positions or steps.

Examples

>>> import numpy as np
>>> import pypulseqpp as pp

A 250 Hz hard pulse held for 1 ms is a 90 degree flip about +x:

>>> on_resonance = np.zeros((1, 1))
>>> pp.sim_bloch(np.full(1000, 250.0 + 0j), on_resonance, 1e-6).round(3) + 0.0
array([[ 0., -1.,  0.]])

Twice the amplitude inverts:

>>> pp.sim_bloch(np.full(1000, 500.0 + 0j), on_resonance, 1e-6).round(3) + 0.0
array([[ 0.,  0., -1.]])

One row of bz_hz per off-resonance:

>>> offsets = np.array([[0.0], [500.0], [-500.0]])
>>> pp.sim_bloch(np.full(1000, 250.0 + 0j), offsets, 1e-6).round(3) + 0.0
array([[ 0.   , -1.   ,  0.   ],
       [ 0.773,  0.162,  0.614],
       [-0.773,  0.162,  0.614]])