v2.0.0
Loading...
Searching...
No Matches
coherence.cpp
Go to the documentation of this file.
1//=============================================================================================================
15
16//=============================================================================================================
17// INCLUDES
18//=============================================================================================================
19
20#include "coherency.h"
21#include "coherence.h"
24#include "../network/network.h"
26
27//=============================================================================================================
28// QT INCLUDES
29//=============================================================================================================
30
31#include <QDebug>
32#include <QtConcurrent>
33
34//=============================================================================================================
35// EIGEN INCLUDES
36//=============================================================================================================
37
38#include <unsupported/Eigen/FFT>
39
40//=============================================================================================================
41// USED NAMESPACES
42//=============================================================================================================
43
44using namespace CONNECTIVITYLIB;
45using namespace Eigen;
46
47//=============================================================================================================
48// DEFINE GLOBAL METHODS
49//=============================================================================================================
50
51//=============================================================================================================
52// DEFINE MEMBER METHODS
53//=============================================================================================================
54
58
59//*******************************************************************************************************
60
62{
63 Network finalNetwork("COH");
64
65 if(connectivitySettings.isEmpty()) {
66 qDebug() << "Coherence::calculate - Input data is empty";
67 return finalNetwork;
68 }
69
71 connectivitySettings.clearIntermediateData();
72 }
73
74 finalNetwork.setSamplingFrequency(connectivitySettings.getSamplingFrequency());
75
76 // Check if start and bin amount need to be reset to full spectrum
77 int iNfft = connectivitySettings.getFFTSize();
78 int iNFreqs = int(floor(iNfft / 2.0)) + 1;
79
80 if(m_iNumberBinStart == -1 ||
81 m_iNumberBinAmount == -1 ||
82 m_iNumberBinStart > iNFreqs ||
83 m_iNumberBinAmount > iNFreqs ||
85 qDebug() << "Coherence::calculate - Resetting to full spectrum";
88 }
89
90 // Pass information about the FFT length. Use iNFreqs because we only use the half spectrum
91 finalNetwork.setFFTSize(iNFreqs);
93
94 //Create nodes
95 int rows = connectivitySettings.at(0).matData.rows();
96 RowVectorXf rowVert = RowVectorXf::Zero(3);
97
98 for(int i = 0; i < rows; ++i) {
99 rowVert = RowVectorXf::Zero(3);
100
101 if(connectivitySettings.getNodePositions().rows() != 0 && i < connectivitySettings.getNodePositions().rows()) {
102 rowVert(0) = connectivitySettings.getNodePositions().row(i)(0);
103 rowVert(1) = connectivitySettings.getNodePositions().row(i)(1);
104 rowVert(2) = connectivitySettings.getNodePositions().row(i)(2);
105 }
106
107 finalNetwork.append(NetworkNode::SPtr(new NetworkNode(i, rowVert)));
108 }
109
110 //Calculate all-to-all coherence matrix over epochs
111 Coherency::calculateAbs(finalNetwork,
112 connectivitySettings);;
113
114 return finalNetwork;
115}
Complex coherency between every channel pair and its two reductions: magnitude (coherence) and imagin...
Magnitude-squared coherence (MSC) between every channel pair, band-averaged over the selected DPSS sp...
Input-data and parameter container shared by every functional-connectivity metric in CONNECTIVITYLIB.
Weighted edge between two NetworkNode instances; stores the full per-frequency weight matrix and the ...
Node of a connectivity Network; carries a 3D position and the lists of incident (in / out,...
Graph container that stores the result of one functional-connectivity metric as nodes (sources/sensor...
Functional connectivity metrics (coherence, PLV, cross-correlation, etc.).
Aggregates trial data, spectral cache and node geometry shared by all CONNECTIVITYLIB metrics.
const IntermediateTrialData & at(int i) const
const Eigen::MatrixX3f & getNodePositions() const
static Network calculate(ConnectivitySettings &connectivitySettings)
Definition coherence.cpp:61
static void calculateAbs(Network &finalNetwork, ConnectivitySettings &connectivitySettings)
Definition coherency.cpp:62
Graph container for one connectivity metric; nodes + weighted edges + threshold/visualisation state.
Definition network.h:98
void setUsedFreqBins(int iNumberFreqBins)
Definition network.cpp:493
void append(QSharedPointer< NetworkEdge > newEdge)
void setFFTSize(int iFFTSize)
Definition network.cpp:500
void setSamplingFrequency(float fSFreq)
Definition network.cpp:479
Graph node carrying a 3D position and its incident in/out, full/thresholded edge lists.
Definition networknode.h:80
QSharedPointer< NetworkNode > SPtr
Definition networknode.h:83