v2.0.0
Loading...
Searching...
No Matches
mne_patch_info.cpp
Go to the documentation of this file.
1//=============================================================================================================
16
17//=============================================================================================================
18// INCLUDES
19//=============================================================================================================
20
21#include "mne_patch_info.h"
22#include "mne_source_space.h"
23#include <mne/mne_triangle.h>
24
25//=============================================================================================================
26// USED NAMESPACES
27//=============================================================================================================
28
29using namespace Eigen;
30using namespace MNELIB;
31
32constexpr int X = 0;
33constexpr int Y = 1;
34constexpr int Z = 2;
35
36//=============================================================================================================
37// DEFINE MEMBER METHODS
38//=============================================================================================================
39
41 :vert (-1)
42 ,area (0)
43 ,dev_nn (0)
44{
45 ave_nn[0] = 0;
46 ave_nn[1] = 0;
47 ave_nn[2] = 0;
48}
49
50//=============================================================================================================
51
53
54//=============================================================================================================
55
57{
58 int k,q;
59 int nneigh;
60
61 area = 0.0;
62 for (k = 0; k < memb_vert.size(); k++) {
63 nneigh = s->nneighbor_tri[memb_vert[k]];
64 const Eigen::VectorXi& neigh = s->neighbor_tri[memb_vert[k]];
65 for (q = 0; q < nneigh; q++)
66 area += s->tris[neigh[q]].area/3.0;
67 }
68}
69
70//=============================================================================================================
71
73{
74 int k;
75 float cos_theta,size;
76
77 Eigen::Map<Eigen::Vector3f> ave(ave_nn);
78 ave.setZero();
79
80 for (k = 0; k < memb_vert.size(); k++) {
81 ave += s->nn.row(memb_vert[k]).transpose();
82 }
83 size = ave.norm();
84 ave /= size;
85
86 dev_nn = 0.0;
87 for (k = 0; k < memb_vert.size(); k++) {
88 cos_theta = s->nn.row(memb_vert[k]).dot(ave);
89 if (cos_theta < -1.0)
90 cos_theta = -1.0;
91 else if (cos_theta > 1.0)
92 cos_theta = 1.0;
93 dev_nn += acos(cos_theta);
94 }
95 dev_nn = dev_nn/memb_vert.size();
96
97 return;
98}
constexpr int Y
constexpr int Z
constexpr int X
Single-hemisphere source space (cortical surface or volume grid) loaded from FIFF.
Patch information (cluster of cortex vertices around each decimated source) used by orientation prior...
Triangle descriptor with cached centroid, area and normal vectors.
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