How to work out BPM from ECG data
35 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Star Strider
il 9 Gen 2020
Modificato: Star Strider
il 9 Gen 2020
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 Commenti
Star Strider
il 10 Gen 2020
Please describe what you intend by: ‘... plot the ECG against BPM ...’
It is not at all obvious what that means.
Più risposte (1)
Kashish Raheja
il 2 Giu 2021
how do i display bpm using my ecg data in matlab command window? what functions and code to write? pls helpp
0 Commenti
Vedere anche
Categorie
Scopri di più su Signal Generation and Preprocessing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!