SequenceDescription#

class torchsim.SequenceDescription(subsequence_index, tr_duration_us, events, rf_definitions, shim_definitions=<factory>, crusher_dephasing_rad=0.0, voxel_size_m=None, rf_raster_time_s=1e-06)[source]#

Bases: object

Event stream and RF resources for one sequence or subsequence.

crusher_dephasing_rad is the dephasing the sequence’s unbalanced gradient winds across one voxel of voxel_size_m. Their ratio sets the b-factor diffusion is damped by and the phase each dephasing order turns through under flow, so a dephasing of zero leaves both terms out however large the coefficient behind them.

voxel_size_m also stands on its own: spins cross a voxel of that size at their own speed whether or not a gradient is playing, which is what washes the voxel out and replaces it with unexcited magnetization. Leaving it None declares no voxel, and a spin velocity then has nothing to cross.

subsequence_index#

Which subsequence of a multi-part acquisition this is.

Type:

int

tr_duration_us#

How long one playing of this stream holds the timeline, in microseconds.

Type:

float or torch.Tensor

events#

The stream itself, in the order it is played.

Type:

tuple of SequenceEvent

rf_definitions#

{id: RfDefinition} – the pulses the RF events name.

Type:

dict

shim_definitions#

{id: ShimDefinition} – the transmit shims the RF events drive.

Type:

dict

crusher_dephasing_rad#

Dephasing wound across one voxel by the sequence’s unbalanced gradient.

Type:

float

voxel_size_m#

The voxel a spin crosses, and the length the dephasing is wound across. None declares no voxel.

Type:

float, optional

rf_raster_time_s#

The dwell the RF shapes are sampled on. A pulse is integrated against it, so a stream carrying shapes on a 2 microsecond raster and read on a 1 microsecond one turns half the angle it should.

Type:

float

Methods

from_operators

Lay operators out end to end and return the stream they make.

from_pulseq

Return what one repetition of a Pulseq sequence plays.

plot

Draw the stream: pulses as stems, samples as markers.

classmethod from_operators(*parts, rf_definitions=None, shim_definitions=None, subsequence_index=0, crusher_dephasing_rad=0.0, voxel_size_m=None, start_s=0.0)[source]#

Lay operators out end to end and return the stream they make.

The other way in besides a scanner: what a sequence written here plays, in the same object one that arrived would be read into.

Parameters:
  • parts (Operator, optional) – The operators, in the order they play.

  • rf_definitions (mapping, optional) – The pulses the events drive, by id. One ideal pulse under id zero when not given, which is what an operator naming no shape asks for.

  • shim_definitions (mapping, optional) – The transmit shims the pulses are driven on, by id.

  • subsequence_index (int, optional) – Which subsequence of a scan this is.

  • crusher_dephasing_rad (float, optional) – The turn one crusher puts across a voxel. Diffusion and flow are read off it and are zero without it.

  • voxel_size_m (float, optional) – The distance that turn is put across.

  • start_s (float or torch.Tensor, optional) – When the first operator starts.

Return type:

The stream, lasting as long as the operators laid out end to end.

classmethod from_pulseq(source, **settings)[source]#

Return what one repetition of a Pulseq sequence plays.

Parameters:
  • source (str, Path or sequence) – A .seq file, or a sequence in memory with pypulseq’s reading interface – pypulseq’s own Sequence, or pypulseqpp’s.

  • settings (Any) – tr_index to name which repetition to read, and the subsequence_index, crusher_dephasing_rad and voxel_size_m the description carries.

Return type:

The stream, in the same object a scanner’s own would arrive in.

plot(axis=None, *, upto_s=None)[source]#

Draw the stream: pulses as stems, samples as markers.

What a layout actually laid down, which is easier to check here than in the signal it produces. A pulse’s stem is as tall as the angle it turns.

Parameters:
  • axis (matplotlib.axes.Axes, optional) – Where to draw. A new figure when not given.

  • upto_s (float, optional) – Stop after this much of the stream, for a repetition long enough that all of it is a smear.

Return type:

The axis drawn on.

Raises:

ImportError – if matplotlib is not installed, which is not a: dependency of this package.

property adc_events#

Return ADC events in state-machine order.