mne_denoise.viz.plot_component_patterns#

mne_denoise.viz.plot_component_patterns(estimator, info=None, picks=None, n_components=None, ax=None, show=True, fname=None)[source]#

Plot spatial component patterns.

When compatible MNE channel information is available, the patterns are rendered as topomaps. Otherwise, the function falls back to plotting the selected component weights across channels on a standard axes.

Parameters:
  • estimator (object) – Fitted estimator exposing patterns_.

  • info (mne.Info | None) – Measurement info used for topomap rendering.

  • picks (array-like of int | None) – Channel indices used for topomap rendering. If None, no topomap is attempted and the function falls back to channel-weight line plots.

  • n_components (int | sequence of int | None) – Components to plot. If an int, plot the first n_components.

  • ax (matplotlib.axes.Axes | None) – Optional target axes. Supported only for the line-plot fallback or when rendering a single topomap.

  • show (bool, default=True) – If True, show the figure.

  • fname (path-like | None) – Optional output path used to save the figure.

Returns:

fig – Figure handle.

Return type:

matplotlib.figure.Figure

Raises:

ValueError – If patterns are not 2D, if no components are selected, or when ax is passed while requesting multiple topomaps. Also raised when picks is provided without valid info.

Notes

Topomap rendering is explicit: pass both info and picks. This function does not infer channel picks automatically.

Examples

>>> from mne_denoise.viz import plot_component_patterns
>>> fig = plot_component_patterns(
...     estimator,
...     info=info,
...     picks=[0, 1, 2, 3],
...     n_components=4,
...     show=False,
... )