RtCov
Namespace: RTPROCESSINGLIB · Library: DSP Library · Source: dsp/rt/rt_cov.h
#include <dsp/rt_cov.h>
class RTPROCESSINGLIB::RtCov
Real-time covariance worker.
Controller that manages background covariance matrix estimation from streaming data.
src/examples/ex_dsp_rt/main.cpp
RtCov rtCov(info);
FiffCov cov;
for (int start = 0; start < covData.cols(); start += 1000) {
cov = rtCov.estimateCovariance(covData.middleCols(start, 1000), 4000); // empty until 4000 samples arrived
}
Inheritance
Public Methods
RtCov(pFiffInfo)
estimateCovariance(matData, iNewMaxSamples)
Perform actual covariance estimation.
Parameters:
-
matData : const Eigen::MatrixXd & Data to estimate the covariance from.
-
iNewMaxSamples : int Number of samples to accumulate before a covariance is estimated.
Returns:
- FiffCov — Noise covariance of the MEG/EEG channels, or an empty FiffCov while fewer than iNewMaxSamples samples are accumulated or if no FiffInfo was set.
Example
- Start here: ex_dsp_rt — DSP real-time workers: averaging, covariance, noise spectrum, connectivity, HPI fitting and inverse operators.
- Full source:
src/examples/ex_dsp_rt/main.cpp - Build target:
ex_dsp_rt(runs under CTest) - Data: mne-cpp-test-data
Used in examples
ex_dsp_rt
DSP real-time workers: averaging, covariance, noise spectrum, connectivity, HPI fitting and inverse operators.
src/examples/ex_dsp_rt/main.cpp, line 196
RtCov rtCov(info);
FiffCov cov;
for (int start = 0; start < covData.cols(); start += 1000) {
cov = rtCov.estimateCovariance(covData.middleCols(start, 1000), 4000); // empty until 4000 samples arrived
}
// regularize() adds 0.1 x mean MEG variance to the diagonal; the off-diagonal term is untouched
ok &= expect(cov.dim == 2 && cov.names == QStringList({"MEG0111", "MEG0121"}) && cov.nfree == 4000 && std::fabs(cov.data(0, 1) - numpyCov(0, 1)) < 1e-6 * std::fabs(numpyCov(0, 1)),
QString("RtCov: covariance of 4000 samples matches numpy.cov off the diagonal (%1)").arg(cov.data(0, 1), 0, 'g', 6));
Authors of this file
- Christoph Dinh <christoph.dinh@mne-cpp.org>