Draw meshes and plot electrical data - openep.draw.draw_routines

This module provides functions for drawing 3D meshes using pyvista and plotting electrical data using matplotlib.

Draw 3D meshes

openep.draw.draw_routines.draw_map(mesh: pyvista.PolyData, field: numpy.ndarray, plotter: pyvista.Plotter = None, add_mesh_kws: dict = None, free_boundaries: bool = True)[source]

Project scalar values onto a mesh and optionally draw the free boundaries.

Parameters
  • mesh (PolyData) – mesh to be drawn

  • field (nx1 array) – scalar values used to colour the mesh

  • plotter (pyvista.Plotter) – The mesh will be added to this plotting object. If None, a new plotting object will be created.

  • add_mesh_kws (dict) – Keyword arguments for pyvista.Plotter.add_mesh()

  • free_boundaries (bool) – If True, the free boundaries will be added to the plot.

Returns

plotter (pyvista.Plotter) – Plotting object with the mesh added.

openep.draw.draw_routines.draw_free_boundaries(free_boundaries: openep.mesh.mesh_routines.FreeBoundary, colour: Union[str, List] = 'black', width: int = 5, plotter: pyvista.Plotter = None)[source]

Draw the freeboundaries of a mesh.

Parameters
  • free_boundaries (FreeBoundary) – FreeBoundary object. Can be generated using openep.mesh.mesh_routines.get_free_boundaries().

  • colour (str, list) – colour or list of colours to render the free boundaries.

  • width (int) – width of the free boundary lines.

  • plotter (pyvista.Plotter) – The free boundaries will be added to this plotting object. If None, a new plotting object will be created.

Returns

plotter (pyvista.Plotter) – Plotting object with the free boundaries added.

Plotting electrical data

openep.draw.draw_routines.plot_electrograms(times, electrograms, names=None, woi=None, y_separation=1, y_start=0, colour=None, axes=None)[source]

Plot electrogram traces.

Parameters
  • times (ndarray) – times at which voltages were measured

  • electrograms (ndarray) – Electrogram traces. Two-dimensional of size N_points x N_times for bipolar voltage, or two-dimensional of shape N_points x N_times x 2 for unipolar dimensional.

  • names (ndarray, optional) – List of electrode names, on per electrogram. If provided, names these will be used to label each electrogram.

  • woi (tuple, optional) – start and stop times of the window of interest. If provided, dashed vertical lines will be added to the plot at these times.

  • y_separation (float, optional) – Vertical spacing to add between consecutive electrograms.

  • y_start (float, optional) – The first electrogram will have this value added to it (to shift the electrogram up or down the y axis).

  • colour (str or list, optional) – Colour or list of colours to use for plotting.

  • axis (matplotlib.axes.Axes, optional) – Matplotlib Axes on which to plot the traces. If None, a new figure and axes will be created.

Returns

figure (matplotlib.Figure) – Figure on which the traces have been plotted axis (matplotlib.axes.Axes): Axes on which the traces have been plotted.