prescribed_flips#
- blochsim.trains.prescribed_flips()[source]#
Refocusing flip angles whose echoes take prescribed amplitudes.
The train is the CPMG arrangement: an ideal 90 degree excitation a quarter turn from the refocusing pulses, each pulse midway between two echoes. The extended phase graph is inverted one echo at a time: the states before a pulse fix the echo after it as a function of its flip angle alone, and the smallest angle in [0, 180] degrees, or in [0,
maximum_flip], giving the prescribed amplitude is taken. An amplitude no angle reaches gets the angle that comes nearest, so the returned echoes are the test of a prescription: they equal it exactly where it can be met.- Parameters:
signal (array-like) – Prescribed echo amplitudes, as fractions of the excited magnetization, shape
(..., echoes).first_flip (float or array-like, default=None) – Flip angle of the first pulse, in degrees, one per train. The first echo is then what that pulse gives and its prescription is not read.
ESP (float, default=None) – Echo spacing, in ms. Needed only with relaxation.
first_ESP (float, default=None) – Time from the excitation to the first echo, in ms;
ESPby default.T1 (float, default=np.inf) – Longitudinal relaxation time the amplitudes are prescribed under, in ms. The default is no relaxation.
T2 (float, default=np.inf) – Transverse relaxation time the amplitudes are prescribed under, in ms. The default is no relaxation.
lengths (int or array-like, default=None) – Echoes each train plays, when the trains of a batch differ in length; what follows a train’s last echo is returned as zero.
threads (int, default=0) – Threads to spread the trains over; 0 sizes the pool to the batch.
signal_tangents (array-like, default=None) – Directions to differentiate along, shape
(directions, ..., echoes): each a change ofsignal. Asks for the derivatives as well.first_flip_tangents (array-like, default=None) – The change of
first_flipalong each direction, in degrees, shape(directions, ...); none by default. Needssignal_tangents.maximum_flip (float or array-like, default=None) – Largest flip angle a solved pulse may take, in degrees, in (0, 180], one per train; 180 by default. A pulse held at it does not move with the prescription, so its derivative is zero.
first_flipis not bounded by it.
- Returns:
flip (numpy.ndarray) – Refocusing flip angles, in degrees, shaped like
signal.achieved (numpy.ndarray) – The echo amplitudes those angles give, shaped like
signal.flip_tangents (numpy.ndarray) – Only with
signal_tangents: the derivative offlipalong each direction, in degrees, shaped likesignal_tangents.achieved_tangents (numpy.ndarray) – Only with
signal_tangents: the derivative ofachievedalong each direction, shaped likesignal_tangents.
- Raises:
ValueError – If an amplitude or a first angle is not finite, the timing, the relaxation times or the lengths are not valid, or the tangents are not shaped as described.
Notes
The magnetization that recovers during the train is excited across the refocusing axis and refocuses at the pulses, not at the echoes, so an echo holds none of it: T1 enters only through the decay of what the train stores along z.
The derivatives are exact: each angle is solved in closed form from the states before its pulse, and the derivatives of those states are carried through the train alongside them. An echo out of reach takes the angle of the nearest one, which moves with the states and not with the target.
Examples
A constant train of 180 degree pulses is what unit echoes ask for:
>>> import numpy as np >>> from blochsim.trains import prescribed_flips >>> flip, achieved = prescribed_flips(np.ones(8)) >>> bool(np.allclose(flip, 180.0)) True