meeg_utils.steps.LineNoise#
- class meeg_utils.steps.LineNoise(method='zapline-plus', *, fline=None, n_remove='auto', n_harmonics=None, nfft=1024, adaptive_params=None)[source]#
Remove power-line noise.
ZapLine methods come from mne-denoise. Each data channel type (
mag,grad,eeg) is processed separately, because their units differ, and the cleaned data are written back in place, so all other channels, annotations and timing are preserved. Channels marked bad are neither used nor cleaned.- Parameters:
method ({"zapline-plus", "zapline", "notch"}) –
"zapline-plus"(default): adaptive ZapLine-plus (Klug & Kloosterman, 2022). It detects the noise aroundfline, segments the recording and chooses the number of components per segment. It adapts to whatever data it transforms, sotransformre-estimates on new data."zapline": standard ZapLine (de Cheveigné, 2020). Spatial filters are learned infitand reused bytransform."notch": notch filters atflineand its harmonics (mne.io.Raw.notch_filter()).
fline (float | None) – Line frequency in Hz.
None(default) usesinfo["line_freq"], which mne-bids reads from the BIDS sidecar; fitting fails if neither is set rather than assuming 50 or 60 Hz.n_remove (int | "auto") –
"zapline"only: number of components to remove, or"auto"(outlier-based selection, capped by mne-denoise at 20% of the components). Fixed counts should stay small: ZapLine’s residual contains broadband activity above roughlyfline / 2as well as the line noise, so removing many components distorts it.n_harmonics (int | None) – Number of harmonics to target;
Noneuses all below Nyquist.nfft (int) – FFT length used by ZapLine.
adaptive_params (dict | None) –
"zapline-plus"only: options passed to mne-denoise’s adaptive mode.
- qc_#
Per channel type:
suppression_db(power reduction atfline),distortion_db(mean absolute log-power change 1-45 Hz outside the line harmonics),distortion_db_broadband(same up to 90% of Nyquist),variance_removed_pct,overclean_fractionandunderclean_fraction(fractions of channels with the noise floor aroundflinelowered by more than 3 dB, or with a residual peak above twice the surrounding power),n_flat_skipped(flat channels left out of these metrics) and, for ZapLine,n_removed.- Type:
Notes
Figures (
plot()):"psd", spectra before and after cleaning with the line frequency and its harmonics marked.- __init__(method='zapline-plus', *, fline=None, n_remove='auto', n_harmonics=None, nfft=1024, adaptive_params=None)[source]#
Methods
__init__([method, fline, n_remove, ...])fit(inst[, y, system])Learn the step's state from the data.
fit_transform(inst[, y, system, copy])Fit the step on the data and transform the same data.
get_metadata_routing()Get metadata routing of this object.
get_params([deep])Get parameters for this estimator.
plot([kind, inst])Draw quality-control figures.
set_fit_request(*[, inst, system])Configure whether metadata should be requested to be passed to the
fitmethod.set_params(**params)Set the parameters of this estimator.
set_transform_request(*[, copy, inst])Configure whether metadata should be requested to be passed to the
transformmethod.transform(inst, *[, copy])Apply the fitted step to the data.
Attributes
Data types the step accepts.
adds_annotationsWhether the step may add
BAD_annotations (existing ones are kept).changes_channelsWhether the step may add, drop or reorder channels.
changes_timesWhether the step may change the time axis (e.g. resampling, cropping).
drops_epochsWhether the step may drop epochs (e.g. artifact rejection).
kind -> whether it needs data (
inst).returnsData type the step returns;
Nonemeans the same type as its input.systemsAcquisition systems the step applies to;
Nonemeans all systems.