v2.0.0
Loading...
Searching...
No Matches
mne_source_spaces.h
Go to the documentation of this file.
1//=============================================================================================================
36
37#ifndef MNE_SOURCE_SPACES_H
38#define MNE_SOURCE_SPACES_H
39
40//=============================================================================================================
41// INCLUDES
42//=============================================================================================================
43
44#include "mne_global.h"
45#include "mne_hemisphere.h"
46
47#include <fiff/fiff_types.h>
48#include <fiff/fiff_dir_node.h>
49#include <fiff/fiff.h>
50
51#include <algorithm>
52#include <vector>
53#include <memory>
54
55//=============================================================================================================
56// EIGEN INCLUDES
57//=============================================================================================================
58
59#include <Eigen/Core>
60
61//=============================================================================================================
62// QT INCLUDES
63//=============================================================================================================
64
65#include <QList>
66
67//=============================================================================================================
68// FORWARD DECLARATIONS
69//=============================================================================================================
70
71namespace FSLIB
72{
73 class FsLabel;
74}
75
76//=============================================================================================================
77// DEFINE NAMESPACE MNELIB
78//=============================================================================================================
79
80namespace MNELIB
81{
82
83//=============================================================================================================
84// MNELIB FORWARD DECLARATIONS
85//=============================================================================================================
86
87//=============================================================================================================
94{
95public:
96 using SPtr = std::shared_ptr<MNESourceSpaces>;
97 using ConstSPtr = std::shared_ptr<const MNESourceSpaces>;
98
99 //=========================================================================================================
104
105 //=========================================================================================================
111 MNESourceSpaces(const MNESourceSpaces &p_MNESourceSpaces);
112
113 //=========================================================================================================
118
119 //=========================================================================================================
123 void clear();
124
125 //=========================================================================================================
131 inline bool isEmpty() const;
132
133 //=========================================================================================================
143 static qint32 find_source_space_hemi(MNESourceSpace& p_SourceSpace);
144
145 //=========================================================================================================
151 QList<Eigen::VectorXi> get_vertno() const;
152
153 //=========================================================================================================
163 QList<Eigen::VectorXi> label_src_vertno_sel(const FSLIB::FsLabel &p_label, Eigen::VectorXi &src_sel) const;
164
165 //=========================================================================================================
176 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.
177
178 //=========================================================================================================
186 MNESourceSpaces pick_regions(const QList<FSLIB::FsLabel> &p_qListLabels) const;
187
188 //=========================================================================================================
200 static bool readFromStream(FIFFLIB::FiffStream::SPtr& p_pStream,
201 bool add_geom,
202 MNESourceSpaces& p_SourceSpace);
203
204 //=========================================================================================================
210 inline qint32 size() const;
211
212 //=========================================================================================================
229
230 //=========================================================================================================
238 void writeToStream(FIFFLIB::FiffStream* p_pStream);
239
240 //=========================================================================================================
246 void append(const MNESourceSpace& space);
247
248 //=========================================================================================================
256 MNESourceSpace& operator[] (qint32 idx);
257
258 //=========================================================================================================
266 const MNESourceSpace& operator[] (qint32 idx) const;
267
268 //=========================================================================================================
276 MNESourceSpace& operator[] (QString idt);
277
278 //=========================================================================================================
286 const MNESourceSpace& operator[] (QString idt) const;
287
288 //=========================================================================================================
296 MNEHemisphere* hemisphereAt(qint32 idx);
297
298 //=========================================================================================================
306 const MNEHemisphere* hemisphereAt(qint32 idx) const;
307
308 //=========================================================================================================
316 std::shared_ptr<MNESourceSpace>& at(qint32 idx);
317
318 //=========================================================================================================
326 const std::shared_ptr<MNESourceSpace>& at(qint32 idx) const;
327
335 friend bool operator== (const MNESourceSpaces &a, const MNESourceSpaces &b);
336
337private:
338
339 //=========================================================================================================
349 static bool complete_source_space_info(MNEHemisphere& p_Hemisphere);
350
351 //=========================================================================================================
363 static bool read_source_space(FIFFLIB::FiffStream::SPtr& p_pStream,
364 const FIFFLIB::FiffDirNode::SPtr& p_Tree,
365 MNEHemisphere& p_Hemisphere);
366
367private:
368 std::vector<std::shared_ptr<MNESourceSpace>> m_sourceSpaces;
369};
370
371//=============================================================================================================
372// INLINE DEFINITIONS
373//=============================================================================================================
374
375inline bool MNESourceSpaces::isEmpty() const
376{
377 return m_sourceSpaces.empty();
378}
379
380//=============================================================================================================
381
382inline qint32 MNESourceSpaces::size() const
383{
384 return static_cast<qint32>(m_sourceSpaces.size());
385}
386
387//=============================================================================================================
388
389inline bool operator== (const MNESourceSpaces &a, const MNESourceSpaces &b)
390{
391 if (a.size() != b.size())
392 return false;
393 for (qint32 i = 0; i < a.size(); ++i) {
394 // Compare as hemispheres if both elements are hemispheres
395 auto* ha = dynamic_cast<const MNEHemisphere*>(&a[i]);
396 auto* hb = dynamic_cast<const MNEHemisphere*>(&b[i]);
397 if (ha && hb) {
398 if (!(*ha == *hb))
399 return false;
400 } else {
401 // Fallback: compare base-class identity (pointer equality or basic fields)
402 // For now, require both to be hemispheres for equality
403 return false;
404 }
405 }
406 return true;
407}
408
409} // NAMESPACE
410
411#endif // MNE_SOURCE_SPACES_H
FIFF class declaration, which provides static wrapper functions to stay consistent with mne matlab to...
FiffDirNode class declaration, which provides fiff dir tree processing methods.
Old fiff_type declarations - replace them.
bool operator==(const BIDSPath &a, const BIDSPath &b)
mne library export/import macros.
#define MNESHARED_EXPORT
Definition mne_global.h:52
MNEHemisphere class declaration.
Core MNE data structures (source spaces, source estimates, hemispheres).
bool operator==(const MNEClusterInfo &a, const MNEClusterInfo &b)
FreeSurfer surface and annotation I/O.
qint32 fiff_int_t
Definition fiff_types.h:89
Coordinate transformation description.
QSharedPointer< FiffDirNode > SPtr
FIFF File I/O routines.
QSharedPointer< FiffStream > SPtr
Freesurfer/MNE label.
Definition fs_label.h:81
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