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
32// Axis indices for coordinate access (kept for documentation).
33[[maybe_unused]] constexpr int X = 0;
34[[maybe_unused]] constexpr int Y = 1;
35[[maybe_unused]] constexpr int Z = 2;
36
37//=============================================================================================================
38// DEFINE MEMBER METHODS
39//=============================================================================================================
40
42: vert(-1)
43, area(0)
44, dev_nn(0)
45{
46 ave_nn[0] = 0;
47 ave_nn[1] = 0;
48 ave_nn[2] = 0;
49}
50
51//=============================================================================================================
52
54
55//=============================================================================================================
56
58{
59 int k, q;
60 int nneigh;
61
62 area = 0.0;
63 for (k = 0; k < memb_vert.size(); k++) {
64 nneigh = s->nneighbor_tri[memb_vert[k]];
65 const Eigen::VectorXi& neigh = s->neighbor_tri[memb_vert[k]];
66 for (q = 0; q < nneigh; q++)
67 area += s->tris[neigh[q]].area / 3.0;
68 }
69}
70
71//=============================================================================================================
72
74{
75 int k;
76 float cos_theta, size;
77
78 Eigen::Map<Eigen::Vector3f> ave(ave_nn);
79 ave.setZero();
80
81 for (k = 0; k < memb_vert.size(); k++) {
82 ave += s->nn.row(memb_vert[k]).transpose();
83 }
84 size = ave.norm();
85 ave /= size;
86
87 dev_nn = 0.0;
88 for (k = 0; k < memb_vert.size(); k++) {
89 cos_theta = s->nn.row(memb_vert[k]).dot(ave);
90 if (cos_theta < -1.0)
91 cos_theta = -1.0;
92 else if (cos_theta > 1.0)
93 cos_theta = 1.0;
94 dev_nn += acos(cos_theta);
95 }
96 dev_nn = dev_nn / memb_vert.size();
97
98 return;
99}
constexpr int Y
constexpr int Z
constexpr int X
Patch information (cluster of cortex vertices around each decimated source) used by orientation prior...
Triangle descriptor with cached centroid, area and normal vectors.
Single-hemisphere source space (cortical surface or volume grid) loaded from FIFF.
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