# How to find Q and S point in QRS complex of ECG signal?

289 views (last 30 days)
Explorer on 9 Feb 2016
Commented: anas khan on 12 Mar 2022
How to find Q and R points of ECG signal shown below?
Code:
plot(val(1,:))
anas khan on 12 Mar 2022
D.val error show why sir plz guid me

Star Strider on 9 Feb 2016
The first trace doesn’t have any S-waves, so don’t look for them. The EKG morphology is dependent on the lead placement and heart health. The second one is a very sick heart, with a left bundle-branch block pattern. It also has an RSR' pattern, so you have to be careful to not detect the first R-deflection.
My code:
EKG1 = q.val(1,:);
EKG2 = q.val(2,:);
Fs = 128;
t = [0:size(EKG1,2)-1]/Fs;
[R1,TR1] = findpeaks( EKG1, t, 'MinPeakHeight',200);
[Q1,TQ1] = findpeaks(-EKG1, t, 'MinPeakHeight',100); % NOTE: No ‘S’ Waves In EKG1
[R2,TR2] = findpeaks( EKG2, t, 'MinPeakHeight', 50);
[QS2,TQS2] = findpeaks(-EKG2, t, 'MinPeakHeight', 75);
figure(1)
subplot(2,1,1)
plot(t, EKG1)
hold on
plot(TR1, R1, '^r')
plot(TQ1, -Q1, 'vg')
hold off
grid
axis([0 2 ylim])
legend('EKG', 'R', 'Q')
subplot(2,1,2)
plot(t, EKG2)
hold on
plot(TR2, R2, '^r')
plot(TQS2(1:2:end), -QS2(1:2:end), 'vg')
plot(TQS2(2:2:end), -QS2(2:2:end), 'vb')
hold off
grid
axis([0 2 ylim])
legend('EKG', 'R', 'Q', 'S')
My plot:
Star Strider on 18 Feb 2016
My pleasure. Electrocardiography and the principles behind it are not trivial to learn.
I didn’t look at that signal in detail, but the number of Q-waves and R-waves should not differ by more than 1, if the EKG trace was cut off in the middle of a QRS complex. Otherwise, experiment with different values of 'MINPEAKDISTANCE' in your findpeaks call to be sure the peaks it returns aren’t too close to each other. Do that for both the Q-wave and R-wave findpeak calls. You can use the same value for 'MINPEAKDISTANCE' for both once you detetermine the best value for it.

Shatha Jazar on 13 Feb 2017
please can you predict the R wave in my signal ?

tursun wali on 20 Mar 2017
Dear @Star Strider, ----------------------------------- Answer by Star Strider on 9 Feb 2016 Accepted answer ----------------------------------- Your result is impressive and what I want. I want to find height of Q, R and S peaks ; so far find R and S not Q peak I have tested you code (I've changed one line:q = load('16265m.mat'); ) It shows this error message: ----------------------------------- Error using uddpvparse (line 122) Invalid Parameter/Value pairs.
Error in findpeaks>parse_inputs (line 84) hopts = uddpvparse('dspopts.findpeaks',varargin{:});
Error in findpeaks (line 59) [X,Ph,Pd,Th,Np,Str,infIdx] = parse_inputs(X,varargin{:});
Error in QRS_detect_tursun6 (line 6) [R1,TR1] = findpeaks( EKG1, t, 'MinPeakHeight',200); -----------------------------------
I would be very happy if you tell me how to fix it? Well actually My signal contains only one EKG (attachment: person6.mat): I want to find height of Q, R and S peaks ; so far find R and S not Q peak
Christopher McCausland on 10 Mar 2021
@sania urooj I would suggest creating a new question. However to run any code on diffrent arrays a simple 'for' loop of the lenght/width (depending on the orentation of the ecg leads) of the data should surfice. Remeber to include an array within the loop to store loop data in and a second array outside the loop to write the loop data too once the loop completes.
Hope this helps!
For 1:width(ecgchanneldata)
% do this code
end