mne_denoise.viz.plot_psd_comparison#

mne_denoise.viz.plot_psd_comparison(inst_before, inst_after, fmin=0, fmax=inf, sfreq=None, line_freq=None, show=True, average=True, ax=None, fname=None)[source]#

Plot PSD comparison for original and denoised data.

Parameters:
  • inst_before (MNE object | ndarray) – Inputs to compare. Supported MNE inputs are Raw, Epochs, and Evoked. Array inputs are interpreted with the last axis as time. When either input is an array, sfreq must be provided.

  • inst_after (MNE object | ndarray) – Inputs to compare. Supported MNE inputs are Raw, Epochs, and Evoked. Array inputs are interpreted with the last axis as time. When either input is an array, sfreq must be provided.

  • fmin (float) – Frequency bounds to display.

  • fmax (float) – Frequency bounds to display.

  • sfreq (float | None) – Sampling frequency for array inputs.

  • line_freq (float | None) – Optional line frequency to mark, along with visible harmonics.

  • show (bool) – Whether to display the figure.

  • average (bool) – If True, average PSDs across non-frequency axes.

  • ax (Axes | None) – Optional axis to draw into.

  • fname (path-like | None) – Optional output path.

Returns:

fig – Figure handle.

Return type:

matplotlib.figure.Figure

Raises:

ValueError – If array inputs are used without sfreq.

Notes

PSD backend is selected by input type: - MNE inputs use compute_psd. - Array inputs use SciPy Welch PSD.

Examples

>>> import numpy as np
>>> from mne_denoise.viz import plot_psd_comparison
>>> before = np.random.randn(8, 2000)
>>> after = before * 0.8
>>> fig = plot_psd_comparison(before, after, sfreq=250.0, show=False)