MATLAB Answers

# How can I Identify the P,Q,R,S and T waves in all 12 leads of ECG

7 views (last 30 days)
Naveen F on 17 Oct 2020
Commented: Naveen F on 17 Oct 2020
Hi all,
I am currenly working on diagnosing heart diseases using 12 lead ecgs.
for this project i use preprocessed data which has 500hz sampling rate.
Here i attached a sample file from the database i used.
as a first step seperated the 12 leads ecg
Data = load('HR00001.mat'); % 12x5000 double
ecg = Data.val(1,1:5000); % 1x5000 double
my next step is to identify the P,Q,R,S and T waves. As a beginner i found it quite challenging.
I wrote a code which only able to find R waves in the lead I but its totally useless when it comes to other leads.
Can some one help me a step by guidance for detect P,Q,R,S and T in different leads.
Data = load('HR00001.mat'); % 12x5000 double
ecg = Data.val(1,1:5000); % 1x5000 double
peaks_1 = ecg>500;
f_s = 500;
time = (1:numel(ecg))/f_s;
[peaks_2,pos_peaks] = findpeaks(ecg,'MINPEAKDISTANCE',10,'MINPEAKHEIGHT',500);
plot(time,ecg,'b',pos_peaks/500,(peaks_2),'ro')
axis ([0 10 -300 800])
Please help me in this issue . your help will will highly appreciated.
thanks and best regards.

#### 6 Comments

Show 3 older comments
Naveen F on 17 Oct 2020
That so true sir, I tried lots of proposed codes in the matlab forum but the problem that i am going to address is quite complex one. I really appreciate your guidance.
I access the source ( Braunwald's Heart Disease: A Textbook of Cardiovascular Medicine ) from google scholar since the website you have mentioned is currenlty not working or it blocks the IPs from my region . I hope this will help me to solve my issue.
Thanks and best regards.
Star Strider on 17 Oct 2020
Naveen —
My pleasure!
I have a hardcopy of the latest edition in my physical library. If you are doing anything related to heart disease, I suggest that you get a copy or refer to one in your university library It is an invaluable resource.
Naveen F on 17 Oct 2020
Thank you very much for the suggestion Star Strider sir, I will deffinitely send an email to our uni librarian regarding this resource.
Thanks and best regards.

Sign in to comment.

### Answers (1)

Cris LaPierre on 17 Oct 2020
Edited: Cris LaPierre on 17 Oct 2020
If you would like an interactive way to try to detect peaks, I suggest using the Find Local Extrema task in the live editor. It allows you to use a graphical interface to set the peak detection parameters. Once you get something you like, you can convrt the task to code, which allows you to build a script to run on multiple data sets.
It might be important to set your expectations here. This is not a silver bullet. You will still need to gain an understanding of what it is doing to use it appropriately, especially if you are trying to make medical diagnoses from your analysis.

#### 1 Comment

Naveen F on 17 Oct 2020
Thank you very much pitching your answer for my question. I know nothing comes on a silver palate. I'll put my fullest effort on this and find a way to solve my problem using this method. I hope this method will help me to solve my issue.
keep up the good work.
Note : Still i can ask any follow up questions regarding this problem right even after i accept this answer ? (just ask because i am new to this forum )
Thanks and best regards.

Sign in to comment.

### Community Treasure Hunt

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

Start Hunting!