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 Label;
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::Label &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::Label> &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 //=========================================================================================================
248 MNESourceSpace& operator[] (qint32 idx);
249
250 //=========================================================================================================
258 const MNESourceSpace& operator[] (qint32 idx) const;
259
260 //=========================================================================================================
268 MNESourceSpace& operator[] (QString idt);
269
270 //=========================================================================================================
278 const MNESourceSpace& operator[] (QString idt) const;
279
280 //=========================================================================================================
288 MNEHemisphere* hemisphereAt(qint32 idx);
289
290 //=========================================================================================================
298 const MNEHemisphere* hemisphereAt(qint32 idx) const;
299
300 //=========================================================================================================
308 std::shared_ptr<MNESourceSpace>& at(qint32 idx);
309
310 //=========================================================================================================
318 const std::shared_ptr<MNESourceSpace>& at(qint32 idx) const;
319
327 friend bool operator== (const MNESourceSpaces &a, const MNESourceSpaces &b);
328
329private:
330
331 //=========================================================================================================
341 static bool complete_source_space_info(MNEHemisphere& p_Hemisphere);
342
343 //=========================================================================================================
355 static bool read_source_space(FIFFLIB::FiffStream::SPtr& p_pStream,
356 const FIFFLIB::FiffDirNode::SPtr& p_Tree,
357 MNEHemisphere& p_Hemisphere);
358
359private:
360 std::vector<std::shared_ptr<MNESourceSpace>> m_sourceSpaces;
361};
362
363//=============================================================================================================
364// INLINE DEFINITIONS
365//=============================================================================================================
366
367inline bool MNESourceSpaces::isEmpty() const
368{
369 return m_sourceSpaces.empty();
370}
371
372//=============================================================================================================
373
374inline qint32 MNESourceSpaces::size() const
375{
376 return static_cast<qint32>(m_sourceSpaces.size());
377}
378
379//=============================================================================================================
380
381inline bool operator== (const MNESourceSpaces &a, const MNESourceSpaces &b)
382{
383 if (a.size() != b.size())
384 return false;
385 for (qint32 i = 0; i < a.size(); ++i) {
386 // Compare as hemispheres if both elements are hemispheres
387 auto* ha = dynamic_cast<const MNEHemisphere*>(&a[i]);
388 auto* hb = dynamic_cast<const MNEHemisphere*>(&b[i]);
389 if (ha && hb) {
390 if (!(*ha == *hb))
391 return false;
392 } else {
393 // Fallback: compare base-class identity (pointer equality or basic fields)
394 // For now, require both to be hemispheres for equality
395 return false;
396 }
397 }
398 return true;
399}
400
401} // NAMESPACE
402
403#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.
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 label.h:81
Hemisphere provides geometry information.
This defines a source space.
QList< Eigen::VectorXi > label_src_vertno_sel(const FSLIB::Label &p_label, Eigen::VectorXi &src_sel) const
void writeToStream(FIFFLIB::FiffStream *p_pStream)
std::shared_ptr< const MNESourceSpaces > ConstSPtr
MNESourceSpaces pick_regions(const QList< FSLIB::Label > &p_qListLabels) const
bool transform_source_space_to(FIFFLIB::fiff_int_t dest, FIFFLIB::FiffCoordTrans &trans)
MNEHemisphere * hemisphereAt(qint32 idx)
std::shared_ptr< MNESourceSpaces > SPtr
static bool patch_info(MNEHemisphere &p_Hemisphere)
static qint32 find_source_space_hemi(MNESourceSpace &p_SourceSpace)
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