Skip to main content

DSP Library (DSPLIB)

The DSP library provides digital signal processing algorithms for MEG/EEG data, covering both offline batch processing and real-time streaming scenarios. All classes reside in the DSPLIB namespace and depend only on Qt and Eigen.

Algorithm Inventory

The tables below list every algorithm implemented in MNE-CPP's DSP library, with references to the corresponding MNE-Python and MNE-C (v2.7) implementations where applicable.

Filtering

ClassDescriptionMNE-PythonMNE-C
FilterKernelFIR filter kernel design (Parks-McClellan or cosine window)mne.filter.create_filtermne_process_raw --filtersize
FirFilterDiscoverable FIR filter engine — lowpass, highpass, bandpass, bandstopmne.filter.filter_datamne_process_raw --highpass/--lowpass
IirFilterButterworth IIR filter via second-order sections (biquads)mne.filter.construct_iir_filter
CosineFilterFrequency-domain cosine filter responsemne.filter.design_mne_c_filterlibmne cosine filter
ParksMcClellanParks-McClellan equiripple FIR design (Remez exchange)scipy.signal.remez (via create_filter)
FilterIORead/write filter coefficients to text files
ResamplePolyphase anti-aliased rational resamplingmne.filter.resample

Time-Frequency Analysis

ClassDescriptionMNE-PythonMNE-C
WelchPsdWelch's averaged-periodogram PSD estimatormne.time_frequency.psd_array_welch
SpectrogramShort-time Fourier transform spectrogrammne.time_frequency.stft
MorletTfrComplex Morlet wavelet time-frequency representationmne.time_frequency.tfr_array_morlet

Spatial Filtering & Decomposition

ClassDescriptionMNE-PythonMNE-C
ICAIndependent Component Analysis (FastICA, deflationary, logcosh)mne.preprocessing.ICA (FastICA, Infomax, Picard)
XdawnxDAWN spatial filter for event-related response enhancementmne.preprocessing.Xdawn
SSSSignal Space Separation (SSS) and temporal SSS (tSSS)mne.preprocessing.maxwell_filter
makeSpharaProjector()SPHARA (Surface Partial Harmonic Analysis) spatial projector

Artifact & Bad-Channel Detection

ClassDescriptionMNE-PythonMNE-C
BadChannelDetectAutomated bad channel detection (flat, variance, correlation)mne.preprocessing.find_bad_channels_maxwell
ArtifactDetectECG R-peak and EOG blink/saccade event detectionmne.preprocessing.find_ecg_events, find_eog_events

Epoch & Event Processing

ClassDescriptionMNE-PythonMNE-C
EpochExtractorSegment continuous data into fixed-length event-locked epochsmne.Epochsmne_process_raw (averaging mode)
detectTriggerFlanksMax()Detect trigger flanks using max-coefficient methodmne.find_eventsmne_process_raw --trigger
detectTriggerFlanksGrad()Detect trigger flanks using gradient methodmne.find_eventsmne_process_raw --trigger

Real-Time Processing

These classes are designed for streaming data and run in background threads:

ClassDescriptionMNE-PythonMNE-C
RtFilterReal-time FIR filtering via FFT overlap-add convolutionmne.io.Raw.filter (batch)mne_process_raw
RtAveragingReal-time epoch averaging with baseline correctionmne.Evoked (offline)mne_process_raw --ave
RtCovBackground covariance matrix estimationmne.compute_raw_covariancemne_process_raw --cov
RtNoiseReal-time noise PSD estimationmne.time_frequency.psd_array_welch
RtInvOpBackground inverse operator recomputation on covariance updatesmne.minimum_norm.make_inverse_operatormne_inverse_operator
RtConnectivityReal-time functional connectivity computationmne_connectivity (offline)
RtHpiContinuous HPI coil localization and head trackingmne.chpi.compute_head_pos

Usage Example

#include <dsp/firfilter.h>
#include <dsp/welch_psd.h>
#include <dsp/ica.h>

using namespace DSPLIB;

// Design and apply a 1–40 Hz band-pass FIR filter
FirFilter filter;
Eigen::MatrixXd filtered = filter.apply(data, sFreq, 1.0, 40.0,
FirFilter::BPF, "hamming");

// Compute Welch PSD
auto [psd, freqs] = WelchPsd::compute(filtered, sFreq,
/*nfft=*/1024, /*noverlap=*/512);

// Run ICA decomposition
ICA ica;
ica.fit(filtered, /*nComponents=*/20);
Eigen::MatrixXd cleaned = ica.apply(filtered, /*exclude=*/{0, 3});

Doxygen Reference

For method signatures, inheritance diagrams, and source-level documentation see the auto-generated DSPLIB namespace in the Doxygen API reference.

See Also