v2.0.0
Loading...
Searching...
No Matches
inv_vector_source_estimate.cpp
Go to the documentation of this file.
1//=============================================================================================================
18
19//=============================================================================================================
20// INCLUDES
21//=============================================================================================================
22
24
25//=============================================================================================================
26// STD INCLUDES
27//=============================================================================================================
28
29#include <cmath>
30
31//=============================================================================================================
32// USED NAMESPACES
33//=============================================================================================================
34
35using namespace INVLIB;
36using namespace Eigen;
37
38//=============================================================================================================
39// DEFINE MEMBER METHODS
40//=============================================================================================================
41
47
48//=============================================================================================================
49
51 const VectorXi& p_vertices,
52 float p_tmin, float p_tstep)
53: InvSourceEstimate(p_sol, p_vertices, p_tmin, p_tstep)
54{
56}
57
58//=============================================================================================================
59
61{
62 return static_cast<int>(data.rows()) / 3;
63}
64
65//=============================================================================================================
66
68{
69 const int nVert = nVertices();
70 const int nTimes = static_cast<int>(data.cols());
71
72 MatrixXd mag(nVert, nTimes);
73 for (int v = 0; v < nVert; ++v) {
74 for (int t = 0; t < nTimes; ++t) {
75 double x = data(v * 3, t);
76 double y = data(v * 3 + 1, t);
77 double z = data(v * 3 + 2, t);
78 mag(v, t) = std::sqrt(x * x + y * y + z * z);
79 }
80 }
81
82 return InvSourceEstimate(mag, vertices, tmin, tstep);
83}
84
85//=============================================================================================================
86
87MatrixXd InvVectorSourceEstimate::vertexData(int vertexIdx) const
88{
89 if (vertexIdx < 0 || vertexIdx >= nVertices())
90 return MatrixXd();
91
92 return data.middleRows(vertexIdx * 3, 3);
93}
94
95//=============================================================================================================
96
98{
99 const int nVert = nVertices();
100 const int nTimes = static_cast<int>(data.cols());
101
102 if (normals.rows() != nVert)
103 return InvSourceEstimate();
104
105 MatrixXd proj(nVert, nTimes);
106 for (int v = 0; v < nVert; ++v) {
107 Vector3d n(normals(v, 0), normals(v, 1), normals(v, 2));
108 n.normalize();
109 for (int t = 0; t < nTimes; ++t) {
110 proj(v, t) = n[0] * data(v * 3, t) + n[1] * data(v * 3 + 1, t) + n[2] * data(v * 3 + 2, t);
111 }
112 }
113
114 return InvSourceEstimate(proj, vertices, tmin, tstep);
115}
Free-orientation surface source estimate carrying a 3-component vector per vertex.
Inverse source estimation (MNE, dSPM, sLORETA, dipole fitting).
Source-space inverse-solution container with dense grid plus optional focal-dipole,...
InvOrientationType orientationType
InvSourceEstimate projectToNormals(const Eigen::MatrixX3f &normals) const
Eigen::MatrixXd vertexData(int vertexIdx) const