~ubuntu-branches/ubuntu/precise/openwalnut/precise

« back to all changes in this revision

Viewing changes to src/modules/data/ext/libeep/cnt/cnt_private.h

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Eichelbaum
  • Date: 2011-06-21 10:26:54 UTC
  • Revision ID: james.westby@ubuntu.com-20110621102654-rq0zf436q949biih
Tags: upstream-1.2.5
ImportĀ upstreamĀ versionĀ 1.2.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/********************************************************************************
 
2
 *                                                                              *
 
3
 * this file is part of:                                                        *
 
4
 * libeep, the project for reading and writing avr/cnt eeg and related files    *
 
5
 *                                                                              *
 
6
 ********************************************************************************
 
7
 *                                                                              *
 
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  *
 
11
 *                                                                              *
 
12
 ********************************************************************************
 
13
 *                                                                              *
 
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.                                          *
 
18
 *                                                                              *
 
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.                          *
 
22
 *                                                                              *
 
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/>          *
 
25
 *                                                                              *
 
26
 *******************************************************************************/
 
27
 
 
28
#ifndef CNT_PRIVATE_H
 
29
 
 
30
#include <cnt/cnt.h>
 
31
#include <cnt/raw3.h>
 
32
#include <cnt/riff.h>
 
33
#include <eep/var_string.h>
 
34
#include <eep/val.h>
 
35
 
 
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')
 
49
 
 
50
/* channel specific informations */
 
51
struct   eegchan_s {
 
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 ...)*/
 
59
};
 
60
 
 
61
/* time/frequency component specific informations */
 
62
struct tf_component_s {
 
63
  float axis_value;
 
64
  char  description[40];
 
65
};
 
66
 
 
67
/* Epoch specific information */
 
68
typedef struct {
 
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 */
 
73
} cnt_epoch_t;
 
74
 
 
75
/* Time/frequency data-chunk information */
 
76
typedef struct {
 
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) */
 
85
} cnt_data_t;
 
86
 
 
87
/* Time Frequency Header contents */
 
88
typedef struct {
 
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          */
 
96
 
 
97
  /* RIFF hacking/trickery. See make_partial_output_consistent() */
 
98
  /* Don't EVER touch this unless you know exactly what it does. */
 
99
  long            chunk_size;
 
100
} tf_header_t;
 
101
 
 
102
/* Standard EEP headers */
 
103
typedef struct {
 
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 */
 
110
 
 
111
  long total_trials;
 
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. */
 
116
 
 
117
  /* RIFF hacking/trickery. See make_partial_output_consistent() */
 
118
  /* Don't EVER touch this unless you know exactly what it does. */
 
119
  long chunk_size;
 
120
} eep_header_t;
 
121
 
 
122
typedef struct {
 
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 */
 
129
 
 
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 */
 
133
 
 
134
  /* RIFF hacking/trickery. See make_partial_output_consistent() */
 
135
  /* Don't EVER touch this unless you know exactly what they're for. */
 
136
  long data_size;
 
137
  long ep_size;
 
138
 
 
139
  /* memory mapped access. It maps the contents of the X.DATA chunk */
 
140
#ifdef CNT_MMAP
 
141
  int   data_mapped;
 
142
  int   map_offset; /* Offset because mmaps always start a page boundaries */
 
143
  void *data_map;
 
144
#endif
 
145
} storage_t;
 
146
 
 
147
/* EEG informations; internal access control stuff */
 
148
struct eeg_dummy_t {
 
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... */
 
154
 
 
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                           */
 
160
#if 0
 
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)   */
 
165
#endif
 
166
  trg_t *trg;                    /* Trigger library (TRG chunk)            */
 
167
  record_info_t *recording_info; /* recording information (INFO chunk)     */
 
168
 
 
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 */
 
176
 
 
177
  /*chunk_mode_e active_chunk_mode;*/ /* type of data reading/writing */
 
178
  eep_datatype_e current_datachunk; /* Chunk we're currently writing */
 
179
 
 
180
  int finalized; /* When writing files, 0 = false, 1 = true */
 
181
 
 
182
  /****************** Backwards compatibility ***********************/
 
183
  /* NeuroScan ---------------------------------------------------- */
 
184
  char  ns_cnttype;
 
185
  int   ns_evtc;
 
186
  int   ns_evtpos;
 
187
  char  ns_evttype;
 
188
  int   ns_evtlen;
 
189
  /* use members epochc, epochl, buf, bufepoch, readpos */
 
190
 
 
191
  int keep_consistent;
 
192
};
 
193
 
 
194
#endif