find_bad_channels_lof

find_bad_channels_lof(raw, *, picks=None, metric='seuclidean', threshold=1.5, return_scores=False, **kwargs)[source][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_good_data)s

  • 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 is False.

  • %(verbose)s

Returns:

  • noisy_chs (list) – List of bad M/EEG channels that were automatically detected.

  • scores (ndarray, shape (n_picks,)) – Only returned when return_scores is True. It contains the LOF outlier score for each channel in picks.

See also

maxwell_filter, annotate_amplitude

Notes

See :footcite:`KumaravelEtAl2022` and :footcite:`BreunigEtAl2000` for background on choosing threshold.

Added in version 1.7.

References