-
Notifications
You must be signed in to change notification settings - Fork 9
/
FindQRSBegin.m
31 lines (19 loc) · 1.1 KB
/
FindQRSBegin.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
function QRSBeginIndex = FindQRSBegin(DownSampledECG, DownSampledTimeAxis, QRSPeakIndex, Fs)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
[b,a] = butter(2, (1.5/ (Fs/2)), 'high'); % Cut out anything below 1.5 Hz to optimize search forward routine
NoBiasDownSampledECG = filter(b, a, DownSampledECG);
QRSBeginIndex = []; % Index of QRS Start samples
for QRSPeakIndexCounter=1:length(QRSPeakIndex)
CurrentSample = QRSPeakIndex(QRSPeakIndexCounter);
while (NoBiasDownSampledECG(CurrentSample) > (0.20 * NoBiasDownSampledECG(QRSPeakIndex(QRSPeakIndexCounter))) && (CurrentSample > 0))
CurrentSample = CurrentSample - 1;
end
QRSBeginIndex(QRSPeakIndexCounter) = CurrentSample;
end
QRSStartPlot = figure('Name','Start of QRS - ECG signal'); % Create a new figure
plot(DownSampledTimeAxis, DownSampledECG);
hold on; plot(DownSampledTimeAxis(QRSBeginIndex), DownSampledECG(QRSBeginIndex), 'r*'); hold off;
title('QRS start locations - ECG signal (w/ starting points indicated by red "*" ');
xlabel('Time (Sec)'); ylabel('ECG (mV)'); axis auto;
end