Signal segmentation error: how to select a specific number of points before and after the ECG signal?

1 vue (au cours des 30 derniers jours)
I want to segment an ECG signal in heartbeats by taking a number of sample points before and after each R-peak. I did the following loop:
for i=1:length(qrs_i_raw)
%qrs_i_raw has the index location of the peak
it gives me this error
Index exceeds the number of array elements (650000).
I understand why I get this error, but how can I modify the loop so for the first and last beat it will take just the existing points before the first beat and the remaining points after the last beat?

Réponse acceptée

Star Strider
Star Strider le 9 Fév 2021
See How do I find and plot the average of action potentials from a trace? for an appropriate approach. Substitute your EKG vector and time vector for the signals in that code, and adjust the ‘ofst’ value to be the one you want (typically about 450 ms for an EKG, so that value would depend on the sampling frequency of your EKG and the heart rate, so multiply the sampling frequency in Hz by 0.45 to get the number of samples to use for ‘ofst’). It may be necessary to adjust that for the heart rate, so typically that interval should be slightly less than ½ of the previous — or mean — R-R interval.

Plus de réponses (1)

Mathieu NOE
Mathieu NOE le 9 Fév 2021
hello Ioana
I modified a bit your code , hope it works
nn = length(qrs_i_raw);
% first and last buffer - specific cases
% general cases
for i=2:nn-1
beat(i,:)=ECG(qrs_i_raw(i)-before:qrs_i_raw(i)+after); % pls note index i is same on both sides of the equation
%qrs_i_raw has the index location of the peak


En savoir plus sur ECG / EKG dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by