v2.0.0
Loading...
Searching...
No Matches
src
libraries
inv
inv_vector_source_estimate.cpp
Go to the documentation of this file.
1
//=============================================================================================================
18
19
//=============================================================================================================
20
// INCLUDES
21
//=============================================================================================================
22
23
#include "
inv_vector_source_estimate.h
"
24
25
//=============================================================================================================
26
// STD INCLUDES
27
//=============================================================================================================
28
29
#include <cmath>
30
31
//=============================================================================================================
32
// USED NAMESPACES
33
//=============================================================================================================
34
35
using namespace
INVLIB
;
36
using namespace
Eigen;
37
38
//=============================================================================================================
39
// DEFINE MEMBER METHODS
40
//=============================================================================================================
41
42
InvVectorSourceEstimate::InvVectorSourceEstimate
()
43
:
InvSourceEstimate
()
44
{
45
orientationType
=
InvOrientationType::Free
;
46
}
47
48
//=============================================================================================================
49
50
InvVectorSourceEstimate::InvVectorSourceEstimate
(
const
MatrixXd& p_sol,
51
const
VectorXi& p_vertices,
52
float
p_tmin,
float
p_tstep)
53
:
InvSourceEstimate
(p_sol, p_vertices, p_tmin, p_tstep)
54
{
55
orientationType
=
InvOrientationType::Free
;
56
}
57
58
//=============================================================================================================
59
60
int
InvVectorSourceEstimate::nVertices
()
const
61
{
62
return
static_cast<
int
>
(
data
.rows()) / 3;
63
}
64
65
//=============================================================================================================
66
67
InvSourceEstimate
InvVectorSourceEstimate::magnitude
()
const
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
87
MatrixXd
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
97
InvSourceEstimate
InvVectorSourceEstimate::projectToNormals
(
const
MatrixX3f& normals)
const
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
}
inv_vector_source_estimate.h
Free-orientation surface source estimate carrying a 3-component vector per vertex.
INVLIB
Inverse source estimation (MNE, dSPM, sLORETA, dipole fitting).
Definition
braintreemodel.h:42
INVLIB::InvOrientationType::Free
@ Free
Definition
inv_types.h:74
INVLIB::InvSourceEstimate
Source-space inverse-solution container with dense grid plus optional focal-dipole,...
Definition
inv_source_estimate.h:88
INVLIB::InvSourceEstimate::data
Eigen::MatrixXd data
Definition
inv_source_estimate.h:228
INVLIB::InvSourceEstimate::InvSourceEstimate
InvSourceEstimate()
Definition
inv_source_estimate.cpp:50
INVLIB::InvSourceEstimate::tstep
float tstep
Definition
inv_source_estimate.h:232
INVLIB::InvSourceEstimate::vertices
Eigen::VectorXi vertices
Definition
inv_source_estimate.h:229
INVLIB::InvSourceEstimate::orientationType
InvOrientationType orientationType
Definition
inv_source_estimate.h:237
INVLIB::InvSourceEstimate::tmin
float tmin
Definition
inv_source_estimate.h:231
INVLIB::InvVectorSourceEstimate::nVertices
int nVertices() const
Definition
inv_vector_source_estimate.cpp:60
INVLIB::InvVectorSourceEstimate::projectToNormals
InvSourceEstimate projectToNormals(const Eigen::MatrixX3f &normals) const
Definition
inv_vector_source_estimate.cpp:97
INVLIB::InvVectorSourceEstimate::magnitude
InvSourceEstimate magnitude() const
Definition
inv_vector_source_estimate.cpp:67
INVLIB::InvVectorSourceEstimate::vertexData
Eigen::MatrixXd vertexData(int vertexIdx) const
Definition
inv_vector_source_estimate.cpp:87
INVLIB::InvVectorSourceEstimate::InvVectorSourceEstimate
InvVectorSourceEstimate()
Definition
inv_vector_source_estimate.cpp:42
Generated on
for MNE-CPP by
1.16.1