Finding the turning point on the left side of a peak
조회 수: 5 (최근 30일)
이전 댓글 표시
I am writing a program that analyses the data from an ECG machine, and it needs to find the turning point on either side of the major peak. I have been able to find the turning point to the roght of each peak but cannot think of a way to find the turning point on the left side
%Load data
load('Sample_2.mat');
%Filter Data
[b, a] = butter(10,0.1,'low');
% fvtool(b,a);
Filtered = filtfilt(b,a,Orig_Sig);
%Dynamic Min Peak Height%
x = max(Filtered)
min_h = x*.8;
plot(Filtered);
hold on;
[peaks,locs] = findpeaks(Filtered,'MinPeakHeight',min_h, 'MinPeakDistance', 150);
plot(locs,peaks,'rv','MarkerSize',10)
hold on;
%find S points
A = 1:length(locs);
current = locs(A);
next = current + 1;
while Filtered(current) >= Filtered(next)
current = next;
next = next + 1;
end
plot(current,Filtered(current),'g*','MarkerSize',10)
hold on;
댓글 수: 0
채택된 답변
Star Strider
2021년 10월 24일
‘... the turning point on either side of the major peak’
Those are referred to as the Q and S deflections (or waves).
The filter is not designed correctly. I would use:
[Filtered, df] = bandpass(Orig_Sig, [1 45], Fs, 'ImpulseResponse','iir');
in order to elimiinate the baselilne drift as well as any high-frequency noise that couold be present. (Here ‘Fs’ is the sampling frequency, and should be constant for the entire record. If it is not, there are ways to correct for that.)
The bandpass call will design an elliptic bandpass filter and the ‘Filtered’ result should make any subsequent analyses easier. It also returns the digital filter object in ‘df’ so that it is not necessary to create it again if the intent is to use it subsequently.
Those deflections appear to be relatively well-defined here, so use the islocalmin function to identify them. I have had success with that in the past, and it should work here as well. It will be necessary to use some of the name-value pair arguments to get it to produce the desired result.
Other than the motion artefact, it appears to be a normal EKG. What appear to be low P-waves and peaked T-waves with U-waves could be indicative of hyperkalemia (or drug effects).
.
댓글 수: 2
Star Strider
2021년 10월 26일
As always, my pleasure!
That tends to be a bit more difficult, since the objective is to find specific peaaks that do not include all peaks.
It just requres a bit of set arithmetic, and it’s easier to demonstrate it than describe it —
t = linspace(0, 100, 250);
EKG = sin(2*pi*t*0.075).*(sin(2*pi*t*0.075)>0.7)*0.25 + sin(2*pi*t*0.075+pi).*(sin(2*pi*t*0.075+pi)>0.7)*0.75;
[pks1,locs1] = findpeaks(EKG); % All Peak Indices
[pks2,locs2] = findpeaks(EKG, 'MinPeakHeight',0.5); % R-Wave Indices
locs3 = setdiff(locs1,locs2); % P- & T-Wave Indices
figure
plot(t, EKG)
hold on
plot(t(locs1), EKG(locs1),'xr', 'MarkerSize',15)
plot(t(locs2), EKG(locs2),'+g', 'MarkerSize',15)
hold off
grid
legend('EKG','All Peaks','R-Waves', 'Location','best')
ylim([0 1])
figure
plot(t, EKG)
hold on
plot(t(locs3), EKG(locs3),'^r', 'MarkerSize',15)
hold off
grid
legend('EKG','P- & T-Waves', 'Location','best')
ylim([0 1])
Since in this trace, the P-waves are reduced and the T-waves appear to be peaked, this approach can be extended to identify them separately. (That may not always be the situation, especially with EKG traces displaying broadband noise, so it is not generally robust.)
.
추가 답변 (0개)
참고 항목
카테고리
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!