v2.0.0
Loading...
Searching...
No Matches
mne_surface_or_volume.h
Go to the documentation of this file.
1//=============================================================================================================
36
37#ifndef MNESURFACEORVOLUME_H
38#define MNESURFACEORVOLUME_H
39
40//=============================================================================================================
41// INCLUDES
42//=============================================================================================================
43
44#include "mne_global.h"
45#include <mne/mne_types.h>
46#include "mne_vol_geom.h"
47#include "mne_mgh_tag_group.h"
48#include "mne_triangle.h"
49#include "mne_nearest.h"
50#include "mne_patch_info.h"
53
54//=============================================================================================================
55// EIGEN INCLUDES
56//=============================================================================================================
57
58#include <Eigen/Core>
59
60//=============================================================================================================
61// QT INCLUDES
62//=============================================================================================================
63
64#include <QSharedPointer>
65
66#include <memory>
67#include <optional>
68#include <vector>
69
70#include <QStringList>
71#include <QDebug>
72
73
74#define FIFF_MNE_SOURCE_SPACE_NNEIGHBORS 3594 /* Number of neighbors for each source space point (used for volume source spaces) */
75#define FIFF_MNE_SOURCE_SPACE_NEIGHBORS 3595 /* Neighbors for each source space point (used for volume source spaces) */
76
77#define FIFFV_MNE_COORD_SURFACE_RAS FIFFV_COORD_MRI /* The surface RAS coordinates */
78
79#define TRIANGLE_FILE_MAGIC_NUMBER (0xfffffe)
80#define NEW_QUAD_FILE_MAGIC_NUMBER (0xfffffd)
81#define QUAD_FILE_MAGIC_NUMBER (0xffffff)
82
83#define TAG_OLD_SURF_GEOM 20
84
85//=============================================================================================================
86// FORWARD DECLARATIONS
87//=============================================================================================================
88
89namespace FIFFLIB {
90 class FiffDigitizerData;
91}
92
93//=============================================================================================================
94// DEFINE NAMESPACE MNELIB
95//=============================================================================================================
96
97namespace MNELIB
98{
99
100//=============================================================================================================
101// MNELIB FORWARD DECLARATIONS
102//=============================================================================================================
103
104class MNESourceSpace;
105class MNESurface;
107class MNEProjData;
108class FilterThreadArg;
109
110//=============================================================================================================
119{
120public:
121 typedef QSharedPointer<MNESurfaceOrVolume> SPtr;
122 typedef QSharedPointer<const MNESurfaceOrVolume> ConstSPtr;
123
124 /*
125 * Eigen convenience types – row-major so that row(i).data() gives
126 * a contiguous 3-element pointer, matching the old float** / int** layout.
127 */
128 typedef Eigen::Matrix<float, Eigen::Dynamic, 3, Eigen::RowMajor> PointsT;
129 typedef Eigen::Matrix<float, Eigen::Dynamic, 3, Eigen::RowMajor> NormalsT;
130 typedef Eigen::Matrix<int, Eigen::Dynamic, 3, Eigen::RowMajor> TrianglesT;
131
132 //=========================================================================================================
137
138 //=========================================================================================================
142 virtual ~MNESurfaceOrVolume();
143
148
158 static double solid_angle (const Eigen::Vector3f& from, /* From this point... */
159 const MNELIB::MNETriangle& tri);
160
165 void add_uniform_curv();
166
174 void add_triangle_data();
175
176
184 static void compute_cm(const PointsT& rr, int np, float (&cm)[3]);
185
191 void compute_surface_cm();
192
200
210 int add_vertex_normals();
211
224 int add_geometry_info(int do_normals, int check_too_many_neighbors);
225
235 int add_geometry_info(int do_normals);
236
246 int add_geometry_info2(int do_normals);
247
248
255 Eigen::VectorXi nearestVertIdx() const;
256
263 Eigen::VectorXd nearestDistVec() const;
264
272 void setNearestData(const Eigen::VectorXi& nearestIdx, const Eigen::VectorXd& nearestDist);
273
274
275public:
276 int type;
277 QString subject;
278 int id;
280 /*
281 * These relate to the FreeSurfer way
282 */
283 std::optional<MNEVolGeom> vol_geom;
284 std::optional<MNEMghTagGroup> mgh_tags;
285 /*
286 * These are meaningful for both surfaces and volumes
287 */
288 int np;
291 float cm[3];
292
293 Eigen::VectorXi inuse;
294 Eigen::VectorXi vertno;
295 int nuse;
296
297 std::vector<Eigen::VectorXi> neighbor_vert;
298 Eigen::VectorXi nneighbor_vert;
299 std::vector<Eigen::VectorXf> vert_dist;
300 /*
301 * These are for surfaces only
302 */
303 float sigma;
304
305 int ntri;
306 std::vector<MNETriangle> tris;
308 float tot_area;
309
311 std::vector<MNETriangle> use_tris;
313
314 std::vector<Eigen::VectorXi> neighbor_tri;
315 Eigen::VectorXi nneighbor_tri;
316
317 std::vector<MNENearest> nearest;
318 std::vector<std::optional<MNEPatchInfo>> patches;
319
322
323 Eigen::VectorXf curv;
324 Eigen::VectorXf val;
325 /*
326 * These are for volumes only
327 */
328 std::optional<FIFFLIB::FiffCoordTrans> voxel_surf_RAS_t;
329 int vol_dims[3];
330 float voxel_size[3];
331 std::optional<FIFFLIB::FiffSparseMatrix> interpolator;
332 QString MRI_volume;
333 std::optional<FIFFLIB::FiffCoordTrans> MRI_voxel_surf_RAS_t;
334 std::optional<FIFFLIB::FiffCoordTrans> MRI_surf_RAS_RAS_t;
336};
337
338//=============================================================================================================
339// INLINE DEFINITIONS
340//=============================================================================================================
341} // NAMESPACE MNELIB
342
343#endif // MNESURFACEORVOLUME_H
FiffSparseMatrix class declaration.
FiffCoordTrans class declaration.
mne library export/import macros.
#define MNESHARED_EXPORT
Definition mne_global.h:52
MNETriangle class declaration.
MNEMghTagGroup class declaration.
MNEVolGeom class declaration.
MNE Patch Information (MNEPatchInfo) class declaration.
Legacy MNE-C constants and common typedefs.
MNENearest class declaration.
Core MNE data structures (source spaces, source estimates, hemispheres).
FIFF file I/O and data structures (raw, epochs, evoked, covariance, forward).
FIFF sparse matrix storage.
Thread-local arguments for parallel raw data filtering (channel range, filter kernel,...
The MNE Msh Display Surface class holds information about a surface to be rendered.
Auxiliary projection data computed from MNEProjOp for efficient repeated application.
This defines a source space.
This defines a surface.
Definition mne_surface.h:79
std::vector< Eigen::VectorXi > neighbor_tri
MNESurfaceOrVolume(MNESurfaceOrVolume &&)=default
void setNearestData(const Eigen::VectorXi &nearestIdx, const Eigen::VectorXd &nearestDist)
int add_geometry_info(int do_normals, int check_too_many_neighbors)
std::vector< Eigen::VectorXi > neighbor_vert
MNESurfaceOrVolume()
Constructs the MNE Surface or Volume.
std::optional< FIFFLIB::FiffCoordTrans > MRI_surf_RAS_RAS_t
QSharedPointer< const MNESurfaceOrVolume > ConstSPtr
Eigen::VectorXd nearestDistVec() const
FIFFLIB::FiffSparseMatrix dist
std::vector< MNENearest > nearest
MNESurfaceOrVolume & operator=(MNESurfaceOrVolume &&)=default
QSharedPointer< MNESurfaceOrVolume > SPtr
static void compute_cm(const PointsT &rr, int np, float(&cm)[3])
Eigen::Matrix< float, Eigen::Dynamic, 3, Eigen::RowMajor > NormalsT
std::optional< FIFFLIB::FiffSparseMatrix > interpolator
static double solid_angle(const Eigen::Vector3f &from, const MNELIB::MNETriangle &tri)
Eigen::Matrix< int, Eigen::Dynamic, 3, Eigen::RowMajor > TrianglesT
MNESurfaceOrVolume(const MNESurfaceOrVolume &)=default
std::optional< MNEVolGeom > vol_geom
std::vector< std::optional< MNEPatchInfo > > patches
std::optional< FIFFLIB::FiffCoordTrans > MRI_voxel_surf_RAS_t
MNESurfaceOrVolume & operator=(const MNESurfaceOrVolume &)=default
std::vector< MNETriangle > tris
std::optional< MNEMghTagGroup > mgh_tags
std::optional< FIFFLIB::FiffCoordTrans > voxel_surf_RAS_t
std::vector< Eigen::VectorXf > vert_dist
Eigen::Matrix< float, Eigen::Dynamic, 3, Eigen::RowMajor > PointsT
Eigen::VectorXi nearestVertIdx() const
std::vector< MNETriangle > use_tris
Per-triangle geometric data for a cortical or BEM surface.