29#include <QElapsedTimer>
30#include <QtConcurrent>
36#include <unsupported/Eigen/FFT>
67 if (connectivitySettings.
isEmpty()) {
68 qDebug() <<
"Correlation::calculate - Input data is empty";
75 int rows = connectivitySettings.
at(0).
matData.rows();
76 RowVectorXf rowVert = RowVectorXf::Zero(3);
78 for (
int i = 0; i < rows; ++i) {
79 rowVert = RowVectorXf::Zero(3);
98 QFuture<MatrixXd> resultMat = QtConcurrent::mappedReduced(connectivitySettings.
getTrialData(),
101 resultMat.waitForFinished();
103 MatrixXd matDist = resultMat.result() / connectivitySettings.
size();
118 MatrixXd matWeight(1, 1);
119 QSharedPointer<NetworkEdge> pEdge;
122 for (
int i = 0; i < matDist.rows(); ++i) {
123 for (j = i; j < matDist.cols(); ++j) {
124 matWeight << matDist(i, j);
126 pEdge = QSharedPointer<NetworkEdge>(
new NetworkEdge(i, j, matWeight));
128 finalNetwork.
getNodeAt(i)->append(pEdge);
129 finalNetwork.
getNodeAt(j)->append(pEdge);
130 finalNetwork.
append(pEdge);
145 const MatrixXd centered = inputData.
matData.colwise() - inputData.
matData.rowwise().mean();
146 const VectorXd norms = centered.rowwise().norm();
147 MatrixXd matDist = centered * centered.transpose();
149 for (
int i = 0; i < matDist.rows(); ++i) {
150 for (
int j = 0; j < matDist.cols(); ++j) {
151 const double denom = norms(i) * norms(j);
152 matDist(i, j) = denom > 0.0 ? matDist(i, j) / denom : 0.0;
162 const MatrixXd& data)
164 if (resultData.rows() != data.rows() || resultData.cols() != data.cols()) {
165 resultData.resize(data.rows(), data.cols());
166 resultData.setZero();
Node of a connectivity CONNECTIVITYLIB::Network; carries a 3D position and the lists of incident (in ...
Weighted edge between two CONNECTIVITYLIB::NetworkNode instances; stores the full per-frequency weigh...
Graph container that stores the result of one functional-connectivity metric as nodes (sources/sensor...
Pearson correlation coefficient between every pair of zero-lag time-domain channels.
Functional connectivity metrics (coherence, PLV, cross-correlation, etc.).
Aggregates trial data, spectral cache and node geometry shared by all CONNECTIVITYLIB metrics.
QList< IntermediateTrialData > & getTrialData()
const IntermediateTrialData & at(int i) const
int getSamplingFrequency() const
const Eigen::MatrixX3f & getNodePositions() const
Per-trial intermediate frequency-domain data used during connectivity computation.
static Eigen::MatrixXd compute(const ConnectivitySettings::IntermediateTrialData &inputData)
static Network calculate(ConnectivitySettings &connectivitySettings)
static void reduce(Eigen::MatrixXd &resultData, const Eigen::MatrixXd &data)
Graph container for one connectivity metric; nodes + weighted edges + threshold/visualisation state.
void append(QSharedPointer< NetworkEdge > newEdge)
void setSamplingFrequency(float fSFreq)
QSharedPointer< NetworkNode > getNodeAt(int i)
Weighted, directional edge in a Network; carries per-frequency weights plus a band-averaged scalar.
Graph node carrying a 3D position and its incident in/out, full/thresholded edge lists.
QSharedPointer< NetworkNode > SPtr