MNE-CPP 0.1.9
A Framework for Electrophysiology
Loading...
Searching...
No Matches
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
57using namespace CONNECTIVITYLIB;
58using namespace Eigen;
59
60//=============================================================================================================
61// DEFINE GLOBAL METHODS
62//=============================================================================================================
63
64//=============================================================================================================
65// DEFINE MEMBER METHODS
66//=============================================================================================================
67
68NetworkEdge::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
96
97//=============================================================================================================
98
100{
101 return m_iEndNodeID;
102}
103
104//=============================================================================================================
105
106void 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
134void 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
165void 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
178const QPair<int,int>& NetworkEdge::getFrequencyBins()
179{
180 return m_iMinMaxFreqBins;
181}
182
NetworkEdge class declaration.
NetworkNode class declaration.
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)