Sequence.paper_plot

Sequence.paper_plot#

Sequence.paper_plot()[source]#

Draw a publication-style diagram of one repetition, using mrsd.

Rows are RF, the physical gradient axes z, y and x, and ADC, each drawn from the waveform the sequence plays. Every row carries its own scale, set by the largest magnitude that channel reaches over the repetitions drawn, so heights are comparable within a row and not between rows. The other repetitions are drawn underneath in underlay_color, which shows what changes from one to the next, and a TR interval is marked below.

Parameters:
  • time_range (Sequence[float], default=(0, np.inf)) – Upstream’s window, in seconds. Given, the blocks it touches are drawn alone, without repetitions underneath.

  • line_width (float, default=1.2) – Width of every drawn line, in points.

  • axes_color (str | tuple[float, ...], default=None) – A Matplotlib colour for the baselines and the repetition marker. The package’s faint ink by default.

  • rf_color (str | tuple[float, ...], default=None) – A Matplotlib colour for the RF and ADC rows. The package’s ink by default, which reads against a light and a dark background alike.

  • gx_color (str | tuple[float, ...], default=None) – A Matplotlib colour for the x gradient row, as rf_color.

  • gy_color (str | tuple[float, ...], default=None) – A Matplotlib colour for the y gradient row, as rf_color.

  • gz_color (str | tuple[float, ...], default=None) – A Matplotlib colour for the z gradient row, as rf_color.

  • rf_plot ({'abs', 'real', 'imag'}, default='abs') – Which part of the RF waveform to draw.

  • tr (int, default=None) – 1-based repetition to draw. By default, the one in which a physical axis reaches its largest magnitude.

  • max_underlays (int, default=16) – At most this many repetitions, evenly spaced, are drawn underneath, together with those in which each axis reaches its most negative and most positive value; 0 draws none.

  • underlay_color (str | tuple[float, ...], default=None) – A Matplotlib colour. The package’s muted ink by default.

  • ax (matplotlib.axes.Axes, default=None) – Axes to draw in; a new figure by default.

Returns:

diagram, the mrsd.Diagram, whose annotate and interval add labels; tr, the repetition drawn solid, and underlays, those drawn underneath, 1-based (None and empty for a time_range).

Return type:

SimpleNamespace

Notes

Repetitions are detected from the block definitions. Choosing them is one compiled pass over the block table, and only the repetitions drawn are expanded, so the cost does not grow with the length of the scan. A sequence that does not repeat is one repetition, drawn whole.

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_trapezoid("x", area=1000, duration=2e-3))
2
>>> drawn = seq.paper_plot()
>>> drawn.tr, drawn.underlays
(1, [])