Sequence.waveforms_and_times

Sequence.waveforms_and_times#

Sequence.waveforms_and_times()[source]#

Return the gradient waveforms, the RF pulse timing and the ADC sampling.

Parameters:
  • append_RF (bool, default=False) – Also return the RF envelope, as a fourth waveform channel.

  • time_range (Sequence[float], default=None) – Two times in seconds; only the blocks they touch are expanded.

  • block_range (Sequence[int], default=None) – Two 1-based block indices. Not with time_range.

  • compat (bool, default=True) – Return upstream’s five values, which a drop-in caller unpacks. False returns a named result covering all seven Pulseq RF uses, which those five values cannot carry.

Returns:

With compat: (wave_data, tfp_excitation, tfp_refocusing, t_adc, fp_adc). Otherwise a named result whose waveforms, rf and adc carry every RF use tag, per-sample ADC phases and the 1-based block each pulse and sample belongs to.

Return type:

tuple | WaveformsAndTimes

Notes

Gradient channels are (2, n) arrays of time (s) and amplitude (Hz/m); the optional RF channel is complex with amplitude in Hz. Block rotations are applied. A time range keeps times measured from the start of the scan; a block range restarts them at its first block.

Examples

>>> import numpy as np
>>> import pypulseqpp as pp
>>> seq = pp.Sequence(pp.Opts())
>>> seq.add_block(pp.make_block_pulse(np.pi / 2, duration=1e-3))
1
>>> seq.add_block(pp.make_adc(num_samples=64, duration=3.2e-3))
2
>>> wave_data, tfp_excitation, tfp_refocusing, t_adc, fp_adc = seq.waveforms_and_times()
>>> tfp_excitation[0], t_adc.shape
(array([0.0005]), (64,))
>>> seq.waveforms_and_times(compat=False).rf.use
('undefined',)