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#define X_43 0
46#define Y_43 1
47#define Z_43 2
48
49#define VEC_DOT_43(x,y) ((x)[X_43]*(y)[X_43] + (x)[Y_43]*(y)[Y_43] + (x)[Z_43]*(y)[Z_43])
50
51//=============================================================================================================
52// USED NAMESPACES
53//=============================================================================================================
54
55using namespace Eigen;
56using namespace MNELIB;
57
58//=============================================================================================================
59// DEFINE MEMBER METHODS
60//=============================================================================================================
61
63 :vert (-1)
64 ,area (0)
65 ,dev_nn (0)
66{
67 ave_nn[0] = 0;
68 ave_nn[1] = 0;
69 ave_nn[2] = 0;
70}
71
72//=============================================================================================================
73
75
76//=============================================================================================================
77
79{
80 int k,q;
81 int nneigh;
82
83 area = 0.0;
84 for (k = 0; k < memb_vert.size(); k++) {
85 nneigh = s->nneighbor_tri[memb_vert[k]];
86 const Eigen::VectorXi& neigh = s->neighbor_tri[memb_vert[k]];
87 for (q = 0; q < nneigh; q++)
88 area += s->tris[neigh[q]].area/3.0;
89 }
90}
91
92//=============================================================================================================
93
95{
96 int k;
97 float cos_theta,size;
98
99 ave_nn[X_43] = 0.0;
100 ave_nn[Y_43] = 0.0;
101 ave_nn[Z_43] = 0.0;
102
103 for (k = 0; k < memb_vert.size(); k++) {
104 ave_nn[X_43] += s->nn(memb_vert[k],X_43);
105 ave_nn[Y_43] += s->nn(memb_vert[k],Y_43);
106 ave_nn[Z_43] += s->nn(memb_vert[k],Z_43);
107 }
108 size = sqrt(VEC_DOT_43(ave_nn,ave_nn));
109 ave_nn[X_43] = ave_nn[X_43]/size;
110 ave_nn[Y_43] = ave_nn[Y_43]/size;
111 ave_nn[Z_43] = ave_nn[Z_43]/size;
112
113 dev_nn = 0.0;
114 for (k = 0; k < memb_vert.size(); k++) {
115 cos_theta = VEC_DOT_43(&s->nn(memb_vert[k],0),ave_nn);
116 if (cos_theta < -1.0)
117 cos_theta = -1.0;
118 else if (cos_theta > 1.0)
119 cos_theta = 1.0;
120 dev_nn += acos(cos_theta);
121 }
122 dev_nn = dev_nn/memb_vert.size();
123
124 return;
125}
MNETriangle class declaration.
MNE Patch Information (MNEPatchInfo) class declaration.
#define VEC_DOT_43(x, y)
#define X_43
#define Z_43
#define Y_43
MNESourceSpace 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