64 , rr(MatrixX3f::Zero(0,3))
65 , nn(MatrixX3f::Zero(0,3))
66 , tris(MatrixX3i::Zero(0,3))
68 , inuse(VectorXi::Zero(0))
69 , vertno(VectorXi::Zero(0))
71 , use_tris(MatrixX3i::Zero(0,3))
72 , nearest(VectorXi::Zero(0))
73 , nearest_dist(VectorXd::Zero(0))
74 , patch_inds(VectorXi::Zero(0))
76 , dist(SparseMatrix<double>())
77 , tri_cent(MatrixX3d::Zero(0,3))
78 , tri_nn(MatrixX3d::Zero(0,3))
79 , tri_area(VectorXd::Zero(0))
80 , use_tri_cent(MatrixX3d::Zero(0,3))
81 , use_tri_nn(MatrixX3d::Zero(0,3))
82 , use_tri_area(VectorXd::Zero(0))
92 : type(p_MNEHemisphere.type)
93 , id(p_MNEHemisphere.id)
94 , np(p_MNEHemisphere.np)
95 , ntri(p_MNEHemisphere.ntri)
96 , coord_frame(p_MNEHemisphere.coord_frame)
97 , rr(p_MNEHemisphere.rr)
98 , nn(p_MNEHemisphere.nn)
99 , tris(p_MNEHemisphere.tris)
100 , nuse(p_MNEHemisphere.nuse)
101 , inuse(p_MNEHemisphere.inuse)
102 , vertno(p_MNEHemisphere.vertno)
103 , nuse_tri(p_MNEHemisphere.nuse_tri)
104 , use_tris(p_MNEHemisphere.use_tris)
105 , nearest(p_MNEHemisphere.nearest)
106 , nearest_dist(p_MNEHemisphere.nearest_dist)
107 , pinfo(p_MNEHemisphere.pinfo)
108 , patch_inds(p_MNEHemisphere.patch_inds)
109 , dist_limit(p_MNEHemisphere.dist_limit)
110 , dist(p_MNEHemisphere.dist)
111 , tri_cent(p_MNEHemisphere.tri_cent)
112 , tri_nn(p_MNEHemisphere.tri_nn)
113 , tri_area(p_MNEHemisphere.tri_area)
114 , use_tri_cent(p_MNEHemisphere.use_tri_cent)
115 , use_tri_nn(p_MNEHemisphere.use_tri_nn)
116 , use_tri_area(p_MNEHemisphere.use_tri_area)
117 , neighbor_tri(p_MNEHemisphere.neighbor_tri)
118 , neighbor_vert(p_MNEHemisphere.neighbor_vert)
119 , cluster_info(p_MNEHemisphere.cluster_info)
120 , m_TriCoords(p_MNEHemisphere.m_TriCoords)
143 rr = MatrixX3f::Zero(0,3);
144 nn = MatrixX3f::Zero(0,3);
145 tris = MatrixX3i::Zero(0,3);
147 inuse = VectorXi::Zero(0);
148 vertno = VectorXi::Zero(0);
156 dist = SparseMatrix<double>();
158 tri_nn = MatrixX3d::Zero(0,3);
169 m_TriCoords = MatrixXf();
177 if(m_TriCoords.size() == 0)
179 m_TriCoords = MatrixXf(3,3*
tris.rows());
180 for(qint32 i = 0; i <
tris.rows(); ++i)
182 m_TriCoords.col(i*3) =
rr.row(
tris(i,0) ).transpose().cast<
float>();
183 m_TriCoords.col(i*3+1) =
rr.row(
tris(i,1) ).transpose().cast<
float>();
184 m_TriCoords.col(i*3+2) =
rr.row(
tris(i,2) ).transpose().cast<
float>();
188 m_TriCoords *= p_fScaling;
206 if (trans.
to == this->coord_frame && trans.
from == dest)
208 else if(trans.
from != this->coord_frame || trans.
to != dest)
210 printf(
"Cannot transform the source space using this coordinate transformation");
214 MatrixXf t = trans.
trans.block(0,0,3,4);
217 MatrixXf t_rr = MatrixXf::Ones(this->
np, 4);
218 t_rr.block(0, 0, this->
np, 3) = this->
rr;
219 MatrixXf t_nn = MatrixXf::Zero(this->
np, 4);
220 t_nn.block(0, 0, this->
np, 3) = this->
nn;
222 this->
rr = (t*t_rr.transpose()).transpose();
223 this->
nn = (t*t_nn.transpose()).transpose();
233 if(this->
type == 1 || this->
type == 2)
236 printf(
"Unknown source space type (%d)\n", this->
type);
246 qDebug() <<
"ToDo: Write Volume not implemented jet!!!!!!!!";
266 p_pStream->
end_block(FIFFB_MNE_PARENT_MRI_FILE);
296 if (this->
dist.rows() > 0)
299 typedef Eigen::Triplet<float> T;
300 std::vector<T> tripletList;
301 tripletList.reserve(this->
dist.nonZeros());
302 for (
int k=0; k < this->
dist.outerSize(); ++k)
303 for (SparseMatrix<double>::InnerIterator it(this->
dist,k); it; ++it)
304 if(it.col() >= it.row())
305 tripletList.push_back(T(it.row(), it.col(), (float)it.value()));
306 SparseMatrix<float> dists(this->
dist.rows(), this->
dist.cols());
307 dists.setFromTriplets(tripletList.begin(), tripletList.end());
void write_int_matrix(fiff_int_t kind, const MatrixXi &mat)
#define FIFF_MNE_SOURCE_SPACE_NPOINTS
#define FIFF_MNE_SOURCE_SPACE_NORMALS
#define FIFF_MNE_SOURCE_SPACE_NUSE
bool transform_hemisphere_to(fiff_int_t dest, const FiffCoordTrans &p_Trans)
#define FIFF_MNE_SOURCE_SPACE_NTRI
MatrixXf & getTriCoords(float p_fScaling=1.0f)
#define FIFF_MNE_SOURCE_SPACE_ID
#define FIFF_MNE_SOURCE_SPACE_TRIANGLES
MNEHemisphere class declaration.
#define FIFF_MNE_SOURCE_SPACE_POINTS
QMap< int, QVector< int > > neighbor_vert
MNEClusterInfo cluster_info
SparseMatrix< double > dist
void write_float(fiff_int_t kind, const float *data, fiff_int_t nel=1)
void write_int(fiff_int_t kind, const fiff_int_t *data, fiff_int_t nel=1)
void start_block(fiff_int_t kind)
#define FIFF_MNE_SOURCE_SPACE_NEAREST_DIST
Hemisphere provides geometry information.
#define FIFF_MNE_SOURCE_SPACE_USE_TRIANGLES
#define FIFF_MNE_COORD_FRAME
#define FIFF_MNE_SOURCE_SPACE_TYPE
#define FIFF_MNE_SOURCE_SPACE_NUSE_TRI
#define FIFF_MNE_SOURCE_SPACE_DIST
void write_float_matrix(fiff_int_t kind, const MatrixXf &mat)
Coordinate transformation description.
QMap< int, QVector< int > > neighbor_tri
void write_float_sparse_rcs(fiff_int_t kind, const SparseMatrix< float > &mat)
#define FIFF_MNE_SOURCE_SPACE_NEAREST
void writeToStream(FiffStream *p_pStream)
void end_block(fiff_int_t kind)
#define FIFF_MNE_SOURCE_SPACE_SELECTION
#define FIFF_MNE_SOURCE_SPACE_DIST_LIMIT
Matrix< float, 4, 4, DontAlign > trans