-
Notifications
You must be signed in to change notification settings - Fork 1
/
QRS_COMPARE.m
54 lines (53 loc) · 2.24 KB
/
QRS_COMPARE.m
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
clc;
clear;
warning('off','all');
data_path = 'database\euro\';
%-EUROPE-------------------------------------------------------------------
% recordings = [103 104 105 112 118 121 139 162 161 154 613 612 704 801 808];
% leads = [001 002 001 002 001 001 002 002 002 002 001 002 002 002 002];
recordings = [112];
leads = [002];
for record = 1:length(recordings)
try
filename = ['e0' num2str(recordings(record))];
disp(filename);
full_path = [data_path filename '.hea'];
ECGw = ECGwrapper( 'recording_name', full_path);
% READ SIGANL AND ANNOTATION---------------------------------------
ann = ECGw.ECG_annotations;
hea = ECGw.ECG_header;
sig = ECGw.read_signal(1,hea.nsamp/20);
sig1_raw = sig(:,1);
sig1_raw = sig1_raw(1:end);
% BASELINE REMOVE USING Wavelet_decompose--------------------------
[approx, detail] = wavelet_decompose(sig1_raw, 8, 'db4');
sig1_raw = sig1_raw - approx(:,8);
% NORMALIZATION CODES----------------------------------------------
sig1_raw = sig1_raw - mean(sig1_raw);
L = length(sig1_raw);
Ex = 1/L * sum(abs(sig1_raw).^2);
sig1_raw = sig1_raw / Ex;
% NORMALIZA THE SIGNAL FROM 0 TO 1
sig1_raw = sig1_raw + abs(min(sig1_raw));
sig1_raw = sig1_raw / max(sig1_raw);
% GENERAL PARAMETERS-----------------------------------------------
fs = hea.freq;
ts = 1/fs;
signal = sig1_raw(1:20000);
[qrs_amp_raw,qrs_i_raw,delay,ecg_h]=pan_tompkin(signal,fs,0);
[QRS_amps, QRS_locs, T_amps, T_locs, signal_filtered] = np_QRSTdetect(signal,fs);
%QRST_detect;
figure1 = figure;
set(figure1,'name',filename,'numbertitle','off');
subplot(3,1,1);plot(signal_filtered);title('Nguyen Pham QRS');
axis([0 length(signal_filtered) 0 1]);
hold on;plot(QRS_locs,QRS_amps,'o');
subplot(3,1,2);plot(signal_filtered);title('Nguyen Pham T');
axis([0 length(signal_filtered) 0 1]);
hold on;plot(T_locs,T_amps,'^');
subplot(3,1,3);plot(ecg_h);title('Pan Thompkin QRS');
hold on;plot(qrs_i_raw,qrs_amp_raw,'o');
catch
disp('error occured.');
end;
end;