mne_denoise.viz.plot_component_psd_comparison#

mne_denoise.viz.plot_component_psd_comparison(inst_before, components, component_indices, sfreq=None, peak_freq=None, fmin=1, fmax=40, show=True, fname=None)[source]#

Plot input PSD next to PSDs of selected components.

Parameters:
  • inst_before (MNE object | ndarray) – Baseline signal used for the reference PSD.

  • components (MNE object | ndarray) – Component signals with canonical shape (n_components, n_times), or (n_epochs, n_components, n_times).

  • component_indices (int | sequence of int) – Explicit component index/indices to include in the component PSD panel.

  • sfreq (float | None) – Sampling frequency for array inputs. If components is an MNE object and sfreq is None, components.info['sfreq'] is used.

  • peak_freq (float | None) – Optional frequency marker shown on both panels.

  • fmin (float) – Frequency bounds for PSD computation.

  • fmax (float) – Frequency bounds for PSD computation.

  • show (bool) – If True, display 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 component_indices is empty/out of range or if array inputs are provided without sfreq.

Examples

>>> import numpy as np
>>> from mne_denoise.viz import plot_component_psd_comparison
>>> signal = np.random.randn(8, 2000)
>>> sources = np.random.randn(4, 2000)
>>> fig = plot_component_psd_comparison(
...     signal,
...     sources,
...     component_indices=[0, 1],
...     sfreq=250.0,
...     show=False,
... )