v2.0.0
Loading...
Searching...
No Matches
mne_source_spaces.cpp
Go to the documentation of this file.
1//=============================================================================================================
36
37//=============================================================================================================
38// INCLUDES
39//=============================================================================================================
40
41#include "mne_source_spaces.h"
42#include "mne_nearest.h"
43
44#include <math/linalg.h>
45#include <fs/fs_label.h>
46
47#include <iostream>
48
49//=============================================================================================================
50// QT INCLUDES
51//=============================================================================================================
52
53#include <QFile>
54
55//=============================================================================================================
56// USED NAMESPACES
57//=============================================================================================================
58
59using namespace UTILSLIB;
60using namespace FSLIB;
61using namespace MNELIB;
62using namespace Eigen;
63using namespace FIFFLIB;
64
65//=============================================================================================================
66// DEFINE MEMBER METHODS
67//=============================================================================================================
68
72
73//=============================================================================================================
74
76{
77 m_sourceSpaces.reserve(p_MNESourceSpaces.m_sourceSpaces.size());
78 for (const auto& sp : p_MNESourceSpaces.m_sourceSpaces)
79 m_sourceSpaces.push_back(sp->clone());
80}
81
82//=============================================================================================================
83
87
88//=============================================================================================================
89
91{
92 m_sourceSpaces.clear();
93}
94
95//=============================================================================================================
96
98{
99 m_sourceSpaces.push_back(space.clone());
100}
101
102//=============================================================================================================
103
104QList<VectorXi> MNESourceSpaces::get_vertno() const
105{
106 QList<VectorXi> p_vertices;
107 for(qint32 i = 0; i < static_cast<qint32>(m_sourceSpaces.size()); ++i)
108 p_vertices.push_back(m_sourceSpaces[i]->vertno);
109 return p_vertices;
110}
111
112//=============================================================================================================
113
114QList<VectorXi> MNESourceSpaces::label_src_vertno_sel(const FsLabel &p_label, VectorXi &src_sel) const
115{
116// if(src[0].['type'] != 'surf')
117// return Exception('FsLabel are only supported with surface source spaces')
118
119 QList<VectorXi> vertno;
120 vertno << this->m_sourceSpaces[0]->vertno << this->m_sourceSpaces[1]->vertno;
121
122 if (p_label.hemi == 0) //lh
123 {
124 VectorXi vertno_sel = Linalg::intersect(vertno[0], p_label.vertices, src_sel);
125 vertno[0] = vertno_sel;
126 vertno[1] = VectorXi();
127 }
128 else if (p_label.hemi == 1) //rh
129 {
130 VectorXi vertno_sel = Linalg::intersect(vertno[1], p_label.vertices, src_sel);
131 src_sel.array() += p_label.vertices.size();
132 vertno[0] = VectorXi();
133 vertno[1] = vertno_sel;
134 }
135
136// if (p_label.hemi == 0) //lh
137// {
138// VectorXi vertno_sel = Linalg::intersect(vertno[0], p_label.vertices[0], src_sel);
139// vertno[0] = vertno_sel;
140// vertno[1] = VectorXi();
141// }
142// else if (p_label.hemi == 1) //rh
143// {
144// VectorXi vertno_sel = Linalg::intersect(vertno[1], p_label.vertices[1], src_sel);
145// src_sel.array() += p_label.vertices[0].size();
146// vertno[0] = VectorXi();
147// vertno[1] = vertno_sel;
148// }
149// else if (p_label.hemi == 2) //both
150// {
151// VectorXi src_sel_lh, src_sel_rh;
152// VectorXi vertno_sel_lh = Linalg::intersect(vertno[0], p_label.vertices[0], src_sel_lh);
153// VectorXi vertno_sel_rh = Linalg::intersect(vertno[1], p_label.vertices[1], src_sel_rh);
154// src_sel.resize(src_sel_lh.size() + src_sel_rh.size());
155// src_sel.block(0,0,src_sel_lh.size(),1) = src_sel_lh;
156// src_sel.block(src_sel_lh.size(),0,src_sel_rh.size(),1) = src_sel_rh;
157// vertno[0] = vertno_sel_lh;
158// vertno[0] = vertno_sel_rh;
159// }
160 else
161 {
162 qWarning("Unknown hemisphere type\n");
163 vertno[0] = VectorXi::Zero(0);
164 vertno[1] = VectorXi::Zero(0);
165 }
166
167 return vertno;
168}
169
170//=============================================================================================================
171
172MNESourceSpaces MNESourceSpaces::pick_regions(const QList<FsLabel> &p_qListLabels) const
173{
174 Q_UNUSED(p_qListLabels);
175
176 MNESourceSpaces selectedSrc(*this);
177
178 for(qint32 h = 0; h < 2; ++h)
179 {
180 auto& srcSpace = *selectedSrc.m_sourceSpaces[h];
181 const auto& origSpace = *this->m_sourceSpaces[h];
182 auto* selHemi = dynamic_cast<MNEHemisphere*>(&srcSpace);
183 auto* origHemi = dynamic_cast<const MNEHemisphere*>(&origSpace);
184
185 VectorXi selVertices;
186
187 //get vertices indeces for new selection
188 qint32 iSize = 0;
189 for(qint32 i = 0; i < p_qListLabels.size(); ++i)
190 {
191 if(p_qListLabels[i].hemi == h)
192 {
193 VectorXi currentSelection;
194
195 Linalg::intersect(origSpace.vertno, p_qListLabels[i].vertices, currentSelection);
196
197 selVertices.conservativeResize(iSize+currentSelection.size());
198 selVertices.block(iSize,0,currentSelection.size(),1) = currentSelection;
199 iSize = selVertices.size();
200 }
201 }
202
203 Linalg::sort(selVertices, false);
204
205 VectorXi newVertno(selVertices.size());
206
207 srcSpace.inuse = VectorXi::Zero(srcSpace.np);
208
209 for(qint32 i = 0; i < selVertices.size(); ++i)
210 {
211 srcSpace.inuse[selVertices[i]] = 1;
212 newVertno[i] = origSpace.vertno[selVertices[i]];
213 }
214
215 srcSpace.nuse = selVertices.size();
216 srcSpace.vertno = newVertno;
217
218 //
219 // Tris
220 //
221 VectorXi idx_select = VectorXi::Zero(origSpace.use_itris.rows());
222 for(qint32 i = 0; i < 3; ++i)
223 {
224 VectorXi tri_dim = origSpace.use_itris.col(i);
225 VectorXi idx_dim;
226 Linalg::intersect(tri_dim, newVertno, idx_dim);
227
228 for(qint32 j = 0; j < idx_dim.size(); ++j)
229 idx_select[idx_dim[j]] = 1;
230 }
231
232 qint32 countSel = 0;
233 for(qint32 i = 0; i < idx_select.size(); ++i)
234 if(idx_select[i] == 1)
235 ++countSel;
236
237 srcSpace.nuse_tri = countSel;
238
239 MatrixX3i use_tris_new(countSel,3);
240 MatrixX3d use_tri_cent_new(countSel,3);
241 MatrixX3d use_tri_nn_new(countSel,3);
242 VectorXd use_tri_area_new(countSel);
243
244 countSel = 0;
245 for(qint32 i = 0; i < idx_select.size(); ++i)
246 {
247 if(idx_select[i] == 1)
248 {
249 use_tris_new.row(countSel) = origSpace.use_itris.row(i);
250 if (origHemi && selHemi) {
251 use_tri_cent_new.row(countSel) = origHemi->use_tri_cent.row(i);
252 use_tri_nn_new.row(countSel) = origHemi->use_tri_nn.row(i);
253 use_tri_area_new[countSel] = origHemi->use_tri_area[i];
254 }
255 ++countSel;
256 }
257 }
258
259 srcSpace.use_itris = use_tris_new;
260 if (selHemi) {
261 selHemi->use_tri_cent = use_tri_cent_new;
262 selHemi->use_tri_nn = use_tri_nn_new;
263 selHemi->use_tri_area = use_tri_area_new;
264 }
265 }
266
267 return selectedSrc;
268}
269
270//=============================================================================================================
271
273 bool add_geom,
274 MNESourceSpaces& p_SourceSpace)
275{
276// if (p_pSourceSpace != NULL)
277// delete p_pSourceSpace;
278 p_SourceSpace = MNESourceSpaces();
279
280 //
281 // Open the file, create directory
282 //
283 bool open_here = false;
284 QFile t_file;//ToDo TCPSocket;
285
286 if (!p_pStream->device()->isOpen())
287 {
288 QString t_sFileName = p_pStream->streamName();
289
290 t_file.setFileName(t_sFileName);
291 p_pStream = FiffStream::SPtr(new FiffStream(&t_file));
292 if(!p_pStream->open())
293 return false;
294 open_here = true;
295// if(t_pDir)
296// delete t_pDir;
297 }
298 //
299 // Find all source spaces
300 //
301 QList<FiffDirNode::SPtr> spaces = p_pStream->dirtree()->dir_tree_find(FIFFB_MNE_SOURCE_SPACE);
302 if (spaces.size() == 0)
303 {
304 if(open_here)
305 p_pStream->close();
306 std::cout << "No source spaces found";
307 return false;
308 }
309
310 for(int k = 0; k < spaces.size(); ++k)
311 {
312 auto p_Hemisphere = std::make_shared<MNEHemisphere>();
313 qInfo("\tReading a source space...");
314 MNESourceSpaces::read_source_space(p_pStream, spaces[k], *p_Hemisphere);
315 qInfo("\t[done]\n" );
316 if (add_geom)
317 p_Hemisphere->complete_source_space_info();
318
319 p_SourceSpace.m_sourceSpaces.push_back(p_Hemisphere);
320
321// src(k) = this;
322 }
323
324 qInfo("\t%lld source spaces read\n", spaces.size());
325
326 if(open_here)
327 p_pStream->close();
328
329 return true;
330}
331
332//=============================================================================================================
333
335{
336 return p_SourceSpace.find_source_space_hemi();
337}
338
339//=============================================================================================================
340
342{
343 for(size_t k = 0; k < this->m_sourceSpaces.size(); ++k)
344 {
345 auto* hemi = dynamic_cast<MNEHemisphere*>(m_sourceSpaces[k].get());
346 if(hemi) {
347 if(!hemi->transform_hemisphere_to(dest,trans))
348 {
349 qWarning("Could not transform source space.");
350 return false;
351 }
352 }
353 }
354 return true;
355}
356
357//=============================================================================================================
358
359bool MNESourceSpaces::read_source_space(FiffStream::SPtr& p_pStream, const FiffDirNode::SPtr& p_Tree, MNEHemisphere& p_Hemisphere)
360{
361 p_Hemisphere.clear();
362
363 FiffTag::UPtr t_pTag;
364
365 //=====================================================================
366 if(!p_Tree->find_tag(p_pStream, FIFF_MNE_SOURCE_SPACE_ID, t_pTag))
367 p_Hemisphere.id = FIFFV_MNE_SURF_UNKNOWN;
368 else
369 p_Hemisphere.id = *t_pTag->toInt();
370
371// qDebug() << "Read SourceSpace ID; type:" << t_pTag->getType() << "value:" << *t_pTag->toInt();
372
373 //=====================================================================
374 if(!p_Tree->find_tag(p_pStream, FIFF_MNE_SOURCE_SPACE_NPOINTS, t_pTag))
375 {
376 p_pStream->close();
377 std::cout << "error: Number of vertices not found."; //ToDo: throw error.
378 return false;
379 }
380// qDebug() << "Number of vertice; type:" << t_pTag->getType() << "value:" << *t_pTag->toInt();
381 p_Hemisphere.np = *t_pTag->toInt();
382
383 //=====================================================================
384 if(!p_Tree->find_tag(p_pStream, FIFF_BEM_SURF_NTRI, t_pTag))
385 {
386 if(!p_Tree->find_tag(p_pStream, FIFF_MNE_SOURCE_SPACE_NTRI, t_pTag))
387 p_Hemisphere.ntri = 0;
388 else
389 p_Hemisphere.ntri = *t_pTag->toInt();
390 }
391 else
392 {
393 p_Hemisphere.ntri = *t_pTag->toInt();
394 }
395// qDebug() << "Number of Tris; type:" << t_pTag->getType() << "value:" << *t_pTag->toInt();
396
397 //=====================================================================
398 if(!p_Tree->find_tag(p_pStream, FIFF_MNE_COORD_FRAME, t_pTag))
399 {
400 p_pStream->close();
401 std::cout << "Coordinate frame information not found."; //ToDo: throw error.
402 return false;
403 }
404 p_Hemisphere.coord_frame = *t_pTag->toInt();
405// qDebug() << "Coord Frame; type:" << t_pTag->getType() << "value:" << *t_pTag->toInt();
406
407 //=====================================================================
408 //
409 // Vertices, normals, and triangles
410 //
411 if(!p_Tree->find_tag(p_pStream, FIFF_MNE_SOURCE_SPACE_POINTS, t_pTag))
412 {
413 p_pStream->close();
414 std::cout << "Vertex data not found."; //ToDo: throw error.
415 return false;
416 }
417
418 p_Hemisphere.rr = t_pTag->toFloatMatrix().transpose();
419 qint32 rows_rr = p_Hemisphere.rr.rows();
420// qDebug() << "last element rr: " << p_Hemisphere.rr(rows_rr-1, 0) << p_Hemisphere.rr(rows_rr-1, 1) << p_Hemisphere.rr(rows_rr-1, 2);
421
422 if (rows_rr != p_Hemisphere.np)
423 {
424 p_pStream->close();
425 std::cout << "Vertex information is incorrect."; //ToDo: throw error.
426 return false;
427 }
428// qDebug() << "Source Space Points; type:" << t_pTag->getType();
429
430 //=====================================================================
431 if(!p_Tree->find_tag(p_pStream, FIFF_MNE_SOURCE_SPACE_NORMALS, t_pTag))
432 {
433 p_pStream->close();
434 std::cout << "Vertex normals not found."; //ToDo: throw error.
435 return false;
436 }
437
438 p_Hemisphere.nn = t_pTag->toFloatMatrix().transpose();
439 qint32 rows_nn = p_Hemisphere.nn.rows();
440
441 if (rows_nn != p_Hemisphere.np)
442 {
443 p_pStream->close();
444 std::cout << "Vertex normal information is incorrect."; //ToDo: throw error.
445 return false;
446 }
447// qDebug() << "Source Space Normals; type:" << t_pTag->getType();
448
449 //=====================================================================
450 if (p_Hemisphere.ntri > 0)
451 {
452 if(!p_Tree->find_tag(p_pStream, FIFF_BEM_SURF_TRIANGLES, t_pTag))
453 {
454 if(!p_Tree->find_tag(p_pStream, FIFF_MNE_SOURCE_SPACE_TRIANGLES, t_pTag))
455 {
456 p_pStream->close();
457 std::cout << "Triangulation not found."; //ToDo: throw error.
458 return false;
459 }
460 else
461 {
462 p_Hemisphere.itris = t_pTag->toIntMatrix().transpose();
463 p_Hemisphere.itris.array() -= 1;//0 based indizes
464 }
465 }
466 else
467 {
468 p_Hemisphere.itris = t_pTag->toIntMatrix().transpose();
469 p_Hemisphere.itris.array() -= 1;//0 based indizes
470 }
471 if (p_Hemisphere.itris.rows() != p_Hemisphere.ntri)
472 {
473 p_pStream->close();
474 std::cout << "Triangulation information is incorrect."; //ToDo: throw error.
475 return false;
476 }
477 }
478 else
479 {
480 MatrixXi p_defaultMatrix(0, 0);
481 p_Hemisphere.itris = p_defaultMatrix;
482 }
483// qDebug() << "Triangles; type:" << t_pTag->getType() << "rows:" << p_Hemisphere.itris.rows() << "cols:" << p_Hemisphere.itris.cols();
484
485 //
486 // Which vertices are active
487 //
488 if(!p_Tree->find_tag(p_pStream, FIFF_MNE_SOURCE_SPACE_NUSE, t_pTag))
489 {
490 p_Hemisphere.nuse = 0;
491 p_Hemisphere.inuse = VectorXi::Zero(p_Hemisphere.nuse);
492 VectorXi p_defaultVector;
493 p_Hemisphere.vertno = p_defaultVector;
494 }
495 else
496 {
497 p_Hemisphere.nuse = *t_pTag->toInt();
498 if(!p_Tree->find_tag(p_pStream, FIFF_MNE_SOURCE_SPACE_SELECTION, t_pTag))
499 {
500 p_pStream->close();
501 std::cout << "Source selection information missing."; //ToDo: throw error.
502 return false;
503 }
504 p_Hemisphere.inuse = VectorXi(Map<VectorXi>(t_pTag->toInt(), t_pTag->size()/4, 1));//use copy constructor, for the sake of easy memory management
505
506 p_Hemisphere.vertno = VectorXi::Zero(p_Hemisphere.nuse);
507 if (p_Hemisphere.inuse.rows() != p_Hemisphere.np)
508 {
509 p_pStream->close();
510 std::cout << "Incorrect number of entries in source space selection."; //ToDo: throw error.
511 return false;
512 }
513 int pp = 0;
514 for (int p = 0; p < p_Hemisphere.np; ++p)
515 {
516 if(p_Hemisphere.inuse(p) == 1)
517 {
518 p_Hemisphere.vertno(pp) = p;
519 ++pp;
520 }
521 }
522 }
523// qDebug() << "Vertices; type:" << t_pTag->getType() << "nuse:" << p_Hemisphere.nuse;
524
525 //
526 // Use triangulation
527 //
528 FiffTag::UPtr t_pTag1;
529 FiffTag::UPtr t_pTag2;
530 if(!p_Tree->find_tag(p_pStream, FIFF_MNE_SOURCE_SPACE_NUSE_TRI, t_pTag1) || !p_Tree->find_tag(p_pStream, FIFF_MNE_SOURCE_SPACE_USE_TRIANGLES, t_pTag2))
531 {
532 MatrixX3i p_defaultMatrix;
533 p_Hemisphere.nuse_tri = 0;
534 p_Hemisphere.use_itris = p_defaultMatrix;
535 }
536 else
537 {
538 p_Hemisphere.nuse_tri = *t_pTag1->toInt();
539 p_Hemisphere.use_itris = t_pTag2->toIntMatrix().transpose();
540 p_Hemisphere.use_itris.array() -= 1; //0 based indizes
541 }
542// qDebug() << "triangulation; type:" << t_pTag2->getType() << "use_itris:" << p_Hemisphere.use_itris.rows()<< "x" << p_Hemisphere.use_itris.cols();
543
544 //
545 // Patch-related information
546 //
547 if(!p_Tree->find_tag(p_pStream, FIFF_MNE_SOURCE_SPACE_NEAREST, t_pTag1) || !p_Tree->find_tag(p_pStream, FIFF_MNE_SOURCE_SPACE_NEAREST_DIST, t_pTag2))
548 {
549 p_Hemisphere.nearest.clear();
550 }
551 else
552 {
553 //res.nearest = tag1.data + 1;
554 VectorXi nearestIdx = VectorXi(Map<VectorXi>(t_pTag1->toInt(), t_pTag1->size()/4, 1));
555 VectorXd nearestDist = VectorXd((Map<VectorXf>(t_pTag2->toFloat(), t_pTag1->size()/4, 1)).cast<double>());
556 p_Hemisphere.setNearestData(nearestIdx, nearestDist);
557 }
558
559// patch_info(p_Hemisphere.nearest, p_Hemisphere.pinfo);
560 if (p_Hemisphere.compute_patch_info())
561 qInfo("\tPatch information added...");
562 //
563 // Distances
564 //
565 if(!p_Tree->find_tag(p_pStream, FIFF_MNE_SOURCE_SPACE_DIST, t_pTag1) || !p_Tree->find_tag(p_pStream, FIFF_MNE_SOURCE_SPACE_DIST_LIMIT, t_pTag2))
566 {
567 p_Hemisphere.dist = FiffSparseMatrix();
568 p_Hemisphere.dist_limit = 0;
569 }
570 else
571 {
572 auto dist_lower = FiffSparseMatrix::fiff_get_float_sparse_matrix(t_pTag1);
573 if (dist_lower) {
574 auto dist_full = dist_lower->mne_add_upper_triangle_rcs();
575 if (dist_full) {
576 p_Hemisphere.dist = std::move(*dist_full);
577 }
578 }
579 p_Hemisphere.dist_limit = *t_pTag2->toFloat(); //ToDo Check if this is realy always a float and not a matrix
580 }
581
582 return true;
583}
584
585//=============================================================================================================
586
588{
589 return p_Hemisphere.compute_patch_info();
590}
591
592//=============================================================================================================
593
594bool MNESourceSpaces::complete_source_space_info(MNEHemisphere& p_Hemisphere)
595{
596 return p_Hemisphere.complete_source_space_info();
597}
598
599//=============================================================================================================
600
602{
603 for(size_t h = 0; h < m_sourceSpaces.size(); ++h)
604 {
605 qInfo("\tWrite a source space... ");
607 auto* hemi = dynamic_cast<MNEHemisphere*>(m_sourceSpaces[h].get());
608 if (hemi)
609 hemi->writeToStream(p_pStream);
611 qInfo("[done]\n");
612 }
613 qInfo("\t%zu source spaces written\n", m_sourceSpaces.size());
614}
615
616//=============================================================================================================
617
619{
620 if(static_cast<qint32>(m_sourceSpaces.size()) > idx)
621 return *m_sourceSpaces[idx];
622 else
623 {
624 qWarning("Warning: Index out of bound! Returning last element.");
625 return *m_sourceSpaces.back();
626 }
627}
628
629//=============================================================================================================
630
632{
633 if(static_cast<qint32>(m_sourceSpaces.size()) > idx)
634 return *m_sourceSpaces[idx];
635 else
636 {
637 qWarning("Warning: Index out of bound! Returning last element.");
638 return *m_sourceSpaces.back();
639 }
640}
641
642//=============================================================================================================
643
645{
646 if(idt.compare("lh") == 0)
647 return *m_sourceSpaces[0];
648 else if(idt.compare("rh") == 0)
649 return *m_sourceSpaces[1];
650 else
651 {
652 qWarning("Warning: Identifier is not 'lh' or 'rh'! Returning 'lh'.");
653 return *m_sourceSpaces[0];
654 }
655}
656
657//=============================================================================================================
658
660{
661 if(idt.compare("lh") == 0)
662 return *m_sourceSpaces[0];
663 else if(idt.compare("rh") == 0)
664 return *m_sourceSpaces[1];
665 else
666 {
667 qWarning("Warning: Identifier is not 'lh' or 'rh'! Returning 'lh'.");
668 return *m_sourceSpaces[0];
669 }
670}
671
672//=============================================================================================================
673
675{
676 if(idx >= 0 && idx < static_cast<qint32>(m_sourceSpaces.size()))
677 return dynamic_cast<MNEHemisphere*>(m_sourceSpaces[idx].get());
678 return nullptr;
679}
680
681//=============================================================================================================
682
684{
685 if(idx >= 0 && idx < static_cast<qint32>(m_sourceSpaces.size()))
686 return dynamic_cast<const MNEHemisphere*>(m_sourceSpaces[idx].get());
687 return nullptr;
688}
689
690//=============================================================================================================
691
692std::shared_ptr<MNESourceSpace>& MNESourceSpaces::at(qint32 idx)
693{
694 return m_sourceSpaces.at(idx);
695}
696
697//=============================================================================================================
698
699const std::shared_ptr<MNESourceSpace>& MNESourceSpaces::at(qint32 idx) const
700{
701 return m_sourceSpaces.at(idx);
702}
#define FIFF_MNE_SOURCE_SPACE_ID
#define FIFF_MNE_SOURCE_SPACE_DIST_LIMIT
#define FIFF_MNE_COORD_FRAME
#define FIFFV_MNE_SURF_UNKNOWN
#define FIFF_MNE_SOURCE_SPACE_SELECTION
#define FIFF_MNE_SOURCE_SPACE_USE_TRIANGLES
#define FIFF_MNE_SOURCE_SPACE_NUSE_TRI
#define FIFF_MNE_SOURCE_SPACE_NORMALS
#define FIFF_MNE_SOURCE_SPACE_NEAREST_DIST
#define FIFF_MNE_SOURCE_SPACE_DIST
#define FIFF_MNE_SOURCE_SPACE_POINTS
#define FIFF_MNE_SOURCE_SPACE_NTRI
#define FIFFB_MNE_SOURCE_SPACE
#define FIFF_MNE_SOURCE_SPACE_NPOINTS
#define FIFF_MNE_SOURCE_SPACE_TRIANGLES
#define FIFF_MNE_SOURCE_SPACE_NUSE
#define FIFF_MNE_SOURCE_SPACE_NEAREST
#define FIFF_BEM_SURF_TRIANGLES
Definition fiff_file.h:736
#define FIFF_BEM_SURF_NTRI
Definition fiff_file.h:734
MNESourceSpaces class declaration.
MNENearest class declaration.
FsLabel class declaration.
Linalg class declaration.
Core MNE data structures (source spaces, source estimates, hemispheres).
FreeSurfer surface and annotation I/O.
FIFF file I/O and data structures (raw, epochs, evoked, covariance, forward).
qint32 fiff_int_t
Definition fiff_types.h:89
Shared utilities (I/O helpers, spectral analysis, layout management, warp algorithms).
Coordinate transformation description.
QSharedPointer< FiffDirNode > SPtr
static FiffSparseMatrix::UPtr fiff_get_float_sparse_matrix(const FIFFLIB::FiffTag::UPtr &tag)
FIFF File I/O routines.
fiff_long_t start_block(fiff_int_t kind)
QSharedPointer< FiffStream > SPtr
fiff_long_t end_block(fiff_int_t kind, fiff_int_t next=FIFFV_NEXT_SEQ)
std::unique_ptr< FiffTag > UPtr
Definition fiff_tag.h:158
Freesurfer/MNE label.
Definition fs_label.h:81
Eigen::VectorXi vertices
Definition fs_label.h:166
static Eigen::VectorXi sort(Eigen::Matrix< T, Eigen::Dynamic, 1 > &v, bool desc=true)
Definition linalg.h:284
static Eigen::VectorXi intersect(const Eigen::VectorXi &v1, const Eigen::VectorXi &v2, Eigen::VectorXi &idx_sel)
Definition linalg.cpp:170
Hemisphere provides geometry information.
void writeToStream(FIFFLIB::FiffStream *p_pStream)
This defines a source space.
virtual MNESourceSpace::SPtr clone() const
qint32 find_source_space_hemi() const
void writeToStream(FIFFLIB::FiffStream *p_pStream)
MNESourceSpaces pick_regions(const QList< FSLIB::FsLabel > &p_qListLabels) const
bool transform_source_space_to(FIFFLIB::fiff_int_t dest, FIFFLIB::FiffCoordTrans &trans)
MNEHemisphere * hemisphereAt(qint32 idx)
void append(const MNESourceSpace &space)
static bool patch_info(MNEHemisphere &p_Hemisphere)
static qint32 find_source_space_hemi(MNESourceSpace &p_SourceSpace)
QList< Eigen::VectorXi > label_src_vertno_sel(const FSLIB::FsLabel &p_label, Eigen::VectorXi &src_sel) const
MNESourceSpace & operator[](qint32 idx)
static bool readFromStream(FIFFLIB::FiffStream::SPtr &p_pStream, bool add_geom, MNESourceSpaces &p_SourceSpace)
std::shared_ptr< MNESourceSpace > & at(qint32 idx)
QList< Eigen::VectorXi > get_vertno() const
void setNearestData(const Eigen::VectorXi &nearestIdx, const Eigen::VectorXd &nearestDist)
FIFFLIB::FiffSparseMatrix dist
std::vector< MNENearest > nearest