47 using namespace MNELIB;
48 using namespace Eigen;
49 using namespace FIFFLIB;
61 , rr(MatrixX3f::Zero(0,3))
62 , nn(MatrixX3f::Zero(0,3))
63 , tris(MatrixX3i::Zero(0,3))
65 , inuse(VectorXi::Zero(0))
66 , vertno(VectorXi::Zero(0))
68 , use_tris(MatrixX3i::Zero(0,3))
69 , nearest(VectorXi::Zero(0))
70 , nearest_dist(VectorXd::Zero(0))
71 , patch_inds(VectorXi::Zero(0))
73 , dist(SparseMatrix<double>())
74 , tri_cent(MatrixX3d::Zero(0,3))
75 , tri_nn(MatrixX3d::Zero(0,3))
76 , tri_area(VectorXd::Zero(0))
77 , use_tri_cent(MatrixX3d::Zero(0,3))
78 , use_tri_nn(MatrixX3d::Zero(0,3))
79 , use_tri_area(VectorXd::Zero(0))
88 : type(p_MNEHemisphere.type)
89 , id(p_MNEHemisphere.id)
90 , np(p_MNEHemisphere.np)
91 , ntri(p_MNEHemisphere.ntri)
92 , coord_frame(p_MNEHemisphere.coord_frame)
93 , rr(p_MNEHemisphere.rr)
94 , nn(p_MNEHemisphere.nn)
95 , tris(p_MNEHemisphere.tris)
96 , nuse(p_MNEHemisphere.nuse)
97 , inuse(p_MNEHemisphere.inuse)
98 , vertno(p_MNEHemisphere.vertno)
99 , nuse_tri(p_MNEHemisphere.nuse_tri)
100 , use_tris(p_MNEHemisphere.use_tris)
101 , nearest(p_MNEHemisphere.nearest)
102 , nearest_dist(p_MNEHemisphere.nearest_dist)
103 , pinfo(p_MNEHemisphere.pinfo)
104 , patch_inds(p_MNEHemisphere.patch_inds)
105 , dist_limit(p_MNEHemisphere.dist_limit)
106 , dist(p_MNEHemisphere.dist)
107 , tri_cent(p_MNEHemisphere.tri_cent)
108 , tri_nn(p_MNEHemisphere.tri_nn)
109 , tri_area(p_MNEHemisphere.tri_area)
110 , use_tri_cent(p_MNEHemisphere.use_tri_cent)
111 , use_tri_nn(p_MNEHemisphere.use_tri_nn)
112 , use_tri_area(p_MNEHemisphere.use_tri_area)
113 , neighbor_tri(p_MNEHemisphere.neighbor_tri)
114 , neighbor_vert(p_MNEHemisphere.neighbor_vert)
115 , cluster_info(p_MNEHemisphere.cluster_info)
116 , m_TriCoords(p_MNEHemisphere.m_TriCoords)
138 for (p = 0; p < this->
tris.rows(); p++) {
139 for (
k = 0;
k < 3;
k++) {
147 for (k = 0;
k < this->
np; k++) {
150 for (c = 0; c < 3; c++) {
183 rr = MatrixX3f::Zero(0,3);
184 nn = MatrixX3f::Zero(0,3);
185 tris = MatrixX3i::Zero(0,3);
187 inuse = VectorXi::Zero(0);
188 vertno = VectorXi::Zero(0);
196 dist = SparseMatrix<double>();
198 tri_nn = MatrixX3d::Zero(0,3);
209 m_TriCoords = MatrixXf();
216 if(m_TriCoords.size() == 0)
218 m_TriCoords = MatrixXf(3,3*
tris.rows());
219 for(qint32 i = 0; i <
tris.rows(); ++i)
221 m_TriCoords.col(i*3) =
rr.row(
tris(i,0) ).transpose().cast<
float>();
222 m_TriCoords.col(i*3+1) =
rr.row(
tris(i,1) ).transpose().cast<
float>();
223 m_TriCoords.col(i*3+2) =
rr.row(
tris(i,2) ).transpose().cast<
float>();
227 m_TriCoords *= p_fScaling;
244 if (trans.
to == this->coord_frame && trans.
from == dest)
246 else if(trans.
from != this->coord_frame || trans.
to != dest)
248 printf(
"Cannot transform the source space using this coordinate transformation");
252 MatrixXf t = trans.
trans.block(0,0,3,4);
255 MatrixXf t_rr = MatrixXf::Ones(this->
np, 4);
256 t_rr.block(0, 0, this->
np, 3) = this->
rr;
257 MatrixXf t_nn = MatrixXf::Zero(this->
np, 4);
258 t_nn.block(0, 0, this->
np, 3) = this->
nn;
260 this->
rr = (t*t_rr.transpose()).transpose();
261 this->
nn = (t*t_nn.transpose()).transpose();
270 if(this->
type == 1 || this->
type == 2)
273 printf(
"Unknown source space type (%d)\n", this->
type);
283 qDebug() <<
"ToDo: Write Volume not implemented yet!!!!!!!!";
303 p_pStream->
end_block(FIFFB_MNE_PARENT_MRI_FILE);
333 if (this->
dist.rows() > 0)
336 typedef Eigen::Triplet<float> T;
337 std::vector<T> tripletList;
338 tripletList.reserve(this->
dist.nonZeros());
339 for (
int k=0;
k < this->
dist.outerSize(); ++
k)
340 for (SparseMatrix<double>::InnerIterator it(this->
dist,
k); it; ++it)
341 if(it.col() >= it.row())
342 tripletList.push_back(T(it.row(), it.col(), (
float)it.value()));
343 SparseMatrix<float> dists(this->
dist.rows(), this->dist.cols());
344 dists.setFromTriplets(tripletList.begin(), tripletList.end());