mne_denoise.dss.denoisers.CycleAverageBias#

class mne_denoise.dss.denoisers.CycleAverageBias(event_samples: Sequence[int], window: tuple[int, int] = (-100, 200), *, sfreq: float | None = None)[source]#

Bias for removing quasi-periodic artifacts (e.g., ECG, EOG).

Applies cycle averaging synchronized to artifact events (e.g., R-peaks for ECG, blink onsets for EOG). This emphasizes the stereotyped artifact waveform while canceling non-phase-locked neural activity.

Parameters:
  • event_samples (array-like) – Sample indices of artifact events (e.g., R-peak locations).

  • window (tuple of int) – (pre, post) samples around each event to include. Default (-100, 200) for ~300ms window at 1kHz.

  • sfreq (float, optional) – Sampling frequency for window specification in seconds. If provided, window can be in seconds instead of samples.

Examples

>>> # ECG artifact removal
>>> from mne.preprocessing import find_ecg_events
>>> from mne_denoise.dss.denoisers import CycleAverageBias
>>> r_peaks, _ = find_ecg_events(raw)  # MNE returns events array
>>> # Extract sample indices (column 0)
>>> r_peak_samples = r_peaks[:, 0]
>>> bias = CycleAverageBias(event_samples=r_peak_samples, window=(-100, 200))
>>> biased_data = bias.apply(raw.get_data())
>>> # EOG (blink) artifact removal
>>> from mne.preprocessing import find_eog_events
>>> blinks = find_eog_events(raw)
>>> blink_samples = blinks[:, 0]
>>> bias_eog = CycleAverageBias(event_samples=blink_samples, window=(-200, 200))
>>> biased_eog = bias_eog.apply(raw.get_data())

References

Särelä & Valpola (2005). Section 4.1.4 “DENOISING OF QUASIPERIODIC SIGNALS”

__init__(event_samples: Sequence[int], window: tuple[int, int] = (-100, 200), *, sfreq: float | None = None) None[source]#

Methods

__init__(event_samples[, window, sfreq])

apply(data)

Apply cycle averaging bias.