Sequence.paper_plot

Sequence.paper_plot#

Sequence.paper_plot()[source]#

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

Rows are RF, the gradient axes z, y and x after each block’s rotation, and ADC. Each row is scaled to the largest magnitude its channel reaches over the repetitions drawn, so heights compare within a row and not between rows. The other repetitions are drawn underneath in underlay_color, and the repetition time 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 solid. By default, the one that acquires the most ADC blocks, ties broken by the largest gradient excursion on the axes that differ between repetitions.

  • 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 those of repetition(), or the range declared by the PlotTRsize and PlotTRstart definitions when present; 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, [])