v2.0.0
Loading...
Searching...
No Matches
mne_surface_or_volume.h
Go to the documentation of this file.
1//=============================================================================================================
19
20#ifndef MNESURFACEORVOLUME_H
21#define MNESURFACEORVOLUME_H
22
23//=============================================================================================================
24// INCLUDES
25//=============================================================================================================
26
27#include "mne_global.h"
28#include <mne/mne_types.h>
29#include "mne_vol_geom.h"
30#include "mne_mgh_tag_group.h"
31#include "mne_triangle.h"
32#include "mne_nearest.h"
33#include "mne_patch_info.h"
36
37//=============================================================================================================
38// EIGEN INCLUDES
39//=============================================================================================================
40
41#include <Eigen/Core>
42
43//=============================================================================================================
44// QT INCLUDES
45//=============================================================================================================
46
47#include <QSharedPointer>
48
49#include <memory>
50#include <optional>
51#include <vector>
52
53#include <QStringList>
54#include <QDebug>
55
56
57#define FIFF_MNE_SOURCE_SPACE_NNEIGHBORS 3594 /* Number of neighbors for each source space point (used for volume source spaces) */
58#define FIFF_MNE_SOURCE_SPACE_NEIGHBORS 3595 /* Neighbors for each source space point (used for volume source spaces) */
59
60#define FIFFV_MNE_COORD_SURFACE_RAS FIFFV_COORD_MRI /* The surface RAS coordinates */
61
62#define TRIANGLE_FILE_MAGIC_NUMBER (0xfffffe)
63#define NEW_QUAD_FILE_MAGIC_NUMBER (0xfffffd)
64#define QUAD_FILE_MAGIC_NUMBER (0xffffff)
65
66#define TAG_OLD_SURF_GEOM 20
67
68//=============================================================================================================
69// FORWARD DECLARATIONS
70//=============================================================================================================
71
72namespace FIFFLIB
73{
74class FiffDigitizerData;
75class FiffStream;
76}
77
78//=============================================================================================================
79// DEFINE NAMESPACE MNELIB
80//=============================================================================================================
81
82namespace MNELIB
83{
84
85//=============================================================================================================
86// MNELIB FORWARD DECLARATIONS
87//=============================================================================================================
88
89class MNESourceSpace;
90class MNESurface;
92class MNEProjData;
93class FilterThreadArg;
94
95//=============================================================================================================
104{
105public:
106 typedef QSharedPointer<MNESurfaceOrVolume> SPtr;
107 typedef QSharedPointer<const MNESurfaceOrVolume> ConstSPtr;
108
109 /*
110 * Eigen convenience types – row-major so that row(i).data() gives
111 * a contiguous 3-element pointer, matching the old float** / int** layout.
112 */
113 typedef Eigen::Matrix<float, Eigen::Dynamic, 3, Eigen::RowMajor> PointsT;
114 typedef Eigen::Matrix<float, Eigen::Dynamic, 3, Eigen::RowMajor> NormalsT;
115 typedef Eigen::Matrix<int, Eigen::Dynamic, 3, Eigen::RowMajor> TrianglesT;
116
117 //=========================================================================================================
122
123 //=========================================================================================================
127 virtual ~MNESurfaceOrVolume();
128
133
143 static double solid_angle(const Eigen::Vector3f& from, /* From this point... */
144 const MNELIB::MNETriangle& tri);
145
150 void add_uniform_curv();
151
157 void add_triangle_data();
158
159
167 static void compute_cm(const PointsT& rr, int np, float (&cm)[3]);
168
172 void compute_surface_cm();
173
179
187 int add_vertex_normals();
188
200 int add_geometry_info(bool do_normals, bool check_too_many_neighbors);
201
210 int add_geometry_info(bool do_normals);
211
220 int add_geometry_info2(bool do_normals);
221
222
229 Eigen::VectorXi nearestVertIdx() const;
230
237 Eigen::VectorXd nearestDistVec() const;
238
246 void setNearestData(const Eigen::VectorXi& nearestIdx, const Eigen::VectorXd& nearestDist);
247
248
249public:
250 int type;
251 QString subject;
252 int id;
254 /*
255 * These relate to the FreeSurfer way
256 */
257 std::optional<MNEVolGeom> vol_geom;
258 std::optional<MNEMghTagGroup> mgh_tags;
259 /*
260 * These are meaningful for both surfaces and volumes
261 */
262 int np;
265 float cm[3];
266
273 Eigen::Map<const Eigen::Vector3f> point(int k) const
274 {
275 return Eigen::Map<const Eigen::Vector3f>(rr.row(k).data());
276 }
277
283 Eigen::Map<Eigen::Vector3f> point(int k)
284 {
285 return Eigen::Map<Eigen::Vector3f>(rr.row(k).data());
286 }
287
293 Eigen::Map<const Eigen::Vector3f> normal(int k) const
294 {
295 return Eigen::Map<const Eigen::Vector3f>(nn.row(k).data());
296 }
297
298 Eigen::VectorXi inuse;
299 Eigen::VectorXi vertno;
300 int nuse;
301
302 std::vector<Eigen::VectorXi> neighbor_vert;
303 Eigen::VectorXi nneighbor_vert;
304 std::vector<Eigen::VectorXf> vert_dist;
305 /*
306 * These are for surfaces only
307 */
308 float sigma;
309
310 int ntri;
311 std::vector<MNETriangle> tris;
313 float tot_area;
314
316 std::vector<MNETriangle> use_tris;
318
319 std::vector<Eigen::VectorXi> neighbor_tri;
320 Eigen::VectorXi nneighbor_tri;
321
322 std::vector<MNENearest> nearest;
323 std::vector<std::optional<MNEPatchInfo>> patches;
324
327
328 Eigen::VectorXf curv;
329 Eigen::VectorXf val;
330 /*
331 * These are for volumes only
332 */
333 std::optional<FIFFLIB::FiffCoordTrans> voxel_surf_RAS_t;
334 int vol_dims[3];
335 float voxel_size[3];
336 std::optional<FIFFLIB::FiffSparseMatrix> interpolator;
337 QString MRI_volume;
338 std::optional<FIFFLIB::FiffCoordTrans> MRI_voxel_surf_RAS_t;
339 std::optional<FIFFLIB::FiffCoordTrans> MRI_surf_RAS_RAS_t;
341};
342
343//=============================================================================================================
344// INLINE DEFINITIONS
345//=============================================================================================================
346} // NAMESPACE MNELIB
347
348#endif // MNESURFACEORVOLUME_H
4x4 affine FIFF coordinate transform (FIFF_COORD_TRANS) annotated with source/destination coordinate-...
FIFF sparse matrix: column / row-compressed sparse storage backed by Eigen::SparseMatrix.
Legacy MNE-C constants and shared typedefs used across MNELIB structures.
Patch information (cluster of cortex vertices around each decimated source) used by orientation prior...
Triangle descriptor with cached centroid, area and normal vectors.
MNELIB shared-library export/import macros and library build metadata.
#define MNESHARED_EXPORT
Definition mne_global.h:40
FreeSurfer volume geometry header carried by surface and tag streams.
Per-source-space-vertex nearest-cortex-vertex mapping.
Ordered group of MNELIB::MNEMghTag entries appended to an MGH/MGZ file.
Core MNE data structures (source spaces, source estimates, hemispheres).
FIFF file I/O, in-memory data structures and high-level readers/writers.
Sparse FIFF matrix: CCS or RCS storage with the value / index / pointer triple as written by FiffStre...
Thread-local arguments for parallel raw data filtering (channel range, filter kernel,...
The MNE Msh Display FsSurface class holds information about a surface to be rendered.
Auxiliary projection data computed from MNEProjOp for efficient repeated application.
This defines a source space.
Lightweight triangulated surface (vertices, triangles, normals).
Definition mne_surface.h:68
std::vector< Eigen::VectorXi > neighbor_tri
MNESurfaceOrVolume(MNESurfaceOrVolume &&)=default
void setNearestData(const Eigen::VectorXi &nearestIdx, const Eigen::VectorXd &nearestDist)
std::vector< Eigen::VectorXi > neighbor_vert
MNESurfaceOrVolume()
Constructs the MNE FsSurface or Volume.
std::optional< FIFFLIB::FiffCoordTrans > MRI_surf_RAS_RAS_t
Eigen::Map< const Eigen::Vector3f > normal(int k) const
QSharedPointer< const MNESurfaceOrVolume > ConstSPtr
Eigen::VectorXd nearestDistVec() const
int add_geometry_info(bool do_normals, bool check_too_many_neighbors)
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::Map< const Eigen::Vector3f > point(int k) const
int add_geometry_info2(bool do_normals)
Eigen::VectorXi nearestVertIdx() const
Eigen::Map< Eigen::Vector3f > point(int k)
std::vector< MNETriangle > use_tris
Per-triangle geometric data for a cortical or BEM surface.