plot_muap_grid#

myogen.utils.plotting.plot_muap_grid(muap_data, axs, muap_indices=None, apply_default_formatting=True, **kwargs)[source]#

Plot Motor Unit Action Potentials (MUAPs) in electrode grid format.

This function visualizes MUAPs as they appear across a grid of electrodes, with each subplot showing the MUAP waveform at a specific electrode position. The layout matches the physical electrode arrangement.

Parameters:
  • muap_data (numpy.ndarray) – MUAP data with shape (n_muaps, n_electrode_rows, n_electrode_cols, n_time_samples) or (n_electrode_rows, n_electrode_cols, n_time_samples) for a single MUAP.

  • axs (list[Union[Axes, np.ndarray]]) – Matplotlib axes to plot on. Should provide one set of axes per MUAP. Each set can be a 2D array of axes (from plt.subplots), a single axis, or a 1D array. Expected structure: list of axes configurations, one per MUAP to plot.

  • muap_indices (list[int], optional) – List of MUAP indices to plot. If None, plots all MUAPs.

  • apply_default_formatting (bool, default True) – Whether to apply default formatting to the plot

  • **kwargs (dict) – Additional keyword arguments to pass to the plot function. Only used if apply_default_formatting is False.

Returns:

The axes that were plotted on

Return type:

list[Union[Axes, np.ndarray]]

Raises:

ValueError – If the number of axes does not match the number of MUAPs to plot