mne_denoise.qa.noise_surround_ratio#

mne_denoise.qa.noise_surround_ratio(freqs: ndarray, psd_after: ndarray, target_freq: float, peak_bw: float = 2.0, surround_bw: float = 5.0) ndarray[source]#

Residual peak-to-surround power ratio around a target frequency.

Values near 1 indicate the target peak is close to its surrounding spectral floor. Values above 1 indicate residual narrow-band peak power.

Parameters:
  • freqs (array of shape (n_freqs,)) – Frequency vector.

  • psd_after (array of shape (n_channels, n_freqs) or (n_freqs,)) – PSD after cleaning.

  • target_freq (float) – Centre frequency of the line-noise peak (Hz).

  • peak_bw (float) – Half-bandwidth (Hz) of the peak region.

  • surround_bw (float) – Half-bandwidth (Hz) of the surrounding region (measured from the outer edge of peak_bw).

Returns:

ratio – Per-channel ratio for 2D PSD input, or a scalar for 1D PSD input.

Return type:

ndarray | float

Notes

The metric compares mean power in a peak window to mean power in two surrounding windows (left/right of the peak window).

Examples

>>> import numpy as np
>>> from mne_denoise.qa import noise_surround_ratio
>>> freqs = np.arange(0, 100, 0.5)
>>> psd = np.ones((2, len(freqs)))
>>> noise_surround_ratio(freqs, psd, 50.0).shape
(2,)