How to work out BPM from ECG data
32 次查看(过去 30 天)
显示 更早的评论
Hi,
I have managed to find the beatsperminute of my data using the findpeaks function, however I want to confirm this using the fourier transform with spectral analysis however I am not sure how to do this.
0 个评论
采纳的回答
Star Strider
2020-1-9
编辑:Star Strider
2020-1-9
The R-wave frequency peak should be the largest peak in the absolute value of the Fourier transform (after removing any d-c offset that may be present). Use the max function (with two outputs) to detect it and its index (into the frequency vector).
Use the second (index) output of max to get the associated frequency index of the R-wave peak.
The frequency vector of the Fourier transform will be in units of cycles/(time unit).
To convert this to (time units)/cycle, simply invert it.
That should produce the average heart rate, based on R-wave frequency.
EDIT — (9 Jan 2020 at 22:48)
Using the data you posted to your other Question:
EKG = readmatrix('Anonymous ECG.csv');
L = numel(EKG);
Fs = 350/2; % Units: Hz
Ts = 1/Fs; % Units: Sec
tv = linspace(0,L,L)*Ts; % Units: Sec
Fn = Fs/2;
FTEKG = fft(EKG)/L;
Fv = linspace(0, 1, fix(L/2)+1)*Fn;
Iv = 1:numel(Fv);
figure
plot(tv , EKG)
grid
[Pks,Locs] = findpeaks(EKG,tv, 'MinPeakHeight',200);
MeanHr1 = 60/mean(diff(Locs)); % Units: 1/Min
figure
plot(Fv, abs(FTEKG(Iv))*2)
grid
[MaxFTEKG,Idx] = max(abs(FTEKG(Iv))*2);
MeanHR2 = 60/Fv(Idx); % Units: 1/Min
Note that ‘MeanHR1’ and ‘MeanHr2’ are not the same because the broadband noise present in the Fourier-transformed data (that cannot be removed witha frequency-selective filter) may obscure the actual R-wave peak in the Fourier-transformed data. They are close, however, although I suspect that ‘Fs’ is wrong (probably should be 350), because the heart rates are about half of what they should be.
2 个评论
Star Strider
2020-1-10
Please describe what you intend by: ‘... plot the ECG against BPM ...’
It is not at all obvious what that means.
更多回答(1 个)
Kashish Raheja
2021-6-2
how do i display bpm using my ecg data in matlab command window? what functions and code to write? pls helpp
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Signal Generation and Preprocessing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!