Find bad channels using Maxwell filtering.

Parameters
rawinstance of Raw

Raw data to process. For equivalence with MaxFilter, it’s recommended to low-pass filter your data (e.g., at 40 Hz) prior to running this function.

limitfloat

Detection limit (default is 7.). Smaller values will find more bad channels at increased risk of including good ones.

durationfloat

Duration into which to window the data for processing. Default is 5.

min_countint

Minimum number of times a channel must show up as bad in a chunk. Default is 5.

originarray_like, shape (3,) | str

Origin of internal and external multipolar moment space in meters. The default is 'auto', which means (0., 0., 0.) when coord_frame='meg', and a head-digitization-based origin fit using fit_sphere_to_headshape() when coord_frame='head'. If automatic fitting fails (e.g., due to having too few digitization points), consider separately calling the fitting function with different options or specifying the origin manually.

int_orderint

Order of internal component of spherical expansion.

ext_orderint

Order of external component of spherical expansion.

calibration

Path to the '.dat' file with fine calibration coefficients. File can have 1D or 3D gradiometer imbalance correction. This file is machine/site-specific.

cross_talk

Path to the FIF file with cross-talk correction information.

coord_framestr

The coordinate frame that the origin is specified in, either 'meg' or 'head'. For empty-room recordings that do not have a head<->meg transform info['dev_head_t'], the MEG coordinate frame should be used.

regularize

Basis regularization type, must be “in” or None. “in” is the same algorithm as the “-regularize in” option in MaxFilter™.

ignore_refbool

If True, do not include reference channels in compensation. This option should be True for KIT files, since Maxwell filtering with reference channels is not currently supported.

How to deal with ill-conditioned SSS matrices. Can be “error” (default), “warning”, “info”, or “ignore”.

If array, movement compensation will be performed. The array should be of shape (N, 10), holding the position parameters as returned by e.g. read_head_pos.

mag_scale

The magenetometer scale-factor used to bring the magnetometers to approximately the same order of magnitude as the gradiometers (default 100.), as they have different units (T vs T/m). Can be 'auto' to use the reciprocal of the physical distance between the gradiometer pickup loops (e.g., 0.0168 m yields 59.5 for VectorView).

skip_by_annotationstr | list of str

If a string (or list of str), any annotation segment that begins with the given string will not be included in filtering, and segments on either side of the given excluded annotated segment will be filtered separately (i.e., as independent signals). The default ('edge', 'bad_acq_skip') will separately filter any segments that were concatenated by mne.concatenate_raws() or mne.io.Raw.append(), or separated during acquisition. To disable, provide an empty list.

verbosebool, str, int, or None

If not None, override default verbose level (see mne.verbose() and Logging documentation for more).

Returns
noisy_chslist

List of bad MEG channels that were automatically detected as being noisy among the good MEG channels.

flat_chslist

List of MEG channels that were detected as being flat in at least min_count segments.

Notes

All arguments after raw, limit, duration, and min_count are the same as maxwell_filter(), except that the following are not allowed in this function because they are unused: st_duration, st_correlation, destination, st_fixed, and st_only.

This algorithm, for a given chunk of data:

1. Runs SSS on the data, without removing external components.

2. Exclude channels as flat that have had low variance (< 0.01 fT or fT/cm in a 30 ms window) in the given or any previous chunk.

3. For each channel $$k$$, computes the peak-to-peak $$d_k$$ of the difference between the reconstructed and original data.

4. Computes the average $$\mu_d$$ and standard deviation $$\sigma_d$$ of the deltas (after scaling magnetometer data to roughly match the scale of the gradiometer data using mag_scale).

5. Channels are marked as bad for the chunk when $$d_k > \mu_d + \textrm{limit} \times \sigma_d$$.

Data are processed in chunks of the given duration, and channels that are bad for at least min_count chunks are returned.

This algorithm gives results similar to, but not identical with, MaxFilter. Differences arise because MaxFilter processes on a buffer-by-buffer basis (using buffer-size-dependent downsampling logic), uses different filtering characteristics, and possibly other factors. Channels that are near the limit for a given min_count are particularly susceptible to being different between the two implementations.

New in version 0.20.