-
Notifications
You must be signed in to change notification settings - Fork 0
/
ecgdata.h
105 lines (80 loc) · 2.68 KB
/
ecgdata.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
/**
* @file ecgdata.h
*
* Copyright (C) 2018 Datrix
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see https://www.gnu.org/licenses/.
*
*/
#if !defined(ECGDATA_H)
#define ECGDATA_H
#include <QtWidgets>
#include "wfdb/wfdb.h"
#include "wfdb/ecgmap.h"
#include "wfdb/ecgcodes.h"
#define CHANNEL_MAX (12)
#define MASK_THESE_BITS(b,bits) ((unsigned long) ((b) & ((1 << (bits)) - 1)))
#define MASK_4_BIT(b) MASK_THESE_BITS(b, 4)
#define MASK_8_BIT(b) MASK_THESE_BITS(b, 8)
#define MASK_10_BIT(b) MASK_THESE_BITS(b,10)
#define MASK_12_BIT(b) MASK_THESE_BITS(b,12)
#define ECG_HEADER_UNIVERSAL (QFileInfo(filename).absolutePath() + "/" + QString("ecg.hea"))
/* {{{ class EcgData
@brief class to manage streams of ECG data
*/
class EcgData : public QObject
{
Q_OBJECT
public:
EcgData( QWidget *parent = NULL );
EcgData( QString filename, QWidget *parent = NULL );
~EcgData();
ulong size() { return datalen_secs * samps_per_chan_per_sec; } /* return samples per channel */
QString parse_header( QString filename );
WFDB_Siginfo * wfdbOpen( QString filename );
int Load( QString filename );
long sample_count();
quint16 *get( int channel_num, long start_time_samps, long duration_samps );
quint16 *get_data_channel( int channel_num ) { return chdata[channel_num]; }
QString file_name;
double range_per_sample;
double device_range_mV;
int channel_count;
int datalen_secs;
int samps_per_chan_per_sec;
int signal_format_specifier;
float bytes_per_samp;
bool data_loading;
QDateTime viewableDateTime;
WFDB_Siginfo *wfdbSignalInfo;
private:
void store_edfheader_field( QByteArray header, QString fieldname, int fieldsize );
QHash<QString,QString> edfheader;
int edf_nr;
int edf_ns;
int edf_bytes_in_header;
int edf_samps_per_record;
float edf_record_duration_secs;
QTemporaryFile fileEcgCache[3];
quint16 * chdata[12];
public slots:
void cancel_data_loading();
signals:
void load_size( int filesize );
void data_loaded_so_far( int loaded );
void loading_finished();
void pacer_spike_found( long samplePos );
};
/* }}} */
#endif