Plotting#
This module contains plotting functionality to illustrate sequence definitions in a commonly occuring format.
Functions:
|
Adds a line with two vertical ticks and a descriptive text into the given axes. |
|
Formats the given axes object, such that the spine of desired axes (xy) is rendered as arrow in the of the plot, rather than the outer box. |
|
Plots a time for the given sequence, on which the names of all contained blocks are added at their corresponding start time |
|
Plots gradient sampling spectra for a given sequence along a list of directions. |
|
2D-scatter plot the trajectory of the sequence and its adc events |
|
3D-scatter plot the trajectory of the sequence and its adc events |
|
Creates a figure with a 3x1 subplot grid and plots the gradient moment |
|
Plot RF, gradients and adc events into a(4, 1) axes grid. |
- anotate_timing(start, end, ypos, text, axis, color=None, fontsize=12, height=2, rot=0, vertical_alignment=None, linewidth=2)[source]#
Adds a line with two vertical ticks and a descriptive text into the given axes.
- Parameters:
start (
Quantity
) – Start of annotation intervalend (
Quantity
) – End of annotation intervalypos (
float
) – position on y-axes in units of the axistext (
str
) – string containing the labelaxis (
Axes
) – axes object to insert the text intocolor (
Optional
[str
]) – Color of text and glyphfontsize (
float
) – Fontsize of annotationheight (
float
) – Height of the annotations vertical ticks in units of the axisrot (
float
) – Angle in degrees, that the text is rotatedvertical_alignment (
Optional
[str
]) – defaults to top if ypos > 0 otherwise bottomlinewidth (
float
) – Linewidth of the annotion glyph
- Return type:
None
- center_axes(axis, linewidth=2, color=(0, 0, 0, 1), xy='xy', ticksoff='')[source]#
Formats the given axes object, such that the spine of desired axes (xy) is rendered as arrow in the of the plot, rather than the outer box.
- Parameters:
axis (
Axes
) – Axes object to formatlinewidth (
float
) – Linewidth of the axis spinecolor – Color of the new axis spine
xy (
str
) – String specifying which axes to modify (x, y, xy)ticksoff (
str
) – String specifying where to switch of ticks
- Return type:
None
- plot_block_names(seq, axis, fontsize=9)[source]#
Plots a time for the given sequence, on which the names of all contained blocks are added at their corresponding start time
- Parameters:
seq (
Sequence
) –axis (
Axes
) –fontsize (
float
) –
- Returns:
- plot_gradient_spectra(seq, directions=None, start_time=None, end_time=None, ax=None)[source]#
Plots gradient sampling spectra for a given sequence along a list of directions. If no directions are given, plots along MPS
- Parameters:
seq (
Sequence
) – Instance of cmrseq.Sequence to plot spectradirections (
Optional
[List
[ndarray
]]) – List[np.ndarray of shape (3, )] directions to plot spectra along, default will plot MPSstart_time (
Optional
[Quantity
]) – Quantity[Time] Start time of spectra calculation windowend_time (
Optional
[Quantity
]) – Quantity[Time] End time of spectra calculation windowax (
Optional
[Axes
]) – plt.Axes axis to place plots into, if not given creates and returns new figure
- Return type:
Figure
- plot_kspace_2d(seq, plot_raster_trajectory=True, k_axes=(0, 1), ax=None, format_axes=True, markersize=15, map_sampling_times=None, add_colorbar=None, colorbar_kwargs=None)[source]#
2D-scatter plot the trajectory of the sequence and its adc events
- Parameters:
seq (
Sequence
) –plot_raster_trajectory (
bool
) – if true plots the k-space points for all gradient raster pointsk_axes (
Tuple
[int
,int
]) – determines which combination of (kx, ky, kz) to scatter plotax (
Optional
[Axes
]) – plt.Axis, if not None this is used to plot k-spaceformat_axes (
bool
) –markersize (
int
) –map_sampling_times (
Optional
[str
]) – str from [None, “global”, “relative”]. For ‘global’, the reference point is 0 ms for ‘relative’ the temporal difference to the center k-space sample is used as reference.add_colorbar (
Optional
[bool
]) – if true a color-bar for the sampling time mappingcolorbar_kwargs (
Optional
[dict
]) – keyword arguments for color bar. Only has an effect if ‘add_colorbar==True’
- Return type:
Axes
- Returns:
axis used to plot
- plot_kspace_3d(seq, plot_raster_trajectory=False, axis=None, format_axis=True, marker_kw=None, line_kw=None)[source]#
3D-scatter plot the trajectory of the sequence and its adc events
- Parameters:
seq (
Sequence
) –plot_raster_trajectory (
bool
) – if true plots the k-space points for all gradient raster pointsaxis –
format_axis (
bool
) –marker_kw (
Optional
[dict
]) – keyword arguments for sample-markersline_kw (
Optional
[dict
]) – keyword arguments for gradient trajectory line
- Return type:
(
Figure
,Axes
)
- plot_moment(seq, moment_order=0, axes=None)[source]#
- Creates a figure with a 3x1 subplot grid and plots the gradient moment
of specified order for all 3 gradient components over time. Also plots gradients superimposed into the corresponding subplot
- Parameters:
axes (
Union
[Tuple
[Axes
,...
],Axes
,str
,None
]) – (plt.Axes, plt.Axes, plt.Axes, plt.Axes) (rf, gx, gy, gz) or a single instance of plt.Axes if everything shall be plotted in the same axis. If the value is set to string “single”, a new figure is created plotting everything into a single axis. If none a new figure with 4 separate axes is created.seq (
Sequence
) – Instance of cmrseq.Sequencemoment_order (
int
) – order of the moment to be plotted
- Return type:
Figure
- Returns:
plt.figure with 3x1 suplot grid
- plot_sequence(seq, axes=None, format_axes=True, add_legend=True, adc_yoffset=0, n_yticks=5, plot_center_lines=True, legend_position='upper left', gradient_style='line', gradient_colors=('C0', 'C1', 'C2'), rf_color='purple', add_flip_angles=False)[source]#
Plot RF, gradients and adc events into a(4, 1) axes grid. If for axes are specified as argument, plots are inserted there.
- Parameters:
seq (
Sequence
) – Instance of cmrseq.Sequenceaxes (
Union
[Tuple
[Axes
,...
],Axes
,str
,None
]) – (plt.Axes, plt.Axes, plt.Axes, plt.Axes) (rf, gx, gy, gz) or a single instance of plt.Axes if everything shall be plotted in the same axis. If the value is set to string “single”, a new figure is create plotting everyting into a single axis. If none a new figure with 4 separate axes is created.format_axes (
bool
) – if true applies styling to the axesadd_legend (
bool
) – if true adds legend to the first axis. If no axes are provided, this is forced to be Trueadc_yoffset (
float
) – determines the y-offset for adc-event markersn_yticks (
int
) – determines the number of y ticks if format axes is Trueplot_center_lines (
bool
) – If True, adds vertical lines for rf-centers and adc-centerslegend_position (
str
) – Position of legend if it is addedgradient_style (
str
) – if “line” only the line is plotted, if “filled” filled between the axesgradient_colors (
List
[str
]) – tuple of 3 colors, the channels are plotted in.rf_color (
str
) – determines the color, RF waveforms are plotted.add_flip_angles (
bool
) – If true, adds text_labels to the RF centers stating the flip angle
- Return type:
Figure