Skip to main content

BadChannelsMaxwell

Namespace: RTPROCESSINGLIB  ·  Library: DSP Library

Module

This page documents a header-level module — a collection of free functions that share an algorithmic topic. There is no enclosing C++ class; the functions live directly in the library namespace.

Python equivalent

mne.preprocessing.find_bad_channels_maxwell in MNE-Python.

#include <dsp/bad_channels_maxwell.h>

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

Channels whose SSS reconstruction error is anomalously high are flagged as bad. This mirrors MNE-Python's mne.preprocessing.find_bad_channels_maxwell().

Reference: Taulu, S., Kajola, M. (2005). J. Appl. Phys. 97, 124905.

src/examples/ex_dsp_maxwell/main.cpp
MatrixXd broken = data;
broken.row(meg[40]).array() += 2e-7; // a sensor with a constant offset the multipole model cannot explain
BadChannelsMaxwellParams badParams;
badParams.origin = params.origin;
badParams.dZThreshold = 50.0; // robust z-score of the reconstruction residual
const BadChannelsMaxwellResult bads = findBadChannelsMaxwell(broken, info, badParams);

Functions​

findBadChannelsMaxwell(matData, info, params)​

[BadChannelsMaxwellResult](/docs/api/dsp/bad-channels-maxwell-result) findBadChannelsMaxwell(const Eigen::MatrixXd & matData, const [FiffInfo](/docs/api/fiff/fiff-info) & info, const [BadChannelsMaxwellParams](/docs/api/dsp/bad-channels-maxwell-params) & params);

Detect bad MEG channels using SSS reconstruction residuals.

Computes the SSS reconstruction of the data, then flags channels whose residual (difference between original and reconstructed) is anomalously large relative to the population of channels.

Parameters:

  • matData : const Eigen::MatrixXd & MEG data (n_channels x n_times). Should include all channels (MEG and non-MEG).

  • info : const FiffInfo & Measurement info with channel positions.

  • params : const BadChannelsMaxwellParams & Detection parameters.

Returns:


Example​

Authors of this file​