v2.0.0
Loading...
Searching...
No Matches
bad_channels_lof.h File Reference

Bad-channel detection via the Local Outlier Factor (LOF) algorithm. More...

#include "dsp_global.h"
#include <Eigen/Core>
#include <QStringList>
Include dependency graph for bad_channels_lof.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  UTILSLIB::LofBadChannelParams

Namespaces

namespace  FIFFLIB
 FIFF file I/O, in-memory data structures and high-level readers/writers.
namespace  UTILSLIB
 Shared utilities (I/O helpers, spectral analysis, layout management, warp algorithms).

Functions

DSPSHARED_EXPORT QStringList UTILSLIB::findBadChannelsLof (const Eigen::MatrixXd &data, const FIFFLIB::FiffInfo &info, const LofBadChannelParams &params=LofBadChannelParams())
 Detect bad channels using Local Outlier Factor (LOF).
DSPSHARED_EXPORT Eigen::VectorXd UTILSLIB::computeLofScores (const Eigen::MatrixXd &features, int k)
 Compute LOF scores for a feature matrix.

Detailed Description

Bad-channel detection via the Local Outlier Factor (LOF) algorithm.

SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2026 MNE-CPP Authors

Author
Christoph Dinh chris.nosp@m.toph.nosp@m..dinh.nosp@m.@mne.nosp@m.-cpp..nosp@m.org
Since
2.2.1
Date
May 2026

LOF (Breunig et al., SIGMOD 2000) scores each channel by the ratio between its own local density (reachability distance to its k nearest channels in the chosen feature space) and the average local density of those neighbours. Values close to 1 indicate a sample that belongs to a dense cluster, values noticeably above 1 mark density outliers. For MEG / EEG each channel is summarised by per-segment statistics (RMS, variance, higher-order moments) so that genuinely flat, very noisy or amplifier- saturated sensors stand out in the LOF score and can be flagged at a single threshold (default 2.0).

The detector follows MNE-Python's mne.preprocessing.find_bad_channels_lof so MEG / EEG pipelines can switch between the two without changing the downstream interpolation / SSS step.

Definition in file bad_channels_lof.h.