CESTSimulator#

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

Bases: Simulator

A Z-spectrum simulated through a train of saturation pulses, pool by pool.

At each offset the magnetization starts from equilibrium, a train of rectangular pulses saturates it while the free water and every exchanging pool precess at their own frequency, relax and exchange, and the longitudinal magnetization left once a spoiled delay has passed is the point of the spectrum. The pools are the Bloch-McConnell model’s [1]: poolB_* to poolE_* beside the free water, each a fraction of M0 with its own exchange rate, relaxation times and chemical shift in Hz. Each pulse starts at the phase the one before it ended at, so the train is continuous in phase over the time the pulses play and not over the delays between them, which is how a Pulseq CEST protocol accumulates it. This is the sequence BART’s sim plays as CEST.

References

Examples

import torch
from torchsim.simulators import CESTSimulator

sequence = CESTSimulator(offsets=torch.linspace(-5.0, 5.0, 21))
spectrum = sequence.simulate(
    T1=1300.0, T2=75.0,
    poolB_fraction=0.001, poolB_exchange=1000.0, poolB_T1=1300.0,
    poolB_T2=10.0, poolB_shift=3.5 * 127.7,
)
print(spectrum.shape)
torch.Size([21])

Methods

bind

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

describe

Return the description this protocol plays.

evaluate

Return the longitudinal magnetization, offsets last.

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 one saturation train and read per offset.

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(*, offsets, field_strength=3.0, B1sat=1.0, npulses=1, pulse_duration=100.0, interpulse_delay=0.0, recovery=6.5, dwell=0.01)[source]#

Return one saturation train and read per offset.

Parameters:
  • offsets (array-like) – Saturation frequency offsets from the free water, in ppm.

  • field_strength (float, optional) – Main field in tesla, which turns an offset in ppm into Hz.

  • B1sat (float, optional) – Amplitude of each saturation pulse in microtesla.

  • npulses (int, optional) – Saturation pulses per offset.

  • pulse_duration (float, optional) – Duration of each pulse in milliseconds.

  • interpulse_delay (float, optional) – Time between two pulses in milliseconds.

  • recovery (float, optional) – Time in milliseconds from the end of the last pulse to the read, over which the transverse magnetization is spoiled.

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

Raises:

ValueError – If a pulse is not a whole number of samples.

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

Return the longitudinal magnetization, offsets last.