I'm using curve length transform to detect QRS complex.I used below code for that.The output LT is having two peaks instead of one. I'm not getting where it went wrong

3 views (last 30 days)
clear all
close all
load 'C:\cygwin\home\kuma\new16265.txt'; % record 16265
s=(new16265(:,2))';
fs=128;
N=length(s);
x=s;
[b,a] = butter(3,[5 15]/(fs/2));
y = filtfilt(b,a,x);
y=y/max(abs(y));
w=128;
c=5;
for i=2+w:N
for k=i-w:i
d=y(k)-y(k-1);
l(k)=sqrt(c+d^2);
end
L(w,i)=sum(l(k));
end

Accepted Answer

Star Strider
Star Strider on 14 Oct 2015
Even when I looked up the paper that seems to describe what you’re doing, it’s difficult to figure out your code. The only problem that I see is:
L(w,i)=sum(l(k));
since it is after the ‘k’ loop, so it is summing only the last element of that vector, essentially being sum(l(end)). I would (1) either put it inside the ‘k’ loop, or (2) leave it where it is and change it to:
L(w,i)=sum(l);
I don’t know if this will solve your problem (because I can’t run your code to test it) but either change will result in the correct values for ‘L’.
  10 Comments
Bharathi Surisetti
Bharathi Surisetti on 16 Oct 2015
Sorry to bother you again. I'm using the same paper for detection of QRS onset and off set .I'm getting 3-4 samples difference for each beat.
"The algorithm searches backward for 125ms to get minimum value, Lmin and forward for 125 ms to get a maximum value, Lmax".The difference LA=Lmax-Lmin is obtained.Then from tc again , algorithm searches backward to find location Qb,where the LT value drops monotically to Lmin+La/100 ,and searches forward to find the location Sb,where the LT increases to Lmax-La/20. QB and Sb are considered the base values of QRS onset and end respectively .The actual QRS onset is adjusted by -5 samples and the actual end by +5 samples"
Matlab implementation I done:
w1=10; for r=1:length(peaks) i=peaks(r); lmin(r)=min(L1(i-w1:i)); lmax(r)=max(L1(i:i+w1)); la(r)=lmax(r)-lmin(r); for k=i:-1:i-w1 x1=lmin(r)+(la(r)/100); if L1(k)<x1 Qb(r)=k-5; end end
for k=i:i+w1
x1=lmax(r)-(la(r)/20);
if L1(k)>x1
Sb(r)=k+5;
end
end
end
Can you please have a look? Please don't mind as I'm asking so many questions.
Star Strider
Star Strider on 16 Oct 2015
They’re preprocessing the EKG to window the QRS complex before they do the line integral on it. That seems to me to defeat the purpose of doing the line integral.
You can threshold the peaks my code provides to identify the QRS occurrences and duration. If that doesn’t produce appropriate results, you may have to tweak my code. I would adjust ‘w’ within the range I mentioned earlier, and perhaps introduce the scaling parameter ‘C’ in place of ‘Ts’ in the ‘l’ calculation, to narrow the peaks my code produces. That may produce narrow enough peaks to allow you to identify both the QRS complex occurrences and widths with reasonable accuracy.

Sign in to comment.

More Answers (0)

Categories

Find more on Measurements and Feature Extraction in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!