-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread_signal_file.h
215 lines (194 loc) · 4.32 KB
/
read_signal_file.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#ifndef READ_SIGNAL_FILE_H
#define READ_SIGNAL_FILE_H
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <locale>
#include <cmath>
#include <math.h>
#include <time.h>
//#include <string.h>
#include <type_traits>
#include <cstdint>
#include <functional>
#include <algorithm>
#include<tuple>
//#include <QString>
#include <QFileInfo>
#include <QDateTime>
#include <QDebug>
//#include <QMap>
// structs definitions
struct SignalPage
{
unsigned short filling;
long time;
};
struct Spages
{
std::vector<std::vector<double>> esignals;
std::vector<SignalPage> pages;
};
struct Event
{
short ev_type;
unsigned char sub_type;
unsigned int page;
float page_time;
unsigned int time;
unsigned int duration;
unsigned int duration_in_ms;
unsigned int channels;
unsigned int info;
unsigned int end_time = time + duration_in_ms;
};
struct Note{
char desc[256];
int page;
int time; // maybe?
};
struct EventDesc
{
int DT_MEASURE = 0;
int DT_EXTERNAL = 1;
int DT_SCAN = 2;
//DT_DICT = {DT_MEASURE: "DT_MEASURE", DT_EXTERNAL: "DT_EXTERNAL", DT_SCAN: "DT_SCAN"}
std::string desc;
std::string label;
int d_type;
int value;
};
struct SignalHeader
{
long program_id;
long signal_id;
short version_id;
short read_only;
};
struct Measurement
{
char id[17];
char name[33];
char street[33];
char zip_code[17];
char city[33];
char state[33];
char country[33];
long birthday;
short sex;
long start_date;
long start_hour;
char room[9];
char doctor[33];
char technician[33];
char class_code[9];
char clin_info[1963];
char backup_flag[1];
short status_flags;
char archive_flag[1];
float vcr_timing_correction;
char referring_doctor_name[33];
char referring_doctor_code[33];
short weight;
short height;
short weight_unit;
short height_unit;
char protocol[33];
short maximum_voltage;
short maximum_amplitude;
};
struct Block
{
long offset;
long size;
long header_size;
};
struct DataTable
{
Block measurement_info;
Block recorder_montage_info;
Block events_info;
Block notes_info;
Block impedance_info;
Block display_montages_info;
Block stimulator_info;
Block signal_info;
};
struct Channel
{
double sampling_rate;
std::string signal_type;
std::string signal_sub_type;
std::string channel_desc;
float sensitivity_index;
float low_filter_index;
float high_filter_index;
double delay;
std::string unit;
short artefact_level;
short cal_type;
float cal_factor;
float cal_offset;
double save_buffer_size;
};
struct Montage{
std::string name;
std::vector<std::string> leads;
};
struct RecorderMontageInfo
{
char name[33];
unsigned char nRecChannels[1];
unsigned char invertedACChannels[1];
short maximumVoltage;
short normalVoltage;
short calibrationSignal;
short calibrationScale;
short videoControl;
unsigned short nSensitivities;
unsigned short nLowFilters;
unsigned short nHighFilters;
std::vector<float> sensitivity; // vector of 20 floats
std::vector<float> lowFilter;
std::vector<float> highFilter;
char montageName[33];
int numberOfChannelsUsed;
int globalSens;
short epochLengthInSamples;
unsigned short highestRate;
std::vector<Channel> channels;
int parameter = 0; // from here - not used?
Montage displayMontage;
std::string dispCh;
std::string dispChScale;
std::string electrode = "";
std::string lead;
int gain;
int offset;
int nChannelsOnDisplay = 0;
int sampleMap;
std::string dummy = "";
};
struct SignalFile
{
SignalHeader header;
DataTable data_table;
Measurement measurement;
RecorderMontageInfo recorder_info;
std::vector<Event> events;
std::vector<EventDesc> events_desc;
std::vector<Note> notes;
int store_events;
std::vector<std::vector<double>> signal_data; //actual EEG data
std::vector<SignalPage> signal_pages;
std::vector<Montage> montages; //additional montages
bool check = false;
};
QDateTime decode_date_time(long date, long time);
SignalFile read_signal_file(QFileInfo fileInfo);
#endif