how to figure heart rate graph
12 次查看(过去 30 天)
显示 更早的评论
Hello guys.
I have ECG signal from which i have average heart rate using wavelet transform. Now, i need to figure heart rate graph, but i dont know how to do it. Can you help me? It should look like picture below.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/853420/image.png)
My code:
%%
clc;
clear all;
close all;
%% Načítanie EKG signálu
[record,hdr] = edfread('EKG3.EDF');
farosEKG=record.ECG;
farosEKG = vertcat(farosEKG{1:end});
%%
fs = 200; % Vzorkovacia frekvencia
farosEKG = downsample(farosEKG,1000/fs); % Presamplovanie na požadovanú vzorkovaciu frekvenciu
pocet_vzorkov = 1:length(farosEKG); % Počet vzorkov signálu
vektor_casu = pocet_vzorkov./200; % Časový vektor
% 4 level undecimated DWT using sym4
vt = modwt(farosEKG,4,'sym4');
% Extracting d3 and d4 coeff.
wtrec = zeros(size(vt));
wtrec(3:4,:) = vt(3:4,:);
% Inverse DWT with d3 and d4 coeff.
y = imodwt(wtrec, 'sym4');
y = abs(y).^2; % Magnitude square
yavg = mean(y); % Average of y^2 as threshold
% Detecting Peaks
[R_peaks, locs] = findpeaks(y,pocet_vzorkov,'MinPeakHeight',8*yavg,'MinPeakDistance',50);
% Number of beats
n_beats = length(locs);
timelimit = length(farosEKG)/200;
% Heart rate BPM
bpm = (n_beats*60)/timelimit;
disp(strcat('Priemerná tepová frekvencia je : ',num2str(bpm)))
% Showing ECG signal and the detected R Peaks
subplot(211)
plot(vektor_casu,farosEKG);
xlim([0,timelimit]);
title('EKG signál');
hold on;
plot([timelimit/3, timelimit/3], [-6000, 10000], 'k');
plot([(timelimit/3)+(timelimit/3), (timelimit/3)+(timelimit/3)], [-6000, 10000], 'k');
text(89, 7000,'Rýchlosť - 4km/hod');
text(336, 7000,'Rýchlosť - 6km/hod');
text(581, 7000,'Rýchlosť - 8km/hod');
hold off;
subplot(212)
plot(pocet_vzorkov,y);
xlim([0,length(farosEKG)]);
hold on;
plot(locs,R_peaks,'ro');
title('Hľadanie peakov');
hold on;
plot([14.8e4/3, 14.8e4/3], [-0.5e7, 3e7], 'k');
plot([(14.8e4/3)+(14.8e4/3), (14.8e4/3)+(14.8e4/3)], [-0.5e7, 3e7], 'k');
text(1.8e4, 2.5e7,'Rýchlosť - 4km/hod');
text(6.7e4, 2.5e7,'Rýchlosť - 6km/hod');
text(11.8e4, 2.5e7,'Rýchlosť - 8km/hod');
hold off;
3 个评论
Star Strider
2022-1-5
The R-R intervals will be in units of seconds/beat.
How would you convert that to beats/second, and then beats/minute?
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 ECG / EKG 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!