Skip to main content

Connectivity

Namespace: CONNECTIVITYLIB  ·  Library: Connectivity Library

Python equivalent

mne_connectivity.spectral_connectivity_epochs in MNE-Python.

#include <connectivity/connectivity.h>

class CONNECTIVITYLIB::Connectivity

Dispatcher that runs one or more functional-connectivity estimators over a batch of pre-processed trials and returns one Network per estimator.

The selected methods are read from CONNECTIVITYLIB::ConnectivitySettings::getConnectivityMethods "ConnectivitySettings::getConnectivityMethods" and matched by string against the supported metric set ("COR", "XCOR", "COH", "IMAGCOH", "PLI", "USPLI", "WPLI", "DSWPLI", "PLV", "GC", "DTF", "PDC"). All spectral metrics share the same DPSS tapered FFT and CSD accumulator inside ConnectivitySettings, so running e.g. PLI + wPLI + dwPLI in one call costs only one FFT pass.

Runs the selected functional-connectivity metrics over a ConnectivitySettings batch.

src/examples/ex_connectivity_metrics/main.cpp
ConnectivitySettings settings;
for (int i = 0; i < kTrials; ++i) {
settings.append(makeTrial(gen)); // channels x samples, one call per trial
}
settings.setSamplingFrequency(kSFreq);
settings.setFFTSize(kSamples);
settings.setWindowType("hanning");

MatrixX3f positions(3, 3);
positions << 0.0f, 0.0f, 0.0f, 0.05f, 0.0f, 0.0f, 0.0f, 0.05f, 0.0f;
settings.setNodePositions(positions);
src/examples/ex_connectivity_metrics/main.cpp
settings.setConnectivityMethods({"COH", "PLV", "WPLI"});
const QList<Network> networks = Connectivity::calculate(settings);
for (Network network : networks) {
network.setFrequencyRange(8.0f, 12.0f); // average the per-bin weights over the alpha band
qInfo().noquote() << network.getConnectivityMethod() << "0-1:" << edgeWeight(network, 0, 1);
}

Public Methods​

Connectivity()​

Constructs a Connectivity object.


Static Methods​

calculate(connectivitySettings)​

Computes the network based on the current settings.

Parameters:

  • connectivitySettings : ConnectivitySettings & Input trials and requested methods; per-trial spectral caches are filled in during computation.

Returns:

  • QList< Network > — Returns the list with calculated networks for each provided method.

Example​

Used in examples​

ex_connectivity_metrics​

Connectivity metrics on synthetic data with a known coupling.

src/examples/ex_connectivity_metrics/main.cpp, line 166
settings.setConnectivityMethods({"COH", "PLV", "WPLI"});
const QList<Network> networks = Connectivity::calculate(settings);
for (Network network : networks) {
network.setFrequencyRange(8.0f, 12.0f); // average the per-bin weights over the alpha band
qInfo().noquote() << network.getConnectivityMethod() << "0-1:" << edgeWeight(network, 0, 1);
}
ok &= expect(networks.size() == 3, "Connectivity::calculate returns one network per method");

ex_connectivity​

Example of using the MNE-CPP Connectivity library.

src/examples/ex_connectivity/main.cpp, line 107
QCommandLineParser parser;
parser.setApplicationDescription("Connectivity Example");
parser.addHelpOption();

ex_connectivity_comparison​

Example to compare connectivity methods.

src/examples/ex_connectivity_comparison/main.cpp, line 100
QCommandLineParser parser;
parser.setApplicationDescription("Connectivity Comparison Example");
parser.addHelpOption();

Also used in ex_dsp_rt, ex_connectivity_performance.

Authors of this file​