ConnectivityAec
Namespace: RTPROCESSINGLIB · Library: DSP Library
mne_connectivity.envelope_correlation in MNE-Python.
#include <dsp/connectivity_aec.h>
class UTILSLIB::ConnectivityAec
Amplitude Envelope Correlation connectivity.
const MatrixXd aec = ConnectivityAec::compute(envelopeSignals); // Pearson r of Hilbert envelopes
const MatrixXd aecOrth = ConnectivityAec::computeOrthogonalized(envelopeSignals); // leakage-corrected
Static Methods
compute(matData)
Compute AEC between all pairs of signals.
Steps: Hilbert envelope → Pearson correlation of envelopes.
Parameters:
- matData : const Eigen::MatrixXd & Bandpassed data (n_signals x n_samples).
Returns:
- Eigen::MatrixXd — Symmetric connectivity matrix (n_signals x n_signals) with values in [-1, 1].
computeOrthogonalized(matData)
Compute orthogonalized AEC (corrected for volume conduction / source leakage).
For each pair (i, j): orthogonalize j w.r.t. i, compute envelope correlation, then symmetrise by averaging AEC(i→j) and AEC(j→i).
Parameters:
- matData : const Eigen::MatrixXd & Bandpassed data (n_signals x n_samples).
Returns:
- Eigen::MatrixXd — Symmetric connectivity matrix (n_signals x n_signals) with values in [0, 1].
hilbertEnvelope(signal, nFft)
Compute the analytic signal envelope via Hilbert transform (using FFT), like numpy.abs(scipy.signal.hilbert(signal, N=nFft)[:n_samples]).
Parameters:
-
signal : const Eigen::VectorXd & Real-valued signal (n_samples).
-
nFft : int FFT length (zero padding), at least n_samples; 0 for n_samples.
Returns:
- Eigen::VectorXd — Envelope (n_samples) — absolute value of analytic signal.
pearsonCorrelation(a, b)
Pearson correlation between two vectors.
Parameters:
-
a : const Eigen::VectorXd & First vector.
-
b : const Eigen::VectorXd & Second vector (same length).
Returns:
- double — Correlation coefficient in [-1, 1].
Example
- Full source:
src/examples/ex_dsp_analysis/main.cpp - Build target:
ex_dsp_analysis(runs under CTest)
Used in examples
ex_dsp_analysis
DSP library: Welch PSD, FIR filtering, peak finding, envelope correlation, SPHARA and simulation.
const MatrixXd aec = ConnectivityAec::compute(envelopeSignals); // Pearson r of Hilbert envelopes
const MatrixXd aecOrth = ConnectivityAec::computeOrthogonalized(envelopeSignals); // leakage-corrected
// numpy corrcoef(|scipy.signal.hilbert(x)|): r(a,b) = 0.98006658, r(a,c) = -0.00701172; orthogonalized r(a,c) = 0.09799620
ok &= expect(std::fabs(aec(0, 1) - 0.9800665778412415) < 1e-9 && std::fabs(aec(0, 2) + 0.007011719607347298) < 1e-9 && std::fabs(aecOrth(0, 2) - 0.09799619541278072) < 1e-9 && aecOrth(0, 1) > 0.98,
QString("ConnectivityAec: r(a,b) = %1, r(a,c) = %2 match scipy").arg(aec(0, 1), 0, 'f', 6).arg(aec(0, 2), 0, 'f', 6));
Authors of this file
- Christoph Dinh <christoph.dinh@mne-cpp.org>