braindecode.preprocessing.FindBadChannelsLof#
- class braindecode.preprocessing.FindBadChannelsLof(n_neighbors=20, *, picks=None, metric='euclidean', threshold=1.5, return_scores=False, verbose=None)[source]#
Braindecode preprocessor wrapper for
find_bad_channels_lof().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 ininfo['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 isFalse.- verbosebool | str | int | None
Control verbosity of the logging output. If
None, use the default verbosity level. See the logging documentation andmne.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_scoresisTrue. It contains the LOF outlier score for each channel inpicks.
See also
maxwell_filterannotate_amplitude
Notes
See [1] and [2] for background on choosing
threshold.Added in version 1.7.
Methods
- fn(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:
raw (instance of Raw) – Raw data to process.
n_neighbors (int) – Number of neighbors defining the local neighborhood (default is 20). Smaller values will lead to higher LOF scores.
picks (str | 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 ininfo['bads']will be included if their names or indices are explicitly provided.metric (str) – Metric to use for distance computation. Default is “euclidean”, see
sklearn.metrics.pairwise.distance_metrics()for details.threshold (float) – 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_scores (bool) – If
True, return a dictionary with LOF scores for each evaluated channel. Default isFalse.verbose (bool | str | int | None) – Control verbosity of the logging output. If
None, use the default verbosity level. See the logging documentation andmne.verbose()for details. Should only be passed as a keyword argument.
- Returns:
noisy_chs (list) – List of bad M/EEG channels that were automatically detected.
scores (ndarray, shape (n_picks,)) – Only returned when
return_scoresisTrue. It contains the LOF outlier score for each channel inpicks.
See also
maxwell_filter,annotate_amplitudeNotes
See [1] and [2] for background on choosing
threshold.Added in version 1.7.
References