mne.preprocessing.find_bad_channels_lof#

mne.preprocessing.find_bad_channels_lof(raw, n_neighbors=20, *, picks=None, metric='euclidean', threshold=1.5, return_scores=False, verbose=None)[source]#

Find bad channels using Local Outlier Factor (LOF) algorithm.

Parameters:
rawinstance of Raw

Raw data to process.

n_neighborsint

Number of neighbors defining the local neighborhood (default is 20). Smaller values will lead to higher LOF scores.

picksstr | array_like | slice | None

Channels to include. Slices and lists of integers will be interpreted as channel indices. In lists, channel type strings (e.g., ['meg', 'eeg']) will pick channels of those types, channel name strings (e.g., ['MEG0111', 'MEG2623'] will pick the given channels. Can also be the string values 'all' to pick all channels, or 'data' to pick data channels. None (default) will pick good data channels. Note that channels in info['bads'] will be included if their names or indices are explicitly provided.

metricstr

Metric to use for distance computation. Default is “euclidean”, see sklearn.metrics.pairwise.distance_metrics() for details.

thresholdfloat

Threshold to define outliers. Theoretical threshold ranges anywhere between 1.0 and any positive integer. Default: 1.5 It is recommended to consider this as an hyperparameter to optimize.

return_scoresbool

If True, return a dictionary with LOF scores for each evaluated channel. Default is False.

verbosebool | str | int | None

Control verbosity of the logging output. If None, use the default verbosity level. See the logging documentation and mne.verbose() for details. Should only be passed as a keyword argument.

Returns:
noisy_chslist

List of bad M/EEG channels that were automatically detected.

scoresndarray, shape (n_picks,)

Only returned when return_scores is True. It contains the LOF outlier score for each channel in picks.

Notes

See [1] and [2] for background on choosing threshold.

New in v1.7.

References