v2.0.0
Loading...
Searching...
No Matches
mne_patch_info.cpp
Go to the documentation of this file.
1//=============================================================================================================
36
37//=============================================================================================================
38// INCLUDES
39//=============================================================================================================
40
41#include "mne_patch_info.h"
42#include "mne_source_space.h"
43#include <mne/mne_triangle.h>
44
45//=============================================================================================================
46// USED NAMESPACES
47//=============================================================================================================
48
49using namespace Eigen;
50using namespace MNELIB;
51
52constexpr int X = 0;
53constexpr int Y = 1;
54constexpr int Z = 2;
55
56//=============================================================================================================
57// DEFINE MEMBER METHODS
58//=============================================================================================================
59
61 :vert (-1)
62 ,area (0)
63 ,dev_nn (0)
64{
65 ave_nn[0] = 0;
66 ave_nn[1] = 0;
67 ave_nn[2] = 0;
68}
69
70//=============================================================================================================
71
73
74//=============================================================================================================
75
77{
78 int k,q;
79 int nneigh;
80
81 area = 0.0;
82 for (k = 0; k < memb_vert.size(); k++) {
83 nneigh = s->nneighbor_tri[memb_vert[k]];
84 const Eigen::VectorXi& neigh = s->neighbor_tri[memb_vert[k]];
85 for (q = 0; q < nneigh; q++)
86 area += s->tris[neigh[q]].area/3.0;
87 }
88}
89
90//=============================================================================================================
91
93{
94 int k;
95 float cos_theta,size;
96
97 Eigen::Map<Eigen::Vector3f> ave(ave_nn);
98 ave.setZero();
99
100 for (k = 0; k < memb_vert.size(); k++) {
101 ave += s->nn.row(memb_vert[k]).transpose();
102 }
103 size = ave.norm();
104 ave /= size;
105
106 dev_nn = 0.0;
107 for (k = 0; k < memb_vert.size(); k++) {
108 cos_theta = s->nn.row(memb_vert[k]).dot(ave);
109 if (cos_theta < -1.0)
110 cos_theta = -1.0;
111 else if (cos_theta > 1.0)
112 cos_theta = 1.0;
113 dev_nn += acos(cos_theta);
114 }
115 dev_nn = dev_nn/memb_vert.size();
116
117 return;
118}
constexpr int Y
constexpr int Z
constexpr int X
MNESourceSpace class declaration.
MNE Patch Information (MNEPatchInfo) class declaration.
MNETriangle class declaration.
Core MNE data structures (source spaces, source estimates, hemispheres).
void calculate_area(MNESourceSpace *s)
void calculate_normal_stats(MNESourceSpace *s)
Eigen::VectorXi memb_vert
This defines a source space.
std::vector< Eigen::VectorXi > neighbor_tri
std::vector< MNETriangle > tris