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
| Class | Description | MNE-Python | MNE-C |
|---|---|---|---|
FilterKernel | FIR filter kernel design (Parks-McClellan or cosine window) | mne.filter.create_filter | mne_process_raw --filtersize |
FirFilter | Discoverable FIR filter engine — lowpass, highpass, bandpass, bandstop | mne.filter.filter_data | mne_process_raw --highpass/--lowpass |
IirFilter | Butterworth IIR filter via second-order sections (biquads) | mne.filter.construct_iir_filter | — |
CosineFilter | Frequency-domain cosine filter response | mne.filter.design_mne_c_filter | libmne cosine filter |
ParksMcClellan | Parks-McClellan equiripple FIR design (Remez exchange) | scipy.signal.remez (via create_filter) | — |
FilterIO | Read/write filter coefficients to text files | — | — |
Resample | Polyphase anti-aliased rational resampling | mne.filter.resample | — |
Time-Frequency Analysis
| Class | Description | MNE-Python | MNE-C |
|---|---|---|---|
WelchPsd | Welch's averaged-periodogram PSD estimator | mne.time_frequency.psd_array_welch | — |
Spectrogram | Short-time Fourier transform spectrogram | mne.time_frequency.stft | — |
MorletTfr | Complex Morlet wavelet time-frequency representation | mne.time_frequency.tfr_array_morlet | — |
Spatial Filtering & Decomposition
| Class | Description | MNE-Python | MNE-C |
|---|---|---|---|
ICA | Independent Component Analysis (FastICA, deflationary, logcosh) | mne.preprocessing.ICA (FastICA, Infomax, Picard) | — |
Xdawn | xDAWN spatial filter for event-related response enhancement | mne.preprocessing.Xdawn | — |
SSS | Signal Space Separation (SSS) and temporal SSS (tSSS) | mne.preprocessing.maxwell_filter | — |
makeSpharaProjector() | SPHARA (Surface Partial Harmonic Analysis) spatial projector | — | — |
Artifact & Bad-Channel Detection
| Class | Description | MNE-Python | MNE-C |
|---|---|---|---|
BadChannelDetect | Automated bad channel detection (flat, variance, correlation) | mne.preprocessing.find_bad_channels_maxwell | — |
ArtifactDetect | ECG R-peak and EOG blink/saccade event detection | mne.preprocessing.find_ecg_events, find_eog_events | — |
Epoch & Event Processing
| Class | Description | MNE-Python | MNE-C |
|---|---|---|---|
EpochExtractor | Segment continuous data into fixed-length event-locked epochs | mne.Epochs | mne_process_raw (averaging mode) |
detectTriggerFlanksMax() | Detect trigger flanks using max-coefficient method | mne.find_events | mne_process_raw --trigger |
detectTriggerFlanksGrad() | Detect trigger flanks using gradient method | mne.find_events | mne_process_raw --trigger |
Real-Time Processing
These classes are designed for streaming data and run in background threads:
| Class | Description | MNE-Python | MNE-C |
|---|---|---|---|
RtFilter | Real-time FIR filtering via FFT overlap-add convolution | mne.io.Raw.filter (batch) | mne_process_raw |
RtAveraging | Real-time epoch averaging with baseline correction | mne.Evoked (offline) | mne_process_raw --ave |
RtCov | Background covariance matrix estimation | mne.compute_raw_covariance | mne_process_raw --cov |
RtNoise | Real-time noise PSD estimation | mne.time_frequency.psd_array_welch | — |
RtInvOp | Background inverse operator recomputation on covariance updates | mne.minimum_norm.make_inverse_operator | mne_inverse_operator |
RtConnectivity | Real-time functional connectivity computation | mne_connectivity (offline) | — |
RtHpi | Continuous HPI coil localization and head tracking | mne.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
- Library API Overview — All MNE-CPP libraries
- Connectivity Library — Functional connectivity metrics
- Disp3D Library — 3D visualization
- MNE-Python API — Full Python API reference for comparison