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 class FiffDigitizerData;
74}
75
76//=============================================================================================================
77// DEFINE NAMESPACE MNELIB
78//=============================================================================================================
79
80namespace MNELIB
81{
82
83//=============================================================================================================
84// MNELIB FORWARD DECLARATIONS
85//=============================================================================================================
86
87class MNESourceSpace;
88class MNESurface;
90class MNEProjData;
91class FilterThreadArg;
92
93//=============================================================================================================
102{
103public:
104 typedef QSharedPointer<MNESurfaceOrVolume> SPtr;
105 typedef QSharedPointer<const MNESurfaceOrVolume> ConstSPtr;
106
107 /*
108 * Eigen convenience types – row-major so that row(i).data() gives
109 * a contiguous 3-element pointer, matching the old float** / int** layout.
110 */
111 typedef Eigen::Matrix<float, Eigen::Dynamic, 3, Eigen::RowMajor> PointsT;
112 typedef Eigen::Matrix<float, Eigen::Dynamic, 3, Eigen::RowMajor> NormalsT;
113 typedef Eigen::Matrix<int, Eigen::Dynamic, 3, Eigen::RowMajor> TrianglesT;
114
115 //=========================================================================================================
120
121 //=========================================================================================================
125 virtual ~MNESurfaceOrVolume();
126
131
141 static double solid_angle (const Eigen::Vector3f& from, /* From this point... */
142 const MNELIB::MNETriangle& tri);
143
148 void add_uniform_curv();
149
157 void add_triangle_data();
158
159
167 static void compute_cm(const PointsT& rr, int np, float (&cm)[3]);
168
174 void compute_surface_cm();
175
183
193 int add_vertex_normals();
194
207 int add_geometry_info(bool do_normals, bool check_too_many_neighbors);
208
218 int add_geometry_info(bool do_normals);
219
229 int add_geometry_info2(bool do_normals);
230
231
238 Eigen::VectorXi nearestVertIdx() const;
239
246 Eigen::VectorXd nearestDistVec() const;
247
255 void setNearestData(const Eigen::VectorXi& nearestIdx, const Eigen::VectorXd& nearestDist);
256
257
258public:
259 int type;
260 QString subject;
261 int id;
263 /*
264 * These relate to the FreeSurfer way
265 */
266 std::optional<MNEVolGeom> vol_geom;
267 std::optional<MNEMghTagGroup> mgh_tags;
268 /*
269 * These are meaningful for both surfaces and volumes
270 */
271 int np;
274 float cm[3];
275
277 Eigen::Map<const Eigen::Vector3f> point(int k) const { return Eigen::Map<const Eigen::Vector3f>(rr.row(k).data()); }
279 Eigen::Map<Eigen::Vector3f> point(int k) { return Eigen::Map<Eigen::Vector3f>(rr.row(k).data()); }
281 Eigen::Map<const Eigen::Vector3f> normal(int k) const { return Eigen::Map<const Eigen::Vector3f>(nn.row(k).data()); }
282
283 Eigen::VectorXi inuse;
284 Eigen::VectorXi vertno;
285 int nuse;
286
287 std::vector<Eigen::VectorXi> neighbor_vert;
288 Eigen::VectorXi nneighbor_vert;
289 std::vector<Eigen::VectorXf> vert_dist;
290 /*
291 * These are for surfaces only
292 */
293 float sigma;
294
295 int ntri;
296 std::vector<MNETriangle> tris;
298 float tot_area;
299
301 std::vector<MNETriangle> use_tris;
303
304 std::vector<Eigen::VectorXi> neighbor_tri;
305 Eigen::VectorXi nneighbor_tri;
306
307 std::vector<MNENearest> nearest;
308 std::vector<std::optional<MNEPatchInfo>> patches;
309
312
313 Eigen::VectorXf curv;
314 Eigen::VectorXf val;
315 /*
316 * These are for volumes only
317 */
318 std::optional<FIFFLIB::FiffCoordTrans> voxel_surf_RAS_t;
319 int vol_dims[3];
320 float voxel_size[3];
321 std::optional<FIFFLIB::FiffSparseMatrix> interpolator;
322 QString MRI_volume;
323 std::optional<FIFFLIB::FiffCoordTrans> MRI_voxel_surf_RAS_t;
324 std::optional<FIFFLIB::FiffCoordTrans> MRI_surf_RAS_RAS_t;
326};
327
328//=============================================================================================================
329// INLINE DEFINITIONS
330//=============================================================================================================
331} // NAMESPACE MNELIB
332
333#endif // MNESURFACEORVOLUME_H
FreeSurfer volume geometry header carried by surface and tag streams.
Ordered group of MNELIB::MNEMghTag entries appended to an MGH/MGZ file.
MNELIB shared-library export/import macros and library build metadata.
#define MNESHARED_EXPORT
Definition mne_global.h:40
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.
Per-source-space-vertex nearest-cortex-vertex mapping.
FIFF sparse matrix: column / row-compressed sparse storage backed by Eigen::SparseMatrix.
4x4 affine FIFF coordinate transform (FIFF_COORD_TRANS) annotated with source/destination coordinate-...
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:66
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.