1
/********************************************************************************
3
* this file is part of: *
4
* libeep, the project for reading and writing avr/cnt eeg and related files *
6
********************************************************************************
8
* LICENSE:Copyright (c) 2003-2009, *
9
* Advanced Neuro Technology (ANT) B.V., Enschede, The Netherlands *
10
* Max-Planck Institute for Human Cognitive & Brain Sciences, Leipzig, Germany *
12
********************************************************************************
14
* This library is free software; you can redistribute it and/or modify *
15
* it under the terms of the GNU Lesser General Public License as published by *
16
* the Free Software Foundation; either version 3 of the License, or *
17
* (at your option) any later version. *
19
* This library is distributed WITHOUT ANY WARRANTY; even the implied warranty *
20
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21
* GNU Lesser General Public License for more details. *
23
* You should have received a copy of the GNU Lesser General Public License *
24
* along with this program. If not, see <http://www.gnu.org/licenses/> *
26
*******************************************************************************/
33
#include <eep/var_string.h>
36
#define FOURCC_raw3 FOURCC('r', 'a', 'w', '3')
37
#define FOURCC_chan FOURCC('c', 'h', 'a', 'n')
38
#define FOURCC_data FOURCC('d', 'a', 't', 'a')
39
#define FOURCC_ep FOURCC('e', 'p', ' ', ' ')
40
#define FOURCC_eeph FOURCC('e', 'e', 'p', 'h')
41
#define FOURCC_evt FOURCC('e', 'v', 't', ' ')
42
#define FOURCC_refh FOURCC('r', 'e', 'f', 'h')
43
#define FOURCC_info FOURCC('i', 'n', 'f', 'o')
44
#define FOURCC_imp FOURCC('i', 'm', 'p', ' ')
45
#define FOURCC_stdd FOURCC('s', 't', 'd', 'd')
46
#define FOURCC_tfh FOURCC('t', 'f', 'h', ' ')
47
#define FOURCC_tfd FOURCC('t', 'f', 'd', ' ')
48
#define FOURCC_rawf FOURCC('r', 'a', 'w', 'f')
50
/* channel specific informations */
52
char lab[16]; /* electrode label */
53
double iscale; /* "internal" scaling gain * calibration */
54
double rscale; /* "real world" scaling (value of 1 bit if iscale = 1.0) */
55
char runit[16]; /* unit String (uV, fT...) */
56
char reflab[10]; /* reference label */
57
char status[10]; /* channel status */
58
char type[10]; /* sensor type (EEG, MEG ...)*/
61
/* time/frequency component specific informations */
62
struct tf_component_s {
67
/* Epoch specific information */
69
slen_t epochc; /* number of epochs in file */
70
slen_t epochl; /* epoch length in samples */
71
int *epochv; /* relative file position of epochs */
72
int epvbuf; /* file position buffer */
75
/* Time/frequency data-chunk information */
77
slen_t bufepoch; /* id number of the epoch in buffer */
78
char writeflag; /* access mode flag */
79
slen_t writepos; /* working buffer write pointer */
80
slen_t readpos; /* " read " */
81
/* Either buf_int or buf_float is used, the other should be NULL */
82
float *buf_float; /* working buffer (1 epoch), floats */
83
sraw_t *buf_int; /* working buffer (1 epoch), integers */
84
char *cbuf; /* buffer with data as in file (poss. compressed) */
87
/* Time Frequency Header contents */
89
char tf_type[40]; /* Time/frequency type identifier */
90
tf_content_e content_datatype;/* TF content type spec. */
91
slen_t componentc; /* Number of components */
92
tf_component_t *componentv; /* component info table */
93
char tf_unit[16]; /* Unit of measurement on time/freq axis */
94
int samplec; /* Number of TF samples */
95
double period; /* T/F time axis scaling */
97
/* RIFF hacking/trickery. See make_partial_output_consistent() */
98
/* Don't EVER touch this unless you know exactly what it does. */
102
/* Standard EEP headers */
104
double period; /* time axis scaling */
105
short chanc; /* number of electrodes */
106
eegchan_t *chanv; /* electrode info table */
107
slen_t samplec; /* Number of samples */
108
int fileversion_major; /* CNT file versioning. See cnt_version.h */
109
int fileversion_minor; /* CNT file versioning. See cnt_version.h */
112
long averaged_trials;
113
char conditionlabel[25]; /* condition label: used trigger value or condition description */
114
char conditioncolor[25]; /* condition color */
115
double pre_stimulus; /* pre-stimulus interval e.g. for baseline calc. */
117
/* RIFF hacking/trickery. See make_partial_output_consistent() */
118
/* Don't EVER touch this unless you know exactly what it does. */
123
int initialized; /* Can we read/write data of this type? */
124
fourcc_t fourcc; /* RIFF chunk identifier (four chars) */
125
chunk_t ch_toplevel; /* The toplevel chunk, e.g. raw3, tfd or avr */
126
chunk_t ch_chan; /* Channel sequence subchunk of toplevel chunk */
127
chunk_t ch_data; /* (Compressed) data subchunk of toplevel chunk */
128
chunk_t ch_ep; /* Epochs subchunk of toplevel chunk */
130
cnt_epoch_t epochs; /* Struct holding the epoch data for this TL chunk */
131
cnt_data_t data; /* Struct representing data from the 'data' chunk */
132
short *chanseq; /* Compressed channel seq, data from chan chunk */
134
/* RIFF hacking/trickery. See make_partial_output_consistent() */
135
/* Don't EVER touch this unless you know exactly what they're for. */
139
/* memory mapped access. It maps the contents of the X.DATA chunk */
142
int map_offset; /* Offset because mmaps always start a page boundaries */
147
/* EEG informations; internal access control stuff */
149
/* common members --------------------------------------- */
150
short mode; /* cnt type */
151
FILE *f; /* File pointer */
152
char *fname; /* File name */
153
val_t *values; /* Method to access extra information... */
155
/* Data structures */
156
eep_header_t eep_header; /* EEP header contents (EEPH chunk) */
157
var_string history; /* File history (EEPH chunk) */
158
tf_header_t tf_header; /* Time/freq. header contents (TFH chunk) */
159
storage_t store[NUM_DATATYPES];/* Data storage */
161
storage_t rawdata; /* Raw EEG data (RAW3 chunk) */
162
storage_t tfdata; /* Time/freq. data (TFD chunk) */
163
storage_t rawfdata; /* Float data (RAWF chunk) */
164
storage_t stddata; /* Standard deviation data (STDD chunk) */
166
trg_t *trg; /* Trigger library (TRG chunk) */
167
record_info_t *recording_info; /* recording information (INFO chunk) */
169
/* Lowlevel structures for internal use */
170
raw3_t *r3; /* Raw3 compression data */
171
chunk_t cnt; /* The 'root' chunk of this file (parent of toplevel chunks) */
172
chunk_t eeph; /* EEP Header chunk */
173
chunk_t tfh; /* Time/frequency Header chunk */
174
chunk_t evt; /* Event-list chunk */
175
chunk_t info; /* Recording-information chunk */
177
/*chunk_mode_e active_chunk_mode;*/ /* type of data reading/writing */
178
eep_datatype_e current_datachunk; /* Chunk we're currently writing */
180
int finalized; /* When writing files, 0 = false, 1 = true */
182
/****************** Backwards compatibility ***********************/
183
/* NeuroScan ---------------------------------------------------- */
189
/* use members epochc, epochl, buf, bufepoch, readpos */