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

1 次查看(过去 30 天)
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:
before=100;
after=140;
for i=1:length(qrs_i_raw)
beat(i,:)=ECG(qrs_i_raw(i+1)-before:qrs_i_raw(i+1)+after);
end
%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?

采纳的回答

Star Strider
Star Strider 2021-2-9
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.

更多回答(1 个)

Mathieu NOE
Mathieu NOE 2021-2-9
hello Ioana
I modified a bit your code , hope it works
before=100;
after=140;
nn = length(qrs_i_raw);
% first and last buffer - specific cases
beat(1,:)=ECG(1:qrs_i_raw(1)+after);
beat(nn,:)=ECG(qrs_i_raw(nn)-before:end);
% 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
end
%qrs_i_raw has the index location of the peak

类别

Help CenterFile Exchange 中查找有关 ECG / EKG 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by