FLASHSimulator#

class torchsim.simulators.FLASHSimulator(*args, **kwargs)[source]#

Bases: Simulator

A spoiled gradient-echo train from equilibrium, optionally inverted first.

Every excitation is a windowed sinc played sample by sample, so the magnetization relaxes, precesses off resonance and exchanges between pools while the pulse plays, unless pulse_duration is zero and it is an instantaneous rotation. The transverse magnetization is spoiled after each sample: ideally, or with rf_spoiling by a quadratic cycle of the excitation phase and a gradient that winds one configuration order per repetition [2], the sample then demodulated by its pulse’s phase. With inversion the train is the inversion-recovery FLASH of Look-Locker T1 mapping [1]. This is the sequence BART’s sim plays as FLASH and IR-FLASH, and with instantaneous pulses and the sample at the pulse, the one its epg plays as FLASH.

The configuration orders are sized from the winding when states is not given: one under ideal spoiling, and one per repetition up to the engine’s limit under RF spoiling.

References

Examples

from torchsim.simulators import FLASHSimulator

sequence = FLASHSimulator(
    flip=8.0, TR=5.0, TE=2.0, nshots=100, inversion="adiabatic"
)
signal = sequence.simulate(T1=1000.0, T2=100.0)
print(signal.shape)
torch.Size([100])

Methods

bind

This simulator with more fixed on it, values or settings alike.

describe

Return the description this protocol plays.

evaluate

Simulate the train, on one configuration order unless it winds.

from_description

Return a simulator over a stream someone else assembled.

from_pulseq

Return a simulator over one repetition of a Pulseq sequence.

jacobian

Return the signal and its derivative with respect to diff.

layout

Return the train, one sample per shot.

played

Return the protocol as it will be laid out.

repetition_s

Return how long one repetition lasts, given what the layout played.

simulate

Return the recorded signal.

layout(*, flip, TR, TE, nshots, pulse_duration=1.0, bandwidth_time=4.0, inversion=None, inversion_duration=10.0, inversion_phase=0.0, spoiler=0.0, dwell=0.01, rf_spoiling=None)[source]#

Return the train, one sample per shot.

Parameters:
  • flip (float or array-like) – Flip angle in degrees, scalar or one per shot.

  • TR (float) – Repetition time in milliseconds, pulse centre to pulse centre.

  • TE (float) – Echo time in milliseconds, from the centre of the pulse.

  • nshots (int) – Excitations in the train.

  • pulse_duration (float, optional) – Duration of each excitation in milliseconds. Zero plays each as an instantaneous rotation.

  • bandwidth_time (float, optional) – Zero crossings of the Hamming-windowed sinc across the pulse.

  • inversion ({None, "ideal", "adiabatic"}, optional) – What prepares the train: nothing, an instantaneous inversion scaled by inv_efficiency, or a hyperbolic secant played sample by sample.

  • inversion_duration (float, optional) – Duration of the adiabatic inversion in milliseconds.

  • inversion_phase (float, optional) – Phase of the adiabatic inversion in degrees, relative to the train’s first pulse, which decides where the transverse magnetization the inversion leaves points.

  • spoiler (float, optional) – Time in milliseconds between the inversion and the train, at the end of which the transverse magnetization is spoiled.

  • dwell (float, optional) – How long each sample of a pulse is held, in milliseconds.

  • rf_spoiling (float, optional) – The RF spoiling increment in degrees: the n-th excitation, counted from zero, is played at rf_spoiling * n (n + 1) / 2. Not given, the transverse magnetization is spoiled ideally.

Raises:

ValueError – If the sample falls inside the pulse or after the next one, if flip is neither scalar nor one per shot, or if a pulse is not a whole number of samples.

evaluate(properties, **sequence)[source]#

Simulate the train, on one configuration order unless it winds.