Sunteți pe pagina 1din 5

Real–Time ECG Algorithms for Ambulatory Patient Monitoring

Esteban Pino1,2,3 , Lucila Ohno–Machado MD, PhD1,3 , Eduardo Wiechmann PhD2 ,


Dorothy Curtis4
1
Decision Systems Group, Brigham & Women’s Hosp., Harvard Med. Sch., Boston, MA
2
Dep. Ing. Eléctrica, Fac. de Ingenierı́a, Universidad de Concepción, Concepción, Chile
3
Division of Health Science and Technology, Harvard–MIT, MA
4
Computer Science and Artificial Intelligence Laboratory, MIT, Cambridge, MA

Brigham & Women’s Hospital is designing a wire- order to accommodate many patients and caregivers,
less monitoring system for patients in the waiting and allocate time to other tasks such as location
area of the Emergency Department. A real–time ECG tracking, alarm handling, storage and retrieval of his-
algorithm is required to monitor and alert changes torical data, and resource management. Also, system
in patients that have not yet been admitted to the dependability is tightly tied to an accurate screening
Emergency Room. For this purpose, three simple of alarms. Response times may improve only if false
algorithms are compared in terms of processing time, alarms are kept to a minimum. To conform to all these
beat detection accuracy and heart rate (HR) esti- requirements, the selected ECG processing algorithm
mation. Varying amounts of noise were added to must be fast, noise resistant and accurate.
records from the MIT-BIH Arrhythmia Database [1] This paper presents an evaluation of three different
to mimic expected waiting room conditions. Some ECG processing algorithms for SMART Central. The
recommendations regarding selection of an algorithm first one, a peak detection algorithm (Peak), is an
and further processing of HR series are presented. improved version from a simple peak detector [4]
originally used to test the SMART system. The other
Introduction two, a slope detector (SQRS) [5] and a Length–
Patients who arrive at a hospital Emergency De- Transform based algorithm (WQRS) [6] are easily
partment (ED) are triaged and sent to a waiting accessible on the web [1]. They were selected for their
area until a caregiver becomes available. It is not simplicity and ease of integration into a streaming
uncommon to wait for a very long time for medi- database. Many more algorithm descriptions can be
cal attention, especially if the initial triage did not found in [7], which gives an overview of the state of
detect an impending medical condition. The SMART the art in ECG processing.
(Scalable Medical Alert and Response Technology)
project aims to monitor those patients in order to Methods
help triage, assist in resource management and pro- Our testbed was programmed in C++. It provides
vide better tools to evaluate patients [2]. The goal a similar streaming-database framework to SMART
is to develop a scalable system, easy to deploy in Central, and allows us to perform tests on standard
emergency situations and locations, and dependable databases simply by adding interfaces to them. Data
in terms of avoiding false alarms and misdirections. are streamed to a small buffer, which is processed
The monitoring devices will include a single– by one of the algorithms and then forwarded to an
lead ECG and a SpO2 sensor. Both signals will be output buffer. Our testbed also has the ability to save
timestamped and buffered in a portable device and the output as annotations in PhysioNet–compatible
sent wirelessly to the SMART Central. Then, the data [1] format or as Matlab / Octave [8] readable text
are directed to a streaming database with processing files. Once tested and tuned, code migration from our
nodes. These computation nodes will transform, in testbed to SMART Central is straightforward.
real–time, the raw data streams into more usable The data set used for testing was the complete
information [3] such as heart rate (HR). MIT-BIH Arrhythmia Database [1], available online
ECG algorithms must meet certain requirements in at www.physionet.org. We selected this database to
order to be useful for the SMART project. As patients try to mimic the ED conditions: different patients with
walk around or even shift in place while in the waiting varying heart conditions. The MIT-BIH Arrhythmia
area, artifacts from sensor displacement, muscle noise Database contains 48 half-hour ECG recordings from
and baseline wander appear in the signal. The scalable 47 different subjects. To evaluate their sensitivity to
premise implies that the processing must be fast, in noise, we generated 6 different noise level recordings

AMIA 2005 Symposium Proceedings Page - 604


200
from each one of the original signals. PhysioNet tools 100
allow the addition of varying amounts of noise to 0

Amplitude
any signal on their database. We selected 6 different -100

Signal to Noise Ratios (SNR): 24 dB, 18 dB, 12 dB, -200 ECG


window max
central seg. max
6 dB, 0 dB and -6 dB. The noise source, “em”, also
-300 threshold
detected beat
-400
available online [1], contains motion artifacts, muscle 0 1 2
Time [s]
3 4 5

noise and baseline wander. Noise is added after the Fig. 1. Peak Algorithm. A beat is detected if the window
first 5 minutes of the signal, in alternating 2 minutes maximum is also the segment maximum and both are greater than
segments of noise and clean signal. a threshold.
In order to provide maximum portability, we want
2000
the algorithms to be independent of signal amplitude 1000

(gain) and sampling frequency. We achieve this by 0

Amplitude
-1000

using variable thresholds and by timestamping the -2000


-3000
recorded data. To evaluate the algorithms, the code -4000 filter output

was ported to our C++ testbed. This allowed us to -5000 threshold


detected beat
-6000

compute running times under the same environment 0 1 2


Time [s]
3 4 5

and also to automate the testing of all of the records. Fig. 2. SQRS Algorithm. A beat is detected when the filtered
The test consists of running each one of the three signal crosses a threshold 2 to 4 times. When there are more than
4 crossings the position is marked as an artifact.
algorithms on the 288 data files. Each test is run
twice, once to save computation times and once to ECG signal [5]. Using a variable threshold, it detects
generate a file with beat annotations. The annotations and identifies QRS complexes from artifacts. The C
are compared to the reference annotations by an code was extracted from PhysioNet [1] web site and
external program, and aggregated by noise level. We adapted to handle data streams.
used PhysioNet’s “bxb” program to compare beat to The filter mask is [1 4 6 4 1 -1 -4 -6 -4 -1] and has
beat annotations using the default values: comparison its maximum gain at 0.1 · Fs or 36 Hz for a signal
begins after the first 5 minutes and the matching sampled at 360 Hz. This convolution filter is applied
window is 0.15 s long. Finally, we computed HR from to a vector containing the last 10 values acquired from
the annotations and post–processed them in Octave. the ECG signal, to enhance its slope. If the filtered
signal is greater than a threshold, the time is saved
Algorithm Descriptions and the algorithm enters a decision phase. Two to
A. Peak detector four of these detections within 160ms of each other
The Peak detector algorithm is applied directly to indicate that a normal beat was identified. More than
the ECG data. It uses a 167 ms window, divided in 4 detections within 200ms of each other indicate an
three 55.6 ms segments. This limits our maximum artifact. After a decision has been made, the algorithm
detectable beat frequency to 360 BPM. It scans the is reset. Once every 2 seconds, if there is no detection,
whole range looking for the maximum value. If the the threshold is reduced by 1/16th . If there are more
maximum value is on the central segment and is than 4 detections, the threshold is increased by 1/16th .
higher than a threshold, the position is marked as a Every time a normal beat is detected, the threshold is
beat and its amplitude is saved as the new threshold. recalculated, asymptotically converging to 1/4 of the
At each new possible beat, the threshold is updated, maximum filter output obtained so far. Fig. 2 shows
using a linear decay between the previous beat ampli- the SQRS filter output for the same ECG signal used
tude and the current window maximum, at a variable in fig. 1.
rate of
last beat ampl. − current peak ampl. 72 C. WQRS algorithm
· (1)
2 60 The original WQRS algorithm was obtained from
The threshold may only decrease unless it is set by PhysioNet [1] and adapted to handle data streams. It
a new beat detection. Fig. 1 shows an example, in is based on the Length Transform [6] of the ECG.
which an extra beat is detected due to a high P wave For a discrete, one channel signal, the Length
and a rising baseline. Transform of a signal x[n] using a window q can
be calculated by:
B. SQRS algorithm
i+q−1
X p
SQRS algorithm uses a Finite Impulse Response Li = 1 + (xk − xk−1 )2 (2)
(FIR) filter as an approximation to the slope of an k=i

AMIA 2005 Symposium Proceedings Page - 605


100000 100
90000 Length Transform
threshold 90
80000 detected beat 80
70000 end point (J)
70
Amplitude

60000
60

[%]
50000
50 Peak Alg. Se
40000
40 Peak Alg. +P
30000 SQRS Alg. Se
20000 30 SQRS Alg. +P
20 WQRS Alg. Se
10000 WQRS Alg. +P
0 10
0 1 2 3 4 5 24 dB 18 dB 12 dB 6 dB 0 dB -6 dB
Time [s] SNR

Fig. 3. WQRS Algorithm. A beat is detected if the Length Fig. 4. Sensitivity and Positive Predictivity by algorithm and noise
Transform of the signal is higher than a threshold. level.

TABLE I B EAT POSITIONS FOR FIGURES 1, 2 AND 3. data points collected at a sampling rate of 360 Hz
Reference beats [s] 0.43 1.58 2.76 – 3.91 and spanning 1806 s. Consequently, the final running
Peak alg. beats [s] 0.40 1.56 2.73 3.74 3.89 times are directly comparable.
SQRS alg. beats [s] 0.39 1.54 2.72 – 3.87 The results are shown in table II. These are only
WQRS alg. beats [s] 0.43 1.58 2.76 – 3.92
WQRS J-points [s] 0.53 1.69 2.87 – 4.02
useful as a reference for how the algorithms compare
to each other. The actual computation time will de-
pend on the processor used and the signal sampling
Our implementation considers a window length of
frequency. The estimated load for the initial SMART
130 ms, in order to maximize the detection of QRS
deployment goal of 16 simultaneous ECGs sampled
complexes. After the transformation, the output is
at 200 Hz is
compared to a threshold and then further tested for a
rising slope of the Length Transform. This algorithm Alg. run time 200
Alg. load [%] = · · 16 · 100 (3)
has the extra ability to mark the end of the QRS 1806 360
complex, also known as J–point. Fig. 3 shows the Using equation 3, the estimated maximum load from
Length Transform of the ECG signal from fig. 1, and running the algorithms is 1.47% for Peak, 2.41% for
the detected onset and offset of the QRS complex. SQRS and 5.06% for WQRS algorithm. In a stream-
ing database environment, the load is the computation
D. Beat detection
time required by unit time of fed data.
Table I shows the detected beat positions reported
by the algorithms for the original ECG signal from B. Beat Detection Accuracy
Fig. 1. The reference beat positions are obtained from Beat detection accuracy is normally evaluated using
the annotation file associated to the clean record. Note two parameters [7]: Sensitivity (Se) and Positive
that there is a small shift in beat positions. However, Predictivity (+P ).
they are all within 150 ms of the reference, and thus
TP TP
considered matching beats. The only unmatched beat Se = , +P = (4)
in our example was detected by the Peak algorithm TP + FN TP + FP
at 3.74 s. where,
T P : number of true positive detections.
Results F N : number of false negatives or missed beats.
A. Processing Time F P : number of false positives or false beats.
The tests were performed on an AMD AthlonTM Table III shows the aggregated T P , F N and F P
64 Processor 3200+, running at 2 GHz, with 1 GB obtained in each case. A total of 547,710 beats were
physical memory. The computation time was mea- tested for each algorithm, resulting in either detected
sured from the start of reading the data into the input beats (T P ) or missed beats (F N ). Table IV and figure
buffer until all the nodes that were chained to that 4 show the results by noise level. WQRS algorithm
input buffer had completed their tasks. All records provides the best Se for the whole noise range, while
from MIT-BIH Arrhythmia Database have 650,000 SQRS has the best +P up to 0 dB SNR. SQRS Se
TABLE II AVERAGE COMPUTATION TIME BY NOISE LEVEL of 19.33% at -6 dB SNR deserves special note. It is
Noise Peak alg. SQRS alg. WQRS alg. unexpected to obtain a Se under 50% for an algorithm
(SNR) mean time [s] mean time [s] mean time [s] that has a Se > 95% for clean signals. Since noise
24 dB 2.982 4.992 10.636 is introduced in alternating 2 minute intervals, the
18 dB 2.949 5.002 10.578
12 dB 2.977 5.020 10.255 expected Se for a very noisy test signal is close to
6 dB 2.993 4.964 10.127 50%. Upon closer examination, it is apparent that the
0 dB 3.070 4.717 10.003 threshold is increased during the noisy interval to a
-6 dB 2.985 4.706 10.090
Average 2.993 4.900 10.281 point that it takes almost the whole clean interval to
return to a suitable range.

AMIA 2005 Symposium Proceedings Page - 606


TABLE III OVERALL Se AND +P [%]. 1000

Alg. TP FN FP Se +P 500

Peak 441,662 106,048 104,902 80.64 80.81 0

Amp.
SQRS 402,284 145,426 36,553 73.45 91.67 -500
WQRS 500,700 47,010 117,595 91.42 80.98 ECG
Peak Beats
-1000 SQRS Beats
WQRS Beats
-1500 Ref Beats
410 415 420 425 430
TABLE IV A LGORITHM Se AND +P [%] BY NOISE LEVEL . time [s]
(a) Beat detection in a 20 s. sample from record 119 with 6 dB
Noise Peak alg. SQRS alg. WQRS alg. SNR. Noise ends at 500 s.
(SNR) Se +P Se +P Se +P
24 dB 91.92 93.85 95.96 99.69 98.37 96.87 450
HR Peak alg.
18 dB 91.54 92.90 95.74 99.57 98.27 95.45 400 HR SQRS alg.
HR WQRS alg.
350
12 dB 88.93 86.60 94.51 98.22 97.00 84.09 300
Reference HR

6 dB 78.16 76.57 84.98 91.70 94.53 75.64 250

HR
0 dB 68.86 69.18 50.17 79.31 87.27 71.73 200
150
-6 dB 64.42 65.76 19.33 53.43 73.07 65.93 100
50
0
410 415 420 425 430

C. Heart Rate Derivation time [s]


(b) HR computed from the beat information without further pro-
The main parameter obtained from ECG signals cessing.
is the HR. SMART project will generate an alarm 450
400
HR Peak alg.

on beat to beat HR thresholds and patterns, so HR


HR SQRS alg.
350 HR WQRS alg.
Reference HR
300
derivation from the detected beats must be accurate. 250

HR
HR errors come from both missed beats (F N ) and
200
150

false beats (F P ). The probability for any beat to 100


50

cause an incorrect HR value is 0


410 415 420 425 430
time [s]
FN + FP (c) HR after applying an order–3 median filter.
P (incorrect HR) = (5)
TP + FN + FP 450
400
HR Peak alg.
HR SQRS alg.

From equation set (4) we obtain 350


300
HR WQRS alg.
Reference HR

250
FN 1 − Se FP 1 − +P
HR

200
= , = (6) 150
TP Se TP +P 100
50

From (5) and (6), the probability of having an incor- 0


410 415 420 425 430

rect beat to beat HR is


time [s]
(d) HR after discarding variations greater than 10 BPM.
+P · Se
P (incorrect HR) = 1 − . (7) Fig. 6. Example of different post-processing options for the HR
+P − +P · Se + Se series.
Figure 5 was generated using equation (7) and table
IV. SQRS algorithm has the lowest error probability to the transition from a noisy segment to a clean
in the range from 24 dB to 6 dB SNR. segment, which mimics our environment of patients
HR variability conveys important diagnosis infor- in a waiting room. Figure 6(b) shows the derived HR
mation. An example is Poincaré plots [9], which from beats in figure 6(a). Peak algorithm is the most
show variations among consecutive RR intervals. affected by noise, producing high HR spikes. SQRS,
Post–processing of the HR series must preserve its on the other hand, is the closest to the reference
variability. HR, computed from the manually annotated normal
A small portion of MIT–BIH record 119 was used beats. The order–3 median filter output is shown in
to pre–evaluate two different HR series filters, an figure 6(c). As expected, the HR spikes from all
order–3 median filter and a 10 BPM outlier rejection algorithms are considerably smoothed. Finally, the
filter. The record was contaminated with noise to outlier rejection filter is shown in figure 6(d). HR
obtain a 6 dB SNR. The selected portion corresponds changes of more than 10 BPM are discarded and the
90
last valid HR value is used. This kind of filtering pro-
80
Peak alg
SQRS alg
WQRS alg
vides the strongest smoothing during noisy segments.
70
60 However, the downside is that true HR variations may
50
be masked for a longer time if they occur during a
[%]

40
30
20 noise episode, as is the case of figure 6(d).
10
0
24 dB 18 dB 12 dB 6 dB 0 dB -6 dB
Table V confirms these observations when we post–
SNR process the HR series for the whole database. As an
Fig. 5. Heart Rate error probability. indication of the HR variability, the standard deviation

AMIA 2005 Symposium Proceedings Page - 607


TABLE V S TD D EV. OF HR WITH DIFFERENT PROCESSING
it is possible to reduce the variation in heart rate by
TECHNIQUES .
using a simple median filter. We also note that the
SNR Ref. Peak alg. SQRS alg. WQRS alg.
Without post–processing
best beat detection algorithm to compute HR is not
24 dB 19.1 49.2 23.1 33.7 necessarily the one with highest Se or +P , but a
18 dB 19.1 52.5 23.4 36.2 combination of both. For the particular conditions of
12 dB 19.1 71.0 25.9 48.2 SMART Project, we would select SQRS algorithm
6 dB 19.1 86.5 36.8 55.5
0 dB 19.1 87.3 45.0 57.8 with an order–3 median filter for the HR derivation.
-6 dB 19.1 86.3 48.7 58.2 SQRS algorithm performance under controlled
Median filter noise conditions (SNR ≥ 6 dB) is consistent with the
24 dB 19.1 22.2 18.1 25.1
18 dB 19.1 22.1 18.1 26.3 calculated probability of HR error. Further improve-
12 dB 19.1 23.8 18.3 33.8 ments under heavy noise conditions may be possible
6 dB 19.1 26.6 22.5 39.8 by combining its output with Peak algorithm’s. The
0 dB 19.1 31.7 27.6 40.2
-6 dB 19.1 32.4 29.4 38.3 projected load from running both is less than WQRS
Outlier rejection algorithm alone.
24 dB 19.1 15.8 16.4 17.6
18 dB 19.1 15.4 16.3 17.4
12 dB 19.1 15.3 16.2 18.2 Acknowledgment
6 dB 19.1 15.4 16.6 18.6 The authors wish to thank CONICYT (Chilean Na-
0 dB 19.1 15.8 16.9 17.3
-6 dB 19.1 16.0 20.3 17.5 tional Council for Science and Technology Research)
for their financial support. This work was supported
in part by the National Library of Medicine, National
(SD) of the HR series is computed. Both without
Institutes of Health, N01LM33509.
filtering and with median filter, SQRS–derived HR SD
is closest to the reference HR SD, for all noise levels.
References
Using the outlier rejection filter, HR SD for all the
algorithms is below the reference HR SD, implying [1] A. L. Goldberger, L. A. N. Amaral, L. Glass et al.
too much filtering. The best combination to preserve PhysioBank, PhysioToolkit, and PhysioNet: Com-
HR variability for this record set is SQRS algorithm ponents of a new research resource for complex
coupled to a median filter. physiologic signals. Circulation, 101(23):e215–
e220, 2000 (June 13).
Conclusion [2] Scalable Medical Alert and Response Technol-
All three algorithms were successfully integrated ogy (SMART) Project web page. Available at
into a streaming database to perform real–time pro- http://smart.csail.mit.edu/
cessing of ECG signals. The projected CPU load to [3] Barbara J. Drew, Robert M. Califf, Marjorie Funk
run any algorithm is less than 5.1% in a normal et al. Practice standards for electrocardiographic
PC workstation, for the expected number of patients. monitoring in hospital settings. Circulation,
This leaves enough time to perform all other SMART 110(17):2721–2746, Oct 2004.
required tasks. System scaling is also possible by [4] Peak algorithm as described in unpublished code
adding extra SMART Central workstations and dis- written by Greg Harfst, MIT.
tributing the streams. Porting the ECG processing [5] W.A.H Englese and C. Zeelenberg. A single
algorithm to a smaller device is still under consid- scan algorithm for QRS detection and feature
eration and would also benefit scaling by offloading extraction. IEEE Computers in Cardiology, pages
processing burden from SMART Central. 37–42, 1979.
Using a standard database we compared algorithm [6] F. Gritzali, G. Frangakis, and G. Papakonstanti-
accuracy with varying degrees of noise level. In the nou. Detection of the P and T waves in an ECG.
whole SNR range, the best Se is obtained by WQRS Computers and Biomedical Research, 22:83–91,
algorithm. However, the best +P results are obtained 1989.
with SQRS algorithm in the 24 dB to 0 dB SNR [7] B. U. Kohler, C. Hennig, and R. Orglmeister. The
range. In order to evaluate the relative importance of principles of software QRS detection. Engineer-
Se and +P , the equation that relates the probability ing in Medicine and Biology Magazine, IEEE,
of deriving an incorrect HR to the Se and +P indexes 21(1):42–57, 2002.
was presented. [8] J. W. Eaton. GNU Octave. Available at
Our Heart Rate tests showed that there is a consid- www.octave.org.
erable amount of errors introduced by missed beats [9] M. Malik and A. J. Camm. Dynamic Electrocar-
(FN) or extra detected beats (FP). We showed that diography. Blackwell Futura, 2004.

AMIA 2005 Symposium Proceedings Page - 608

S-ar putea să vă placă și