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?
댓글 수: 0
채택된 답변
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.
댓글 수: 0
추가 답변 (1개)
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 Center 및 File Exchange에서 ECG / EKG에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!