v2.0.0
Loading...
Searching...
No Matches
mne_source_spaces.h
Go to the documentation of this file.
1//=============================================================================================================
21
22#ifndef MNE_SOURCE_SPACES_H
23#define MNE_SOURCE_SPACES_H
24
25//=============================================================================================================
26// INCLUDES
27//=============================================================================================================
28
29#include "mne_global.h"
30#include "mne_hemisphere.h"
31
32#include <fiff/fiff_types.h>
33#include <fiff/fiff_dir_node.h>
34#include <fiff/fiff.h>
35
36#include <algorithm>
37#include <vector>
38#include <memory>
39
40//=============================================================================================================
41// EIGEN INCLUDES
42//=============================================================================================================
43
44#include <Eigen/Core>
45
46//=============================================================================================================
47// QT INCLUDES
48//=============================================================================================================
49
50#include <QList>
51
52//=============================================================================================================
53// FORWARD DECLARATIONS
54//=============================================================================================================
55
56namespace FSLIB
57{
58 class FsLabel;
59}
60
61//=============================================================================================================
62// DEFINE NAMESPACE MNELIB
63//=============================================================================================================
64
65namespace MNELIB
66{
67
68//=============================================================================================================
69// MNELIB FORWARD DECLARATIONS
70//=============================================================================================================
71
72//=============================================================================================================
81{
82public:
83 using SPtr = std::shared_ptr<MNESourceSpaces>;
84 using ConstSPtr = std::shared_ptr<const MNESourceSpaces>;
85
86 //=========================================================================================================
91
92 //=========================================================================================================
98 MNESourceSpaces(const MNESourceSpaces &p_MNESourceSpaces);
99
100 //=========================================================================================================
105
106 //=========================================================================================================
110 void clear();
111
112 //=========================================================================================================
118 inline bool isEmpty() const;
119
120 //=========================================================================================================
130 static qint32 find_source_space_hemi(MNESourceSpace& p_SourceSpace);
131
132 //=========================================================================================================
138 QList<Eigen::VectorXi> get_vertno() const;
139
140 //=========================================================================================================
150 QList<Eigen::VectorXi> label_src_vertno_sel(const FSLIB::FsLabel &p_label, Eigen::VectorXi &src_sel) const;
151
152 //=========================================================================================================
163 static bool patch_info(MNEHemisphere &p_Hemisphere);//VectorXi& nearest, QList<VectorXi>& pinfo);@param[in] nearest The nearest vector of the source space.@param[in, out] pinfo The requested patch information.
164
165 //=========================================================================================================
173 MNESourceSpaces pick_regions(const QList<FSLIB::FsLabel> &p_qListLabels) const;
174
175 //=========================================================================================================
187 static bool readFromStream(FIFFLIB::FiffStream::SPtr& p_pStream,
188 bool add_geom,
189 MNESourceSpaces& p_SourceSpace);
190
191 //=========================================================================================================
197 inline qint32 size() const;
198
199 //=========================================================================================================
214 bool transform_source_space_to(FIFFLIB::fiff_int_t dest,
216
217 //=========================================================================================================
225 void writeToStream(FIFFLIB::FiffStream* p_pStream);
226
227 //=========================================================================================================
233 void append(const MNESourceSpace& space);
234
235 //=========================================================================================================
243 MNESourceSpace& operator[] (qint32 idx);
244
245 //=========================================================================================================
253 const MNESourceSpace& operator[] (qint32 idx) const;
254
255 //=========================================================================================================
263 MNESourceSpace& operator[] (QString idt);
264
265 //=========================================================================================================
273 const MNESourceSpace& operator[] (QString idt) const;
274
275 //=========================================================================================================
283 MNEHemisphere* hemisphereAt(qint32 idx);
284
285 //=========================================================================================================
293 const MNEHemisphere* hemisphereAt(qint32 idx) const;
294
295 //=========================================================================================================
303 std::shared_ptr<MNESourceSpace>& at(qint32 idx);
304
305 //=========================================================================================================
313 const std::shared_ptr<MNESourceSpace>& at(qint32 idx) const;
314
322 friend bool operator== (const MNESourceSpaces &a, const MNESourceSpaces &b);
323
324private:
325
326 //=========================================================================================================
336 static bool complete_source_space_info(MNEHemisphere& p_Hemisphere);
337
338 //=========================================================================================================
350 static bool read_source_space(FIFFLIB::FiffStream::SPtr& p_pStream,
351 const FIFFLIB::FiffDirNode::SPtr& p_Tree,
352 MNEHemisphere& p_Hemisphere);
353
354private:
355 std::vector<std::shared_ptr<MNESourceSpace>> m_sourceSpaces;
356};
357
358//=============================================================================================================
359// INLINE DEFINITIONS
360//=============================================================================================================
361
362inline bool MNESourceSpaces::isEmpty() const
363{
364 return m_sourceSpaces.empty();
365}
366
367//=============================================================================================================
368
369inline qint32 MNESourceSpaces::size() const
370{
371 return static_cast<qint32>(m_sourceSpaces.size());
372}
373
374//=============================================================================================================
375
376inline bool operator== (const MNESourceSpaces &a, const MNESourceSpaces &b)
377{
378 if (a.size() != b.size())
379 return false;
380 for (qint32 i = 0; i < a.size(); ++i) {
381 // Compare as hemispheres if both elements are hemispheres
382 auto* ha = dynamic_cast<const MNEHemisphere*>(&a[i]);
383 auto* hb = dynamic_cast<const MNEHemisphere*>(&b[i]);
384 if (ha && hb) {
385 if (!(*ha == *hb))
386 return false;
387 } else {
388 // Fallback: compare base-class identity (pointer equality or basic fields)
389 // For now, require both to be hemispheres for equality
390 return false;
391 }
392 }
393 return true;
394}
395
396} // NAMESPACE
397
398#endif // MNE_SOURCE_SPACES_H
bool operator==(const BIDSPath &a, const BIDSPath &b)
MNELIB shared-library export/import macros and library build metadata.
#define MNESHARED_EXPORT
Definition mne_global.h:40
Per-hemisphere cortical surface bundle with decimation, patch info and rendering buffers.
Recursive node of the parsed FIFF block tree (FIFFB_* hierarchy with directory entries and children).
Static MATLAB-style FIFF facade: thin wrapper functions kept for parity with the historical mne-matla...
Primitive scalar typedefs and forward-compatible aliases backing the FIFF type system.
Core MNE data structures (source spaces, source estimates, hemispheres).
bool operator==(const MNEClusterInfo &a, const MNEClusterInfo &b)
FreeSurfer surface, annotation and parcellation I/O for mne-cpp.
Labelled 4x4 FIFF affine: source frame, destination frame, rotation, translation and cached inverse.
QSharedPointer< FiffDirNode > SPtr
FIFF tag-stream reader/writer: wraps a QIODevice and exposes typed read_* / write_* methods for every...
QSharedPointer< FiffStream > SPtr
A FreeSurfer/MNE surface label: per-vertex indices, Tk-RAS positions and scalar values for one hemisp...
Definition fs_label.h:79
Hemisphere provides geometry information.
This defines a source space.
void writeToStream(FIFFLIB::FiffStream *p_pStream)
MNESourceSpaces pick_regions(const QList< FSLIB::FsLabel > &p_qListLabels) const
std::shared_ptr< const MNESourceSpaces > ConstSPtr
bool transform_source_space_to(FIFFLIB::fiff_int_t dest, FIFFLIB::FiffCoordTrans &trans)
MNEHemisphere * hemisphereAt(qint32 idx)
std::shared_ptr< MNESourceSpaces > SPtr
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
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