-
Notifications
You must be signed in to change notification settings - Fork 4
/
KPointDetect.m
45 lines (42 loc) · 1.08 KB
/
KPointDetect.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
%This code is adapted from Kasturi Joshi and Edward Labrador's code
%published in Early Myocardial Infarction Detection, May 2009.
function [K_index,K_amp,K_t] = KPointDetect(Q_index,H_R,sfreq,D)
D = transpose(D);
D = cwt(D,1:4,'bior2.4'); %Performing Continuous Wavelet Transform using
%Biorthogonal Wavelet
D = transpose(D);
x = D(:,4);
clear D;
Q_len = length(Q_index);
for j = 1:Q_len
IQ1 = Q_index(j);
for i=IQ1:-1:IQ1- (round(sfreq*0.03) *(H_R/72))
if i == 0
K_index(j) = 1;
K_amp(j)= x(1,1);
K_t(j)=t(1,1);
break
end
if x(i,1)>=0
K_index(j) = i;
K_amp(j)= x(i,1);
K_t(j)=t(1,i);
break
end
end
if i == 0
K_index(j) = 1;
K_amp(j)= x(1,1);
K_t(j)=t(1,1);
break
end
if x(i,1)< x(i+1,1) && x(i,1)< x(i-1,1)
K_index(j) = i;
if K_index(j)==0
K_index(j)=1;
end
K_amp(j)= x(i,1);
K_t(j)=t(1,i);
end
end
return