v2.0.0
Loading...
Searching...
No Matches
networkedge.cpp
Go to the documentation of this file.
1//=============================================================================================================
14
15//=============================================================================================================
16// INCLUDES
17//=============================================================================================================
18
19#include "networkedge.h"
20
21#include "networknode.h"
22
23//=============================================================================================================
24// QT INCLUDES
25//=============================================================================================================
26
27#include <QDebug>
28
29//=============================================================================================================
30// EIGEN INCLUDES
31//=============================================================================================================
32
33//=============================================================================================================
34// USED NAMESPACES
35//=============================================================================================================
36
37using namespace CONNECTIVITYLIB;
38using namespace Eigen;
39
40//=============================================================================================================
41// DEFINE GLOBAL METHODS
42//=============================================================================================================
43
44//=============================================================================================================
45// DEFINE MEMBER METHODS
46//=============================================================================================================
47
48NetworkEdge::NetworkEdge(int iStartNodeID,
49 int iEndNodeID,
50 const MatrixXd& matWeight,
51 bool bIsActive,
52 int iStartWeightBin,
53 int iEndWeightBin)
54: m_iStartNodeID(iStartNodeID)
55, m_iEndNodeID(iEndNodeID)
56, m_bIsActive(bIsActive)
57, m_iMinMaxFreqBins(QPair<int,int>(iStartWeightBin,iEndWeightBin))
59{
60 if(matWeight.rows() == 0 || matWeight.cols() == 0) {
61 m_matWeight = MatrixXd::Zero(1,1);
62 qDebug() << "NetworkEdge::NetworkEdge - Matrix weights number of rows and/or columns are zero. Setting to 1x1 zero matrix.";
63 } else {
64 m_matWeight = matWeight;
65 }
66
68}
69
70//=============================================================================================================
71
76
77//=============================================================================================================
78
80{
81 return m_iEndNodeID;
82}
83
84//=============================================================================================================
85
86void NetworkEdge::setActive(bool bActiveFlag)
87{
88 m_bIsActive = bActiveFlag;
89}
90
91//=============================================================================================================
92
94{
95 return m_bIsActive;
96}
97
98//=============================================================================================================
99
101{
102 return m_dAveragedWeight;
103}
104
105//=============================================================================================================
106
108{
109 return m_matWeight;
110}
111
112//=============================================================================================================
113
114void NetworkEdge::setWeight(double dAveragedWeight)
115{
116 m_dAveragedWeight = dAveragedWeight;
117}
118
119//=============================================================================================================
120
122{
123 int iStartWeightBin = m_iMinMaxFreqBins.first;
124 int iEndWeightBin = m_iMinMaxFreqBins.second;
125
126 if(iEndWeightBin < iStartWeightBin || iStartWeightBin < -1 || iEndWeightBin < -1 ) {
127 return;
128 }
129
130 int rows = m_matWeight.rows();
131
132 if ((iEndWeightBin == -1 && iStartWeightBin == -1) ) {
134 } else if(iStartWeightBin < rows) {
135 if(iEndWeightBin < rows) {
136 m_dAveragedWeight = m_matWeight.block(iStartWeightBin,0,iEndWeightBin-iStartWeightBin+1,1).mean();
137 } else {
138 m_dAveragedWeight = m_matWeight.block(iStartWeightBin,0,rows-iStartWeightBin,1).mean();
139 }
140 }
141}
142
143//=============================================================================================================
144
145void NetworkEdge::setFrequencyBins(const QPair<int,int>& minMaxFreqBins)
146{
147 m_iMinMaxFreqBins = minMaxFreqBins;
148
149 if(m_iMinMaxFreqBins.second < m_iMinMaxFreqBins.first || m_iMinMaxFreqBins.first < -1 || m_iMinMaxFreqBins.second < -1 ) {
150 return;
151 }
152
154}
155
156//=============================================================================================================
157
158const QPair<int,int>& NetworkEdge::getFrequencyBins()
159{
160 return m_iMinMaxFreqBins;
161}
162
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,...
Functional connectivity metrics (coherence, PLV, cross-correlation, etc.).
void setFrequencyBins(const QPair< int, int > &minMaxFreqBins)
Eigen::MatrixXd getMatrixWeight() const
const QPair< int, int > & getFrequencyBins()
QPair< int, int > m_iMinMaxFreqBins
void setWeight(double dAveragedWeight)
NetworkEdge(int iStartNodeID, int iEndNodeID, const Eigen::MatrixXd &matWeight, bool bIsActive=true, int iStartWeightBin=-1, int iEndWeightBin=-1)
void setActive(bool bActiveFlag)