meeg_utils.steps.BadChannels#
- class meeg_utils.steps.BadChannels(method='auto', *, ransac=True, psd=False, robust_reference=True, random_state=42, reject_by_annotation=None, origin='auto', cross_talk='auto', calibration='auto', limit=7.0, h_freq=40.0)[source]#
Detect bad channels and mark them in
info["bads"].The data themselves are not changed; follow with
Interpolateto repair the channels. Channels already marked bad stay bad.- Parameters:
method ({"auto", "prep", "maxwell"}) –
"prep": PREP noisy-channel detection for EEG (Bigdely-Shamlo et al., 2015) via PyPREP, running the PREP criteria: NaN/flat, deviation, high-frequency noise, correlation, low SNR and, optionally, RANSAC."maxwell":mne.preprocessing.find_bad_channels_maxwell()for MEG (Neuromag; CTF via a grade-0 compensated copy)."auto"(default): PREP for EEG channels and Maxwell for MEG channels of Neuromag/CTF systems; MEG from other systems raises, because no validated default exists for them.
ransac (bool) – PREP: also run RANSAC, which needs electrode positions.
psd (bool) – PREP: also run PyPREP’s band-power criterion (
find_bad_by_PSD, robust z > 3 in 1-15, 15-30 or 30-45 Hz), which PyPREP adds to PREP (“not present in the original MATLAB PREP”). Off by default: it flags frontal channels, whose low-frequency power includes the blinks (in MNE’s sample EEG, EEG 001, 004 and 007 were flagged by it alone), and these would then be interpolated before ICA could remove the blinks.robust_reference (bool) – PREP: detect the bad channels after PREP’s robust average reference (pyprep’s
Reference: iteratively re-reference to the average of the channels not yet found bad), as the PREP paper does. Without it, detection runs on the recording’s own reference, which flags channels next to the reference electrode (their signals are small and poorly correlated with the others; seen in HAD-MEEG, where C1 and Cz record about 0.4 µV against 2-3 µV elsewhere). The data themselves are not re-referenced.random_state (int | None) – PREP: seed for RANSAC.
reject_by_annotation ({"omit", None}) – PREP: whether to ignore
BAD_annotated segments.origin (str | tuple) – Maxwell: head origin,
"auto"fits it to the digitization (or uses (0, 0, 0.04) with a warning when there are no head-shape points).cross_talk ("auto" | str | None) – Maxwell, Neuromag only: cross-talk and fine-calibration files.
"auto"(default) finds them in the BIDS dataset of the recording (sub-*/[ses-*/]meg/*_acq-crosstalk_meg.fifand*_acq-calibration_meg.dat) and raises if they are missing;Nonedetects without them (less accurate).calibration ("auto" | str | None) – Maxwell, Neuromag only: cross-talk and fine-calibration files.
"auto"(default) finds them in the BIDS dataset of the recording (sub-*/[ses-*/]meg/*_acq-crosstalk_meg.fifand*_acq-calibration_meg.dat) and raises if they are missing;Nonedetects without them (less accurate).limit (float) – Maxwell: detection threshold.
h_freq (float | None) – Maxwell: low-pass applied before detection.
- qc_#
previous_badsand, per modality,bads,n_bads,fractionandby_criterion; with the robust reference,eeg_before_reference(channels PREP flags on the original reference, for comparison); for MEG,noisy_references(reference sensors Maxwell flags: reported with a warning, not marked bad, as they cannot be interpolated).- Type:
Notes
Figures (
plot()):"sensors"(sensor layout with previously and newly marked bad channels) and"scores"(per-channel scores of each criterion against its threshold).- __init__(method='auto', *, ransac=True, psd=False, robust_reference=True, random_state=42, reject_by_annotation=None, origin='auto', cross_talk='auto', calibration='auto', limit=7.0, h_freq=40.0)[source]#
Methods
__init__([method, ransac, psd, ...])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.