MNE-CPP 0.1.9
A Framework for Electrophysiology
Loading...
Searching...
No Matches
mne_types_mne-c.h
1#ifndef _mne_types_h
2#define _mne_types_h
3/*
4 * Type definitions for the MNE library
5 *
6 * Copyright 2001 - 2009
7 *
8 * Matti Hamalainen
9 * Athinoula A. Martinos Center for Biomedical Imaging
10 * Massachusetts General Hospital
11 * Charlestown, MA, USA
12 *
13 * $Id: mne_types.h 3477 2016-01-14 12:48:00Z msh $
14 *
15 * Revision 1.76 2009/03/14 12:37:30 msh
16 * Quite a bit of work for C++ compatibility
17 *
18 * Revision 1.75 2009/02/28 17:53:50 msh
19 * Added extra fields to mneWdata and mneStcData with future extensions in mind
20 *
21 * Revision 1.74 2009/02/18 02:45:40 msh
22 * Moved to the mneEventList structure, which contains comments per event
23 *
24 * Revision 1.73 2009/02/05 04:54:14 msh
25 * Added first_sample_val member to mneRawData
26 *
27 * Revision 1.72 2009/01/30 15:20:29 msh
28 * Added code to mask the contents of the digital trigger channel if appropriate
29 *
30 * Revision 1.71 2009/01/19 13:08:05 msh
31 * Initialize the MRI structure more completely
32 *
33 * Revision 1.70 2008/11/16 20:19:59 msh
34 * Added Talairach transforms
35 * Fixed bugs in MRI reading
36 *
37 * Revision 1.69 2008/09/30 11:47:01 msh
38 * Added option to load unprocessed MaxShield data
39 *
40 * Revision 1.68 2008/08/15 12:56:49 msh
41 * Added option for discrete source spaces
42 *
43 * Revision 1.67 2008/06/16 16:07:09 msh
44 * Added compatibility for the old event file format
45 *
46 * Revision 1.66 2008/05/28 10:14:05 msh
47 * Added possibility for a sparse covariance matrix
48 *
49 * Revision 1.65 2008/05/26 10:50:10 msh
50 * Changes to accommodate the preweighted lead field basis
51 *
52 * Revision 1.64 2008/03/17 18:29:31 msh
53 * Possibility to define the trigger channel with an environment variable
54 * Added mne_compare_filters routine
55 *
56 * Revision 1.63 2008/03/15 12:54:46 msh
57 * Handle FIFF_MEAS_DATE appropriately
58 * Copy MNE_PROCESSING_HISTORY to output files as needed
59 * Possibility to add new epochs to raw data epochs previously loaded
60 *
61 * Revision 1.62 2008/03/09 01:19:35 msh
62 * Added mne_raw_formatted_time routine
63 * Include first sample to number of omitted samples
64 * Read the FIFF_MEAS_DATE tag
65 *
66 * Revision 1.61 2007/04/06 19:07:58 msh
67 * Implemented a new event structure in raw data which will eventually
68 * allow for multiple event lists and comments for the events
69 *
70 * Revision 1.60 2007/03/01 04:32:19 msh
71 * Reworked the MRI data structure to be more flexible
72 *
73 * Revision 1.59 2007/02/27 17:40:14 msh
74 * Fixed empty row or column handling in mne_create_sparse_rcs and mne_create_sparse_ccs
75 * Fixed memory leak in mne_inverse_io.c
76 * Added new fields to volume source spaces
77 *
78 * Revision 1.58 2007/02/26 05:01:29 msh
79 * Added the voxel-RAS coordinate transformation to mneMRIdata
80 * Added routine to set voxels at given RAS coordinate location to given value
81 *
82 * Revision 1.57 2007/02/25 14:29:44 msh
83 * Added routines to read mgh and mgz MRI data files.
84 *
85 * Revision 1.56 2007/02/23 14:24:47 msh
86 * Made more provisions for volume source spaces.
87 *
88 * Revision 1.55 2007/02/20 20:40:40 msh
89 * Match channel names without spaces as well for compatibility with
90 * the new Neuromag channel naming scheme.
91 *
92 * Revision 1.54 2007/01/29 21:02:44 msh
93 * Added the additional prior weightings to the inverse operator structure
94 *
95 * Revision 1.53 2007/01/09 12:43:08 msh
96 * Added total area member to the mneSourceSpace structure
97 * Compute the total area in mne_add_triangle_data
98 *
99 * Revision 1.52 2006/12/08 16:36:36 msh
100 * Added source file name to layout.
101 *
102 * Revision 1.51 2006/12/05 21:27:55 msh
103 * Added the SSS stuff to raw data and the covariance matrix
104 *
105 * Revision 1.50 2006/11/16 22:46:13 msh
106 * Changed sample number in mneTrigEvent to be a signed integer.
107 *
108 * Revision 1.49 2006/10/16 13:39:17 msh
109 * Changed field names in mneMeasDataSet structure
110 *
111 */
112#include <fiff/c/fiff_types.h>
113
114#if defined(__cplusplus)
115extern "C" {
116#endif
117
118/*
119 * Complex data
120 */
121typedef struct {
122 float re;
123 float im;
125
126typedef struct {
127 double re;
128 double im;
130
131typedef void (*mneUserFreeFunc)(void *); /* General purpose */
132typedef fiffSparseMatrix mneSparseMatrix;
133typedef fiffSparseMatrixRec mneSparseMatrixRec;
134
135typedef struct {
136 int vert; /* Which vertex does this apply to */
137 int *memb_vert; /* Which vertices constitute the patch? */
138 int nmemb; /* How many? */
139 float area; /* Area of the patch */
140 float ave_nn[3]; /* Average normal */
141 float dev_nn; /* Average deviation of the patch normals from the average normal */
143
144typedef struct { /* This is used in the patch definitions */
145 int vert; /* Number of this vertex (to enable sorting) */
146 int nearest; /* Nearest 'inuse' vertex */
147 float dist; /* Distance to the nearest 'inuse' vertex */
148 mnePatchInfo patch; /* The patch information record for the patch this vertex belongs to */
150
151typedef struct {
152 int *vert; /* Triangle vertices (pointers to the itris member of the associated mneSurface) */
153 float *r1,*r2,*r3; /* Triangle vertex locations (pointers to the rr member of the associated mneSurface) */
154 float r12[3],r13[3]; /* Vectors along the sides */
155 float nn[3]; /* Normal vector */
156 float area; /* Area */
157 float cent[3]; /* Centroid */
158 float ex[3],ey[3]; /* Other unit vectors (used by BEM calculations) */
159} *mneTriangle,mneTriangleRec; /* Triangle data */
160
161typedef struct {
162 int valid; /* Is the information below valid */
163 int width,height,depth; /* Size of the stack */
164 float xsize,ysize,zsize; /* Increments in the three voxel directions */
165 float x_ras[3],y_ras[3],z_ras[3]; /* Directions of the coordinate axes */
166 float c_ras[3]; /* Center of the RAS coordinates */
167 char *filename; /* Name of the MRI data file */
168} *mneVolGeom,mneVolGeomRec; /* MRI data volume geometry information like FreeSurfer keeps it */
169
170/*
171 * Values of the type field in the mneVolumeOrSurface structure
172 */
173#define MNE_SOURCE_SPACE_UNKNOWN -1
174#define MNE_SOURCE_SPACE_SURFACE 1 /* Surface-based source space */
175#define MNE_SOURCE_SPACE_VOLUME 2 /* 3D volume source space */
176#define MNE_SOURCE_SPACE_DISCRETE 3 /* Discrete points */
177
178typedef struct { /* This defines a source space or a surface */
179 int type; /* Is this a volume or a surface */
180 char *subject; /* Name (id) of the subject */
181 int id; /* Surface id */
182 int coord_frame; /* Which coordinate system are the data in now */
183 /*
184 * These relate to the FreeSurfer way
185 */
186 mneVolGeom vol_geom; /* MRI volume geometry information as FreeSurfer likes it */
187 void *mgh_tags; /* Tags listed in the file */
188 /*
189 * These are meaningful for both surfaces and volumes
190 */
191 int np; /* Number of vertices */
192 float **rr; /* The vertex locations */
193 float **nn; /* Surface normals at these points */
194 float cm[3]; /* Center of mass */
195
196 int *inuse; /* Is this point in use in the source space */
197 int *vertno; /* Vertex numbers of the used vertices in the full source space */
198 int nuse; /* Number of points in use */
199
200 int **neighbor_vert; /* Vertices neighboring each vertex */
201 int *nneighbor_vert; /* Number of vertices neighboring each vertex */
202 float **vert_dist; /* Distances between neigboring vertices */
203 /*
204 * These are for surfaces only
205 */
206 int ntri; /* Number of triangles */
207 mneTriangle tris; /* The triangulation information */
208 int **itris; /* The vertex numbers */
209 float tot_area; /* Total area of the surface, computed from the triangles */
210
211 int nuse_tri; /* The triangulation corresponding to the vertices in use */
212 mneTriangle use_tris; /* The triangulation information for the vertices in use */
213 int **use_itris; /* The vertex numbers for the 'use' triangulation */
214
215 int **neighbor_tri; /* Neighboring triangles for each vertex
216 * Note: number of entries varies for vertex to vertex */
217 int *nneighbor_tri; /* Number of neighboring triangles for each vertex */
218
219 mneNearest nearest; /* Nearest inuse vertex info (number of these is the same as the number vertices) */
220 mnePatchInfo *patches; /* Patch information (number of these is the same as the number of points in use) */
221 int npatch; /* How many (should be same as nuse) */
222
223 mneSparseMatrix dist; /* Distances between the (used) vertices (along the surface). */
224 float dist_limit; /* Distances above this (in volume) have not been calculated.
225 * If negative, only used vertices have been considered */
226
227 float *curv; /* The FreeSurfer curvature values */
228 float *val; /* Some other values associated with the vertices */
229 /*
230 * These are for volumes only
231 */
232 fiffCoordTrans voxel_surf_RAS_t;/* Transform from voxel coordinate to the surface RAS (MRI) coordinates */
233 int vol_dims[3]; /* Dimensions of the volume grid (width x height x depth)
234 * NOTE: This will be present only if the source space is a complete
235 * rectangular grid with unused vertices included */
236 float voxel_size[3]; /* Derived from the above */
237 mneSparseMatrix interpolator; /* Matrix to interpolate into an MRI volume */
238 char *MRI_volume; /* The name of the file the above interpolator is based on */
239 fiffCoordTrans MRI_voxel_surf_RAS_t;
240 fiffCoordTrans MRI_surf_RAS_RAS_t; /* Transform from surface RAS to RAS coordinates in the associated MRI volume */
241 int MRI_vol_dims[3]; /* Dimensions of the MRI volume (width x height x depth) */
242 /*
243 * Possibility to add user-defined data
244 */
245 void *user_data; /* Anything else we want */
246 mneUserFreeFunc user_data_free; /* Function to set the above free */
248/*
249 * These are the aliases
250 */
255
260
261//typedef struct { /* FreeSurfer patches */
262// mneSurface s; /* Patch represented as a surface */
263// int *vert; /* Vertex numbers in the complete surface*/
264// int *surf_vert; /* Which vertex corresponds to each complete surface vertex here? */
265// int np_surf; /* How many points on the complete surface? */
266// int *tri; /* Which triangles in the complete surface correspond to our triangles? */
267// int *surf_tri; /* Which of our triangles corresponds to each triangle on the complete surface? */
268// int ntri_surf; /* How many triangles on the complete surface */
269// int *border; /* Is this vertex on the border? */
270// int flat; /* Is this a flat patch? */
271// void *user_data; /* Anything else we want */
272// mneUserFreeFunc user_data_free; /* Function to set the above free */
273//} *mneSurfacePatch,mneSurfacePatchRec;
274
275typedef struct { /* Matrix specification with a channel list */
276 int nrow; /* Number of rows */
277 int ncol; /* Number of columns */
278 char **rowlist; /* Name list for the rows (may be NULL) */
279 char **collist; /* Name list for the columns (may be NULL) */
280 float **data; /* The data itself (dense) */
282
283typedef struct { /* Matrix specification with a channel list */
284 int nrow; /* Number of rows (same as in data) */
285 int ncol; /* Number of columns (same as in data) */
286 char **rowlist; /* Name list for the rows (may be NULL) */
287 char **collist; /* Name list for the columns (may be NULL) */
288 mneSparseMatrix data; /* The data itself (sparse) */
290
291typedef struct { /* Vector specification with a channel list */
292 int nvec; /* Number of elements */
293 char **names; /* Name list for the elements */
294 float *data; /* The data itself */
296
297typedef struct { /* One linear projection item */
298 mneNamedMatrix vecs; /* The original projection vectors */
299 int nvec; /* Number of vectors = vecs->nrow */
300 char *desc; /* Projection item description */
301 int kind; /* Projection item kind */
302 int active; /* Is this item active now? */
303 int active_file; /* Was this item active when loaded from file? */
304 int has_meg; /* Does it have MEG channels? */
305 int has_eeg; /* Does it have EEG channels? */
307
308typedef struct { /* Collection of projection items and the projector itself */
309 mneProjItem *items; /* The projection items */
310 int nitems; /* Number of items */
311 char **names; /* Names of the channels in the final projector */
312 int nch; /* Number of channels in the final projector */
313 int nvec; /* Number of vectors in the final projector */
314 float **proj_data; /* The orthogonalized projection vectors picked and orthogonalized from the original data */
316
317typedef struct {
318 int job; /* Value of FIFF_SSS_JOB tag */
319 int coord_frame; /* Coordinate frame */
320 float origin[3]; /* The expansion origin */
321 int nchan; /* How many channels */
322 int out_order; /* Order of the outside expansion */
323 int in_order; /* Order of the inside expansion */
324 int *comp_info; /* Which components are included */
325 int ncomp; /* How many entries in the above */
326 int in_nuse; /* How many components included in the inside expansion */
327 int out_nuse; /* How many components included in the outside expansion */
328} *mneSssData,mneSssDataRec; /* Essential information about SSS */
329
330/*
331 * The class field in mneCovMatrix can have these values
332 */
333#define MNE_COV_CH_UNKNOWN -1 /* No idea */
334#define MNE_COV_CH_MEG_MAG 0 /* Axial gradiometer or magnetometer [T] */
335#define MNE_COV_CH_MEG_GRAD 1 /* Planar gradiometer [T/m] */
336#define MNE_COV_CH_EEG 2 /* EEG [V] */
337
338//typedef struct { /* Covariance matrix storage */
339// int kind; /* Sensor or source covariance */
340// int ncov; /* Dimension */
341// int nfree; /* Number of degrees of freedom */
342// int nproj; /* Number of dimensions projected out */
343// int nzero; /* Number of zero or small eigenvalues */
344// char **names; /* Names of the entries (optional) */
345// double *cov; /* Covariance matrix in packed representation (lower triangle) */
346// double *cov_diag; /* Diagonal covariance matrix */
347// mneSparseMatrix cov_sparse; /* A sparse covariance matrix
348// * (Note: data are floats in this which is an inconsistency) */
349// double *lambda; /* Eigenvalues of cov */
350// double *inv_lambda; /* Inverses of the square roots of the eigenvalues of cov */
351// float **eigen; /* Eigenvectors of cov */
352// double *chol; /* Cholesky decomposition */
353// mneProjOp proj; /* The projection which was active when this matrix was computed */
354// mneSssData sss; /* The SSS data present in the associated raw data file */
355// int *ch_class; /* This will allow grouping of channels for regularization (MEG [T/m], MEG [T], EEG [V] */
356// char **bads; /* Which channels were designated bad when this noise covariance matrix was computed? */
357// int nbad; /* How many of them */
358//} *mneCovMatrix,mneCovMatrixRec;
359
360//typedef struct { /* A forward solution */
361// char *fwdname; /* Name of the file this was loaded from */
362// fiffId meas_id; /* The assosiated measurement ID */
363// mneSourceSpace *spaces; /* The source spaces */
364// int nspace; /* Number of source spaces */
365// fiffCoordTrans mri_head_t; /* MRI <-> head coordinate transformation */
366// fiffCoordTrans meg_head_t; /* MEG <-> head coordinate transformation */
367// int methods; /* EEG, MEG or EEG+MEG (see mne_fiff.h) */
368// int coord_frame; /* The coordinate frame employed in the forward calculations */
369// int source_ori; /* Fixed or free source orientations */
370// float **rr_source; /* The active source points */
371// float **nn_source; /* The source orientations
372// * (These are equal to the cortex normals
373// * in the fixed orientation case) */
374// int nsource; /* Number of source (recalculated for convenience) */
375// fiffChInfo chs; /* The channel list */
376// int nch; /* Number of channels */
377// mneNamedMatrix fwd; /* The forward solution (may be whitened) */
378// mneNamedMatrix fwd_proc; /* This is an alternate matrix for a processed forward matrix (linear projection
379// * and whitening) As a rule, this field is not used but rater the operations are
380// * applied to the field fwd itself */
381// float *patch_areas; /* Contains the patch areas if the CSD transformation has been applied */
382// int fwd_whitened; /* Has the noise covariance been applied to the field fwd? */
383// mneCovMatrix noise_cov; /* The noise covariance matrix employed in whitening */
384// mneProjOp proj; /* Associated projection operator */
385//} *mneForwardSolution,mneForwardSolutionRec;
386
387//typedef struct { /* An inverse operator */
388// fiffId meas_id; /* The assosiated measurement ID */
389// mneSourceSpace *spaces; /* The source spaces */
390// int nspace; /* Number of source spaces */
391// fiffCoordTrans meg_head_t; /* MEG device <-> head coordinate transformation */
392// fiffCoordTrans mri_head_t; /* MRI device <-> head coordinate transformation */
393// int methods; /* EEG, MEG or EEG+MEG (see mne_fiff.h) */
394// int nchan; /* Number of measurement channels */
395// int nsource; /* Number of source points */
396// int fixed_ori; /* Fixed source orientations? */
397// float **rr_source; /* The active source points */
398// float **nn_source; /* The source orientations
399// * (These are equal to the cortex normals
400// * in the fixed orientation case) */
401// int coord_frame; /* Which coordinates are the locations and orientations given in? */
402// mneCovMatrix sensor_cov; /* Sensor covariance matrix */
403// int nave; /* Number of averaged responses (affects scaling of the noise covariance) */
404// int current_unit; /* This can be FIFF_UNIT_AM, FIFF_UNIT_AM_M2, FIFF_UNIT_AM_M3 */
405// mneCovMatrix source_cov; /* Source covariance matrix */
406// mneCovMatrix orient_prior; /* Orientation prior applied */
407// mneCovMatrix depth_prior; /* Depth-weighting prior applied */
408// mneCovMatrix fMRI_prior; /* fMRI prior applied */
409// float *sing; /* Singular values of the inverse operator */
410// mneNamedMatrix eigen_leads; /* The eigen leadfields */
411// int eigen_leads_weighted; /* Have the above been already weighted with R^0.5? */
412// mneNamedMatrix eigen_fields; /* Associated field patterns */
413// float trace_ratio; /* tr(GRG^T)/tr(C) */
414// mneProjOp proj; /* The associated projection operator */
415//} *mneInverseOperator,mneInverseOperatorRec;
416
417typedef struct { /* For storing the wdata */
418 int id; /* Surface id these data belong to */
419 int kind; /* What kind of data */
420 float lat; /* Latency */
421 int nvert; /* Number of vertices */
422 int *vertno; /* Vertex numbers */
423 float *vals; /* The values */
425
426typedef struct {
427 int id; /* Surface id these data belong to */
428 int kind; /* What kind of data */
429 float tmin; /* First time */
430 float tstep; /* Step between times */
431 int ntime; /* Number of times */
432 int nvert; /* Number of vertices */
433 int *vertno; /* The vertex numbers */
434 float **data; /* The data, time by time */
436
437//typedef struct { /* Information about raw data in fiff file */
438// char *filename; /* The name of the file this comes from */
439// fiffId id; /* Measurement id from the file */
440// int nchan; /* Number of channels */
441// fiffChInfo chInfo; /* Channel info data */
442// int coord_frame; /*
443// * Which coordinate frame are the
444// * positions defined in?
445// */
446// fiffCoordTrans trans; /* This is the coordinate transformation
447// * FIFF_COORD_HEAD <--> FIFF_COORD_DEVICE
448// */
449// float sfreq; /* Sampling frequency */
450// float lowpass; /* Lowpass filter setting */
451// float highpass; /* Highpass filter setting */
452// fiffTimeRec start_time; /* Starting time of the acquisition
453// * taken from the meas date
454// * or the meas block id
455// * whence it may be inaccurate. */
456// int buf_size; /* Buffer size in samples */
457// int maxshield_data; /* Are these unprocessed MaxShield data */
458// fiffDirEntry rawDir; /* Directory of raw data tags
459// * These may be of type
460// * FIFF_DATA_BUFFER
461// * FIFF_DATA_SKIP
462// * FIFF_DATA_SKIP_SAMP
463// * FIFF_NOP
464// */
465// int ndir; /* Number of tags in the above
466// * directory */
467//} mneRawInfoRec, *mneRawInfo;
468
469typedef struct { /* Spatiotemporal map */
470 int kind; /* What kind of data */
471 int coord_frame; /* Coordinate frame for vector values */
472 int nvert; /* Number of vertex values */
473 int ntime; /* Number of time points */
474 int nval_vert; /* Number of values per vertex */
475 float tmin; /* First time point */
476 float tstep; /* Step between the time points */
477 int *vertno; /* Vertex numbers in the full triangulation (starting with zero) */
478 float **data; /* The data values (time by time) */
479} mneMapRec, *mneMap;
480
481typedef struct { /* Plotter layout port definition */
482 int portno; /* Running number of this viewport */
483 int invert; /* Invert the signal coming to this port */
484 float xmin,xmax,ymin,ymax; /* Limits */
485 char *names; /* Channels to go into this port (one line, separated by colons) */
486 int match; /* Does this port match with our present channel? */
488
489typedef struct { /* Plotter layout */
490 char *name; /* File where this came from */
491 float xmin,xmax,ymin,ymax; /* The VDC limits */
492 float cxmin,cxmax,cymin,cymax; /* The confined VDC limits */
493 int nport; /* Number of viewports */
494 mneLayoutPort ports; /* Array of viewports */
495 int **match; /* Matching matrix */
496 int nmatch; /* How many channels in matching matrix */
498
499/*
500 * The following relate to high-level handling of raw data
501 */
502#define MNE_CH_SELECTION_UNKNOWN 0
503#define MNE_CH_SELECTION_FILE 1
504#define MNE_CH_SELECTION_USER 2
505
506typedef struct {
507 char *name; /* Name of this selection */
508 char **chdef; /* Channel definitions (may contain regular expressions) */
509 int ndef; /* How many of them */
510 char **chspick; /* Translated into channel names using the present data */
511 char **chspick_nospace; /* The same without spaces */
512 int *pick; /* These are the corresponding channels in the raw data
513 (< 0 indicates missing) */
514 int *pick_deriv; /* These are the corresponding derivations in the raw data */
515 int nderiv; /* How many derivations in the above */
516 int *ch_kind; /* Kinds of the channels corresponding to picks (< 0 indicates missing) */
517 int nchan; /* How many picked channels? */
518 int kind; /* Loaded from file or created here? */
520
521typedef struct {
522 char *name; /* Name of this set */
523 mneChSelection *sels; /* These are the selections */
524 int nsel; /* How many */
525 int current; /* Which is active now? */
527
528typedef struct {
529 unsigned int from; /* Source transition value */
530 unsigned int to; /* Destination transition value */
531 int sample; /* Sample number */
532 int show; /* Can be used as desired */
533 int created_here; /* Was this event created in the program */
534 char *comment; /* Event comment */
536
537typedef struct { /* List of the above. */
538 mneEvent *events;
539 int nevent;
541
542typedef struct {
543 int filter_on; /* Is it on? */
544 int size; /* Length in samples (must be a power of 2) */
545 int taper_size; /* How long a taper in the beginning and end */
546 float highpass; /* Highpass in Hz */
547 float highpass_width; /* Highpass transition width in Hz */
548 float lowpass; /* Lowpass in Hz */
549 float lowpass_width; /* Lowpass transition width in Hz */
550 float eog_highpass; /* EOG highpass in Hz */
551 float eog_highpass_width; /* EOG highpass transition width in Hz */
552 float eog_lowpass; /* EOG lowpass in Hz */
553 float eog_lowpass_width; /* EOG lowpass transition width in Hz */
555
556//typedef struct {
557// fiffDirEntry ent; /* Where is this in the file (file bufs only, pointer to info) */
558// int firsts,lasts; /* First and last sample */
559// int ntaper; /* For filtered buffers: taper length */
560// int ns; /* Number of samples (last - first + 1) */
561// int nchan; /* Number of channels */
562// int is_skip; /* Is this a skip? */
563// float **vals; /* Values (null if not in memory) */
564// int valid; /* Are the data meaningful? */
565// int *ch_filtered; /* For filtered buffers: has this channel filtered already */
566// int comp_status; /* For raw buffers: compensation status */
567//} *mneRawBufDef,mneRawBufDefRec;
568
569/*
570 * CTF compensation stuff
571 */
572#define MNE_CTFV_NOGRAD 0
573#define MNE_CTFV_GRAD1 1
574#define MNE_CTFV_GRAD2 2
575#define MNE_CTFV_GRAD3 3
576/*
577 * 4D compensation stuff
578 */
579#define MNE_4DV_COMP1 101
580
581typedef struct {
582 int kind; /* The compensation kind (CTF) */
583 int mne_kind; /* Our kind */
584 int calibrated; /* Are the coefficients in the file calibrated already? */
585 mneNamedMatrix data; /* The compensation data */
586 mneSparseMatrix presel; /* Apply this selector prior to compensation */
587 mneSparseMatrix postsel; /* Apply this selector after compensation */
588 float *presel_data; /* These are used for the intermediate results in the calculations */
589 float *comp_data;
590 float *postsel_data;
592
593typedef struct {
594 mneCTFcompData *comps; /* All available compensation data sets */
595 int ncomp; /* How many? */
596 fiffChInfo chs; /* Channel information */
597 int nch; /* How many of the above */
598 mneCTFcompData undo; /* Compensation data to undo the current compensation before applying current */
599 mneCTFcompData current; /* The current compensation data composed from the above
600 * taking into account channels presently available */
602
603typedef struct { /* One item in a derivation data set */
604 char *filename; /* Source file name */
605 char *shortname; /* Short nickname for this derivation */
606 mneSparseNamedMatrix deriv_data; /* The derivation data itself */
607 int *in_use; /* How many non-zero elements on each column of the derivation data
608 * (This field is not always used) */
609 int *valid; /* Which of the derivations are valid considering the units of the input
610 * channels (This field is not always used) */
611 fiffChInfo chs; /* First matching channel info in each derivation */
613
614typedef struct { /* A collection of derivations */
615 int nderiv; /* How many? */
616 mneDeriv *derivs; /* Pointers to the items */
618
619typedef struct { /* A comprehensive raw data structure */
620 char *filename; /* This is our file */
621 fiffFile file;
622 mneRawInfo info; /* Loaded using the mne routines */
623 char **ch_names; /* Useful to have the channel names as a single list */
624 char **badlist; /* Bad channel names */
625 int nbad; /* How many? */
626 int *bad; /* Which channels are bad? */
627 mneRawBufDef bufs; /* These are the data */
628 int nbuf; /* How many? */
629 mneRawBufDef filt_bufs; /* These are the filtered ones */
630 int nfilt_buf;
631 int first_samp; /* First sample? */
632 int omit_samp; /* How many samples of skip omitted in the beginning */
633 int omit_samp_old; /* This is the value omit_samp would have in the old versions */
634 int nsamp; /* How many samples in total? */
635 float *first_sample_val; /* Values at the first sample (for dc offset correction before filtering) */
636 mneProjOp proj; /* Projection operator */
637 mneSssData sss; /* SSS data found in this file */
638 mneCTFcompDataSet comp; /* Compensation data */
639 int comp_file; /* Compensation status of these raw data in file */
640 int comp_now; /* Compensation status of these raw data in file */
641 mneFilterDef filter; /* Filter definition */
642 void *filter_data; /* This can be whatever the filter needs */
643 mneUserFreeFunc filter_data_free; /* Function to free the above */
644 mneEventList event_list; /* Trigger events */
645 unsigned int max_event; /* Maximum event number in usenest */
646 char *dig_trigger; /* Name of the digital trigger channel */
647 unsigned int dig_trigger_mask; /* Mask applied to digital trigger channel before considering it */
648 float *offsets; /* Dc offset corrections for display */
649 void *ring; /* The ringbuffer (structure is of no
650 * interest to us) */
651 void *filt_ring; /* Separate ring buffer for filtered data */
652 mneDerivSet deriv; /* Derivation data */
653 mneDeriv deriv_matched; /* Derivation data matched to this raw data and
654 * collected into a single item */
655 float *deriv_offsets; /* Dc offset corrections for display of the derived channels */
656 void *user; /* Whatever */
657 mneUserFreeFunc user_free; /* How this is freed */
659
660typedef struct { /* Data associated with MNE computations for each mneMeasDataSet */
661 float **datap; /* Projection of the whitened data onto the field eigenvectors */
662 float **predicted; /* The predicted data */
663 float *SNR; /* Estimated power SNR as a function of time */
664 float *lambda2_est; /* Regularization parameter estimated from available data */
665 float *lambda2; /* Regularization parameter to be used (as a function of time) */
667
668typedef struct { /* One data set, used in mneMeasData */
669 /*
670 * These are unique to each data set
671 */
672 char *comment; /* Comment associated with these data */
673 float **data; /* The measured data */
674 float **data_proj; /* Some programs maybe interested in keeping the data after SSP separately */
675 float **data_filt; /* Some programs maybe interested in putting a filtered version here */
676 float **data_white; /* The whitened data */
677 float *stim14; /* Data from the digital stimulus channel */
678 int first; /* First sample index for raw data processing */
679 int np; /* Number of times */
680 int nave; /* Number of averaged responses */
681 int kind; /* Which aspect of data */
682 float tmin; /* Starting time */
683 float tstep; /* Time step */
684 float *baselines; /* Baseline values currently applied to the data */
685 mneMneData mne; /* These are the data associated with MNE computations */
686 void *user_data; /* Anything else we want */
687 mneUserFreeFunc user_data_free;/* Function to set the above free */
689
690typedef struct { /* Measurement data representation in MNE calculations */
691 /*
692 * These are common to all data sets
693 */
694 char *filename; /* The source file name */
695 fiffId meas_id; /* The id from the measurement file */
696 fiffTimeRec meas_date; /* The measurement date from the file */
697 fiffChInfo chs; /* The channel information */
698 fiffCoordTrans meg_head_t; /* MEG device <-> head coordinate transformation */
699 fiffCoordTrans mri_head_t; /* MRI device <-> head coordinate transformation
700 (duplicated from the inverse operator or loaded separately) */
701 float sfreq; /* Sampling frequency */
702 int nchan; /* Number of channels */
703 float highpass; /* Highpass filter setting */
704 float lowpass; /* Lowpass filter setting */
705 mneProjOp proj; /* Associated projection operator (useful if inverse operator is not included) */
706 mneCTFcompDataSet comp; /* The software gradient compensation data */
707 mneInverseOperator op; /* Associated inverse operator */
708 mneNamedMatrix fwd; /* Forward operator for dipole fitting */
709 mneRawData raw; /* This will be non-null if the data stems from a raw data file */
710 mneChSelection chsel; /* Channel selection for raw data */
711 char **badlist; /* Bad channel names */
712 int nbad; /* How many? */
713 int *bad; /* Which channels are bad? */
714 /*
715 * These are the data sets loaded
716 */
717 int ch_major; /* Rows are channels rather than times */
718 mneMeasDataSet *sets; /* All loaded data sets */
719 int nset; /* How many */
720 mneMeasDataSet current; /* Which is the current one */
722
723typedef struct { /* Identifier for the automatic parcellation */
724 char *name; /* Name of this area */
725 int index; /* Index in the parcellation */
726 int flag; /* Flag read from the color table (whatever it means) */
727 float r,g,b,alpha; /* The color values */
728 int *vert; /* The vertices belonging to this one */
729 int nvert;
731
732typedef struct { /* A set of the above */
733 int *vert; /* The assignment of each vertex */
734 int nvert; /* How many */
735 mneParc *parcs; /* The 'parcels' */
736 int nparc;
738
739typedef struct {
740 mneParcSet lh_parc;
741 mneParcSet rh_parc;
742} *mneParcData,mneParcDataRec; /* This is the complete parcellation data */
743
744/*
745 * The following are included for reading and writing MRI data in the mgh and mgz formats
746 */
747#define MNE_MRI_VERSION 1
748#define MNE_MRI_UCHAR 0
749#define MNE_MRI_INT 1
750#define MNE_MRI_LONG 2
751#define MNE_MRI_FLOAT 3
752#define MNE_MRI_SHORT 4
753#define MNE_MRI_BITMAP 5
754#define MNE_MRI_TENSOR 6
755
756#define MNE_MRI_ALL_FRAMES -1 /* Load all frames */
757#define MNE_MRI_NO_FRAMES -2 /* Do not load data at all */
758
759typedef union {
760 unsigned char uval;
761 short sval;
762 int ival;
763 float fval;
765
766typedef union {
767 unsigned char ***uslices; /* Different types of voxels */
768 short ***sslices;
769 int ***islices;
770 float ***fslices;
772
773typedef struct {
774 int type; /* Data type duplicated from mneMRIdata */
775 int width; /* Size of the stack duplicated from mneMRIdata*/
776 int height;
777 int depth;
778 void *data; /* These are the actual voxels stored sequentially */
779 int nbytes; /* How many bytes in data (just a convenience) */
780 mneMRIvoxels voxels; /* Different types of voxels */
781 int frame; /* Which frame is this in the original data */
782 void *user_data; /* Anything else we want */
783 mneUserFreeFunc user_data_free; /* Function to set the above free */
784} *mneMRIvolume,mneMRIvolumeRec; /* One volume of data */
785
786typedef struct {
787 char *filename; /* Name of the source file */
788 int version; /* Version number of the data file */
789 int width; /* Size of the stack */
790 int height;
791 int depth;
792 int nframes; /* Number of frames in the original */
793 int dof;
794 int ras_good; /* Indicates that the values below are good */
795 float xsize,ysize,zsize; /* Increments in the three voxel directions */
796 float x_ras[3],y_ras[3],z_ras[3]; /* these are the RAS distances across the whole volume */
797 float c_ras[3]; /* Center of the RAS coordinates
798 * This is irrelevant to the MNE software because we work in
799 * surface RAS coordinates */
800 fiffCoordTrans voxel_surf_RAS_t; /* Transform from voxel coordinate to the surface RAS (MRI) coordinates */
801 fiffCoordTrans surf_RAS_RAS_t; /* Transform from surface RAS to RAS (nonzero origin) coordinates */
802 fiffCoordTrans head_surf_RAS_t; /* Transform from MEG head coordinates to surface RAS */
803 fiffCoordTrans RAS_MNI_tal_t; /* Transform from RAS (nonzero origin) to MNI Talairach coordinates */
804 fiffCoordTrans MNI_tal_tal_gtz_t; /* Transform MNI Talairach to FreeSurfer Talairach coordinates (z > 0) */
805 fiffCoordTrans MNI_tal_tal_ltz_t; /* Transform MNI Talairach to FreeSurfer Talairach coordinates (z < 0) */
806 int type; /* Data type for voxels */
807 mneMRIvolume *volumes; /* The volumes loaded */
808 int nvol; /* How many loaded volumes */
809 int current_vol; /* Which volume is the current destination for modifications */
810 float TR; /* Recovery time */
811 float TE; /* Echo time time */
812 float TI; /* Inversion time */
813 float flip_angle; /* Flip angle */
814 float fov; /* Field of view */
815 void *tags; /* The format of the tag information is kept private */
816 void *user_data; /* Anything else we want */
817 mneUserFreeFunc user_data_free; /* Function to set the above free */
818} *mneMRIdata,mneMRIdataRec; /* MRI data description suitable for handling mgh and mgz data files */
819
820/*
821 * Wavelet transform structures
822 */
823typedef struct {
824 float sfreq; /* The sampling frequency */
825 int nfreq; /* How many frequencies */
826 float **W; /* The corresponding wavelets */
827 float **W_power; /* Power spectra of the above */
828 int *np; /* Number of points in each */
829 float *freqs; /* The corresponding frequencies */
830 float **W_fft; /* Fourier transforms of the wavelets for convolution */
831 int *np_fft; /* Number of points in each the above */
832 /*
833 * Possibility to add user-defined data
834 */
835 void *user_data; /* Anything else we want */
836 mneUserFreeFunc user_data_free; /* Function to set the above free */
838
839typedef struct { /* Used to store the wavelet transform */
840 int type; /* What is stored here? */
841 int nchan; /* Number of channels */
842 int nsamp; /* Number of time samples */
843 float sfreq; /* Sampling frequency */
844 float *freqs; /* Wavelet frequencies */
845 int nfreq; /* Number of frequencies */
846 float tmin; /* Time scale minimum */
847 float ***trans; /* The transforms */
849
850#define MNE_WAVELET_COMPLEX 1
851#define MNE_WAVELET_POWER 2
852
853/*
854 * Environment variables and others
855 */
856#define MNE_DEFAULT_TRIGGER_CH "STI 014"
857#define MNE_DEFAULT_FILTER_SIZE 4096
858#define MNE_ENV_TRIGGER_CH "MNE_TRIGGER_CH_NAME"
859#define MNE_ENV_TRIGGER_CH_MASK "MNE_TRIGGER_CH_MASK"
860#define MNE_ENV_ROOT "MNE_ROOT"
861#define MNE_ENV_FILTER_SIZE "MNE_FILTER_SIZE"
862
863#if defined(__cplusplus)
864}
865#endif
866#endif