MNE-CPP  0.1.9
A Framework for Electrophysiology
networkedge.cpp
Go to the documentation of this file.
1 //=============================================================================================================
35 //=============================================================================================================
36 // INCLUDES
37 //=============================================================================================================
38 
39 #include "networkedge.h"
40 
41 #include "networknode.h"
42 
43 //=============================================================================================================
44 // QT INCLUDES
45 //=============================================================================================================
46 
47 #include <QDebug>
48 
49 //=============================================================================================================
50 // EIGEN INCLUDES
51 //=============================================================================================================
52 
53 //=============================================================================================================
54 // USED NAMESPACES
55 //=============================================================================================================
56 
57 using namespace CONNECTIVITYLIB;
58 using namespace Eigen;
59 
60 //=============================================================================================================
61 // DEFINE GLOBAL METHODS
62 //=============================================================================================================
63 
64 //=============================================================================================================
65 // DEFINE MEMBER METHODS
66 //=============================================================================================================
67 
68 NetworkEdge::NetworkEdge(int iStartNodeID,
69  int iEndNodeID,
70  const MatrixXd& matWeight,
71  bool bIsActive,
72  int iStartWeightBin,
73  int iEndWeightBin)
74 : m_iStartNodeID(iStartNodeID)
75 , m_iEndNodeID(iEndNodeID)
76 , m_bIsActive(bIsActive)
77 , m_iMinMaxFreqBins(QPair<int,int>(iStartWeightBin,iEndWeightBin))
78 , m_dAveragedWeight(0.0)
79 {
80  if(matWeight.rows() == 0 || matWeight.cols() == 0) {
81  m_matWeight = MatrixXd::Zero(1,1);
82  qDebug() << "NetworkEdge::NetworkEdge - Matrix weights number of rows and/or columns are zero. Setting to 1x1 zero matrix.";
83  } else {
84  m_matWeight = matWeight;
85  }
86 
88 }
89 
90 //=============================================================================================================
91 
93 {
94  return m_iStartNodeID;
95 }
96 
97 //=============================================================================================================
98 
100 {
101  return m_iEndNodeID;
102 }
103 
104 //=============================================================================================================
105 
106 void NetworkEdge::setActive(bool bActiveFlag)
107 {
108  m_bIsActive = bActiveFlag;
109 }
110 
111 //=============================================================================================================
112 
114 {
115  return m_bIsActive;
116 }
117 
118 //=============================================================================================================
119 
121 {
122  return m_dAveragedWeight;
123 }
124 
125 //=============================================================================================================
126 
128 {
129  return m_matWeight;
130 }
131 
132 //=============================================================================================================
133 
134 void NetworkEdge::setWeight(double dAveragedWeight)
135 {
136  m_dAveragedWeight = dAveragedWeight;
137 }
138 
139 //=============================================================================================================
140 
142 {
143  int iStartWeightBin = m_iMinMaxFreqBins.first;
144  int iEndWeightBin = m_iMinMaxFreqBins.second;
145 
146  if(iEndWeightBin < iStartWeightBin || iStartWeightBin < -1 || iEndWeightBin < -1 ) {
147  return;
148  }
149 
150  int rows = m_matWeight.rows();
151 
152  if ((iEndWeightBin == -1 && iStartWeightBin == -1) ) {
154  } else if(iStartWeightBin < rows) {
155  if(iEndWeightBin < rows) {
156  m_dAveragedWeight = m_matWeight.block(iStartWeightBin,0,iEndWeightBin-iStartWeightBin+1,1).mean();
157  } else {
158  m_dAveragedWeight = m_matWeight.block(iStartWeightBin,0,rows-iStartWeightBin,1).mean();
159  }
160  }
161 }
162 
163 //=============================================================================================================
164 
165 void NetworkEdge::setFrequencyBins(const QPair<int,int>& minMaxFreqBins)
166 {
167  m_iMinMaxFreqBins = minMaxFreqBins;
168 
169  if(m_iMinMaxFreqBins.second < m_iMinMaxFreqBins.first || m_iMinMaxFreqBins.first < -1 || m_iMinMaxFreqBins.second < -1 ) {
170  return;
171  }
172 
174 }
175 
176 //=============================================================================================================
177 
178 const QPair<int,int>& NetworkEdge::getFrequencyBins()
179 {
180  return m_iMinMaxFreqBins;
181 }
182 
CONNECTIVITYLIB::NetworkEdge::setFrequencyBins
void setFrequencyBins(const QPair< int, int > &minMaxFreqBins)
Definition: networkedge.cpp:165
CONNECTIVITYLIB::NetworkEdge::getFrequencyBins
const QPair< int, int > & getFrequencyBins()
Definition: networkedge.cpp:178
networknode.h
NetworkNode class declaration.
CONNECTIVITYLIB::NetworkEdge::m_iEndNodeID
int m_iEndNodeID
Definition: networkedge.h:184
CONNECTIVITYLIB::NetworkEdge::getStartNodeID
int getStartNodeID()
Definition: networkedge.cpp:92
CONNECTIVITYLIB::NetworkEdge::setActive
void setActive(bool bActiveFlag)
Definition: networkedge.cpp:106
CONNECTIVITYLIB::NetworkEdge::getEndNodeID
int getEndNodeID()
Definition: networkedge.cpp:99
CONNECTIVITYLIB::NetworkEdge::isActive
bool isActive()
Definition: networkedge.cpp:113
CONNECTIVITYLIB::NetworkEdge::getWeight
double getWeight() const
Definition: networkedge.cpp:120
CONNECTIVITYLIB::NetworkEdge::m_iStartNodeID
int m_iStartNodeID
Definition: networkedge.h:183
CONNECTIVITYLIB::NetworkEdge::m_dAveragedWeight
double m_dAveragedWeight
Definition: networkedge.h:192
CONNECTIVITYLIB::NetworkEdge::m_bIsActive
bool m_bIsActive
Definition: networkedge.h:186
networkedge.h
NetworkEdge class declaration.
CONNECTIVITYLIB::NetworkEdge::setWeight
void setWeight(double dAveragedWeight)
Definition: networkedge.cpp:134
CONNECTIVITYLIB::NetworkEdge::calculateAveragedWeight
void calculateAveragedWeight()
Definition: networkedge.cpp:141
CONNECTIVITYLIB::NetworkEdge::getMatrixWeight
Eigen::MatrixXd getMatrixWeight() const
Definition: networkedge.cpp:127
CONNECTIVITYLIB::NetworkEdge::m_matWeight
Eigen::MatrixXd m_matWeight
Definition: networkedge.h:190
CONNECTIVITYLIB::NetworkEdge::m_iMinMaxFreqBins
QPair< int, int > m_iMinMaxFreqBins
Definition: networkedge.h:188
CONNECTIVITYLIB::NetworkEdge::NetworkEdge
NetworkEdge(int iStartNodeID, int iEndNodeID, const Eigen::MatrixXd &matWeight, bool bIsActive=true, int iStartWeightBin=-1, int iEndWeightBin=-1)
Definition: networkedge.cpp:68