v2.0.0
Loading...
Searching...
No Matches
imagcoherence.cpp
Go to the documentation of this file.
1//=============================================================================================================
15
16//=============================================================================================================
17// INCLUDES
18//=============================================================================================================
19
20#include "coherency.h"
21#include "imagcoherence.h"
24#include "../network/network.h"
25
26//=============================================================================================================
27// QT INCLUDES
28//=============================================================================================================
29
30#include <QDebug>
31#include <QtConcurrent>
32
33//=============================================================================================================
34// EIGEN INCLUDES
35//=============================================================================================================
36
37#include <unsupported/Eigen/FFT>
38
39//=============================================================================================================
40// USED NAMESPACES
41//=============================================================================================================
42
43using namespace CONNECTIVITYLIB;
44using namespace Eigen;
45
46//=============================================================================================================
47// DEFINE GLOBAL METHODS
48//=============================================================================================================
49
50//=============================================================================================================
51// DEFINE MEMBER METHODS
52//=============================================================================================================
53
57
58//*******************************************************************************************************
59
61{
62 Network finalNetwork("IMAGCOH");
63
64 if(connectivitySettings.isEmpty()) {
65 qDebug() << "ImagCoherence::calculate - Input data is empty";
66 return finalNetwork;
67 }
68
70 connectivitySettings.clearIntermediateData();
71 }
72
73 finalNetwork.setSamplingFrequency(connectivitySettings.getSamplingFrequency());
74
75 // Check if start and bin amount need to be reset to full spectrum
76 int iNfft = connectivitySettings.getFFTSize();
77
78// // Check that iNfft >= signal length
79// if(iNfft > connectivitySettings.at(0).matData.cols()) {
80// iNfft = connectivitySettings.at(0).matData.cols();
81// }
82
83 int iNFreqs = int(floor(iNfft / 2.0)) + 1;
84
85 if(m_iNumberBinStart == -1 ||
86 m_iNumberBinAmount == -1 ||
87 m_iNumberBinStart > iNFreqs ||
88 m_iNumberBinAmount > iNFreqs ||
90 qDebug() << "ImagCoherence::calculate - Resetting to full spectrum";
93 }
94
95 // Pass information about the FFT length. Use iNFreqs because we only use the half spectrum
96 finalNetwork.setFFTSize(iNFreqs);
98
99 //Create nodes
100 int rows = connectivitySettings.at(0).matData.rows();
101 RowVectorXf rowVert = RowVectorXf::Zero(3);
102
103 for(int i = 0; i < rows; ++i) {
104 rowVert = RowVectorXf::Zero(3);
105
106 if(connectivitySettings.getNodePositions().rows() != 0 && i < connectivitySettings.getNodePositions().rows()) {
107 rowVert(0) = connectivitySettings.getNodePositions().row(i)(0);
108 rowVert(1) = connectivitySettings.getNodePositions().row(i)(1);
109 rowVert(2) = connectivitySettings.getNodePositions().row(i)(2);
110 }
111
112 finalNetwork.append(NetworkNode::SPtr(new NetworkNode(i, rowVert)));
113 }
114
115 //Calculate all-to-all imaginary coherence matrix over epochs
116 Coherency::calculateImag(finalNetwork,
117 connectivitySettings);
118
119 return finalNetwork;
120}
Complex coherency between every channel pair and its two reductions: magnitude (coherence) and imagin...
Volume-conduction-robust imaginary coherence (Nolte et al., 2004) between every channel pair.
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 void calculateImag(Network &finalNetwork, ConnectivitySettings &connectivitySettings)
static Network calculate(ConnectivitySettings &connectivitySettings)
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