bemobil_mne.preproc.compute_zapline#

bemobil_mne.preproc.compute_zapline(raw, noise_freqs, method='adaptive', n_remove=1, threshold=3.0, adaptive_params=None)[source]#

Remove spectral line noise from EEG using ZapLine (DSS-based).

Operates on EEG channels only; all other channel types are left untouched (except for the "adaptive" and "zapline" methods, which operate on the full raw object via mne_denoise.zapline.ZapLine).

Parameters:
rawmne.io.Raw

Continuous EEG recording.

noise_freqsfloat | array_like | "europe" | "usa" | None

One or more frequencies (Hz) to remove (e.g. 50 or [50, 100]). Accepts the string shortcuts "europe" (50/100/150 Hz) and "usa" (60/120/180 Hz). For method="adaptive" you may pass None to let ZapLine-plus auto-detect line-noise frequencies.

methodstr

Algorithm to use. One of:

"adaptive" (default)

ZapLine-plus via mne_denoise.zapline.ZapLine with adaptive=True. Automatically detects noise harmonics. Loops over each entry in noise_freqs (or runs once with line_freq=None when noise_freqs is None). Requires mne_denoise.

"zapline"

Standard (non-adaptive) ZapLine via mne_denoise.zapline.ZapLine with adaptive=False. Loops over each entry in noise_freqs. Requires mne_denoise.

"dss_line"

Single-pass DSS via meegkit.dss.dss_line(). Loops over each entry in noise_freqs. Requires meegkit.

"dss_line_iter"

Iterative DSS via meegkit.dss.dss_line_iter(). Loops over each entry in noise_freqs. Requires meegkit.

n_removeint

Number of DSS components to remove at each frequency. Only used by "dss_line" and "dss_line_iter". Default 1.

thresholdfloat

Detection threshold for the mne-denoise methods ("adaptive" and "zapline"). Passed as the threshold argument to mne_denoise.zapline.ZapLine. Default 3.0.

adaptive_paramsdict | None

Extra keyword arguments forwarded to mne_denoise.zapline.ZapLine when method="adaptive". Useful for controlling process_harmonics, n_iterations, etc. None uses defaults.

Returns:
raw_cleanmne.io.Raw

Copy of raw with line noise attenuated.