mne_denoise.qa.peak_attenuation_db#
- mne_denoise.qa.peak_attenuation_db(freqs: ndarray, psd_before: ndarray, psd_after: ndarray, target_freq: float, bandwidth: float = 2.0) ndarray[source]#
Attenuation (dB) of the dominant peak around a target frequency.
- Parameters:
freqs (array of shape (n_freqs,)) – Frequency vector.
psd_before (array of shape (n_channels, n_freqs) or (n_freqs,)) – PSD before cleaning.
psd_after (array of shape (n_channels, n_freqs) or (n_freqs,)) – PSD after cleaning.
target_freq (float) – Centre frequency of the peak (Hz).
bandwidth (float) – Half-bandwidth (Hz) around target_freq to search for the peak.
- Returns:
attenuation – Per-channel attenuation in dB for 2D PSD input, or a scalar value for 1D PSD input.
- Return type:
ndarray | float
Notes
This metric compares the maximum PSD value in a narrow band around
target_freq:10 * log10(max_before / max_after)Positive values indicate suppression of the target peak.
Examples
>>> import numpy as np >>> from mne_denoise.qa import peak_attenuation_db >>> freqs = np.arange(0, 100, 0.5) >>> before = np.ones_like(freqs) * 0.01 >>> after = before.copy() >>> band = (freqs >= 49) & (freqs <= 51) >>> before[band] = 1.0 >>> after[band] = 0.5 >>> float(peak_attenuation_db(freqs, before, after, 50.0)) > 0 True