Anda di halaman 1dari 12

1660 IEEE JOURNAL OF BIOMEDICAL AND HEALTH INFORMATICS, VOL. 19, NO.

5, SEPTEMBER 2015

A Method for Context-Based Adaptive QRS


Clustering in Real Time
Daniel Castro, Paulo Félix, and Jesús Presedo

Abstract—Continuous followup of heart condition through long- Cardiac arrhythmias are the most relevant among the ECG
term electrocardiogram monitoring is an invaluable tool for di- findings. There are two main sources of arrhythmias: An
agnosing some cardiac arrhythmias. In such context, providing automatism disorder, that is, a set of alterations in the beat activa-
tools for fast locating alterations of normal conduction patterns is
mandatory and still remains an open issue. This paper presents tion point due to changes in its location or activation frequency;
a real-time method for adaptive clustering QRS complexes from or a conduction disorder, that is, an abnormal propagation of the
multilead ECG signals that provides the set of QRS morpholo- beat wavefront through the cardiac tissue. They both have an
gies that appear during an ECG recording. The method processes effect on the ECG, affecting the beat morphology and/or beat
the QRS complexes sequentially by grouping them into a dynamic rhythm. In order to support their identification, a method for
set of clusters based on the information content of the temporal
context. The clusters are represented by templates which evolve separating the beats by their activation point and conduction
over time and adapt to the QRS morphology changes. Rules to pattern should be provided.
create, merge, and remove clusters are defined along with tech- Beat classification arises as the task of assigning each beat
niques for noise detection in order to avoid their proliferation. To in an ECG a label identifying its physiological nature. Machine
cope with beat misalignment, derivative dynamic time warping is
learning techniques have been applied to this task by estimating
used. The proposed method has been validated against the MIT-
BIH Arrhythmia Database and the AHA ECG Database showing the underlying mechanisms that produce the data of a training
a global purity of 98.56% and 99.56%, respectively. Results show set. The main drawback of this approach is its strong dependence
that our proposal not only provides better results than previous on the pattern diversity present in the training set. Thus, interpa-
offline solutions but also fulfills real-time requirements. tient differences show that it cannot be assumed that a classifier
Index Terms—Adaptive clustering, dominant points, dynamic trained on data of a large set of patients will yield valid results on
time warping (DTW), electrocardiogram (ECG), QRS clustering. a new patient [2]–[4], and intrapatient differences show that this
cannot be assumed even for the same patient throughout time.
In addition, class labels only provide gross information about
I. INTRODUCTION the origin of the beats in the cardiac tissue, losing all the in-
OWADAYS, the surface electrocardiogram (ECG) is rec- formation about their conduction pathways. This approach does
N ognized as an invaluable tool for monitoring heart con-
dition, since its analysis provides decisive information that can
not distinguish the multiple morphological families present in a
given class, as occurs in multifocal arrhythmias.
reveal critical deviations from normal cardiac behavior. Recent In contrast, beat clustering aims at dividing the ECG recording
developments in mobile sensors and mobile computing have in a set of beat clusters, each one of them preserving some
enabled new scenarios for continuous ECG monitoring as an in- similar properties. Previous proposals have focused on an offline
expensive tool for the early detection of some cardiac events [1], approach from a priori maximum number of clusters [5]–[8] and
especially in those cases where symptoms appear intermittently. they imply processing the ECG signal once the acquisition has
As the monitoring period increases, the interpretation task been completed. This approach has given good noise robustness
becomes more time consuming and decision support tools are but as a side effect, a single morphology is usually replicated in
needed to help cardiologists to reduce the time spent on it. If a several clusters and rare beat morphologies can be missed. It also
continuous followup is required, these tools become imperative. omits the dynamic aspect of ECG and, in particular, ignores the
Their main aim is to provide the cardiologists with a summary temporal evolution of morphologies. Furthermore, the detection
of all the acquired signals, enhanced with a fast locating of those of critical events can be deferred too long to provide timely
anomalies detected. attention. For all these reasons, a dynamic online approach must
be considered.
In this paper, we present a real-time method for adaptive
beat clustering, with a potential application not only as a pre-
Manuscript received February 17, 2014; revised July 4, 2014 and September
1, 2014; accepted September 26, 2014. Date of publication October 8, 2014; date vious step for classification [9], but also as a summary about
of current version September 1, 2015. This work was supported by the Spanish those beat morphologies present in a certain period, their tem-
Ministry of Science and Innovation under Grant TIN2009-14372-C03-03. poral evolution and variability, or even to detect the presence
The authors are with the Centro de Investigación en Tecnoloxı́as da Infor-
mación, University of Santiago de Compostela, 15782 Santiago de Compostela, of alternating morphologies. The proposed method emulates
Spain (e-mail: daniel.castro@usc.es; paulo.felix@usc.es; jesus.presedo@ the experts behavior in exploiting the temporal context for
usc.es). assigning each new beat to the most appropriate cluster. To
Color versions of one or more of the figures in this paper are available online
at http://ieeexplore.ieee.org. this end, clusters are continuously adapting to the temporal
Digital Object Identifier 10.1109/JBHI.2014.2361659 evolution of beat morphologies, and they can be dynamically

2168-2194 © 2014 IEEE. Personal use is permitted, but republication/redistribution requires IEEE permission.
See http://www.ieee.org/publications standards/publications/rights/index.html for more information.
CASTRO et al.: METHOD FOR CONTEXT-BASED ADAPTIVE QRS CLUSTERING IN REAL TIME 1661

Fig. 1. Flowchart of the method proposed for QRS clustering. The different stages involved in beat processing are shown and the creation of a new cluster is
exemplified. Each block refers to the corresponding section.

created, merged or modified, resulting in a variable number of wards, the current cluster set is updated in one of three ways:
clusters. Creating a new cluster, modifying the most similar one or merg-
Beat clustering requires extracting from the ECG a set of rep- ing two or more clusters (see Section IV-E). The next stage
resentative measurements for every beat. Bibliography shows a performs a noise analysis for each lead in order to detect noisy
variety of proposals for beat representation that can be grouped intervals and avoid the processing of noisy beats or discard the
into four categories: morphological features where the signal clusters created from them (see Section V). Finally, the beats are
amplitude is directly used [2], [4], [7], [9]; segmentation fea- classified by their rhythm type and a set of groups with common
tures like area, amplitude, or interval duration from beat waves morphology and rhythm is obtained (see Section VI).
[2], [4], [7], [10] or amplitude and angle values from vector- The ECG databases have been processed and their beat
cardiogram [3]; statistical features derived using high-order cu- class labels have been used to validate the purity of the fi-
mulants [4], [11], [12]; and finally, transformed space features, nal cluster and group sets (see Section VII). These results are
defined in an alternative space using different transforms like discussed in Section VIII along with the conclusions of this
Karhunen–Loewe transform [13], Hermite basis functions [4], paper.
[5], [12], discrete Fourier transform [9], [14] or wavelet trans-
form [3], [14]. All the previous works complete their feature
sets with rhythm information to complement their description II. ECG SIGNAL DATABASES
capabilities. The ECG databases recommended by the ANSI/AAMI EC57
This paper proposes a new approach to represent a beat by [15] standard for reporting the performance of arrhythmia de-
reducing the QRS complex to a set of relevant points and sup- tectors were used for validation purposes: The MIT-BIH Ar-
port regions. This representation has some nice properties for rhythmia database and the AHA ECG database.
beat clustering: It is stable against the usual variability and the The MIT-BIH Arrhythmia database [16], [17] can be referred
presence of noise in the ECG, and it explicitly represents the to as the golden standard for beat clustering and classification
temporal location of some QRS features. tasks and it is the reference database for almost all the litera-
The proposed method processes a real-time multilead ECG ture in this field. This database is composed of 48 recordings
signal through a set of data-driven stages as shown in Fig. 1. In of ambulatory ECG, obtained from 47 different patients which
order to obtain comparable results, signals from two standard comprise a very complete set of examples of common and rare
ECG signal databases are used as data source (see Section II). arrhythmias. Each record has a duration of 30 min, and in-
The preprocessing stage comprises real-time beat detection and cludes two channels with the same leads in almost all of them:
baseline filtering (see Section III). Then, a fixed-length signal a modified-lead II (MLII) in the first one and lead V1 in the
segment is selected for extracting and characterizing the QRS second one. MLII was replaced by lead V5 in three records and
complex (see Section IV-A). QRS complexes are compared to V1 was replaced by MLII, V2, V4 or V5 on eight records. The
the current set of clusters following a context-based criteria to signals were digitized at fs = 360 Hz and bandpass filtered with
obtain the best matching cluster (see Sections IV-B–D). After- cutoff frequencies at 0.1 and 100 Hz. All beats present in the
1662 IEEE JOURNAL OF BIOMEDICAL AND HEALTH INFORMATICS, VOL. 19, NO. 5, SEPTEMBER 2015

database were annotated by at least two expert cardiologists and


assigned a class label using a 16 label set.
The AHA ECG database was compiled by the American Heart
Association and it is composed of 155 recordings of ambulatory
ECG digitized at fs = 250 Hz containing the most relevant types
of ventricular arrhythmias. Each record is 3 h long with two
channels but only the last 30 min have been manually annotated
by experts.

III. PREPROCESSING
The major drawback of processing long-term ECG sig-
nals is the presence of a high level of noise with multiple
manifestations—baseline wandering, power line interference or
electromyographic activity— so an initial filtering stage needs
to be performed. The efforts have been focused on filtering the
Fig. 2. Example of a subsequence qln for lead l = 2, of a beat at sample 4102,
baseline wandering as this is the most relevant source affect- n = 13, from record 108 of the MIT-BIH database. The relevant points detected
ing the reliability of the clustering algorithm because of the by the algorithm are marked with *. The parameters involved in the relevant
distortion it can cause on the QRS morphology. point detection are also shown.

A. Baseline Filtering morphology to characterize the beat. As a consequence, beats


The baseline filtering is performed through the estimation of with different atrial activation points or even with nodal acti-
the baseline wandering and its posterior elimination from the vation points can share the same QRS morphology and will be
original ECG. To achieve this goal, each signal is processed by assigned to the same cluster. In the absence of a P wave analysis,
two sequentially connected median filters of 200 and 600 ms, rhythm information can be useful in some cases to detect this
respectively, as described in [2]. A global delay of 400 ms is situation, as explained in Section VI.
added by this process, independently of the sampling rate. The proposed method is intended to provide a real-time re-
sume of the ECG signal as a dynamic set of clusters. When-
B. Beat Detection ever a new beat is detected, the set of clusters is updated.
Let C denote a time series C = {C1 , C2 , . . . , Cn , . . .} where
In order to carry out an evaluation of the clustering method
Cn = {Cnc | 1 ≤ c ≤ Nn } is the set of clusters that represents
separately from beat detector and provide a fair comparison
those QRS morphologies which appeared from the beginning of
framework for future algorithms, we used the beat position pro-
the recording up to the beat n, Cnc is the set of beats assigned to
vided by the ECG databases as fiducial points.
cluster c, and Nn the number of clusters, both at beat n.
A beat detector is required for real scenarios affecting the
The clustering follows a data-driven flow triggered by the beat
quality of results. However, it virtually does not increment the
detector as shown in Fig. 1. Each new beat is compared to the
global computational complexity as QRS detection represents
set of clusters Cn using concordance and dissimilarity measures
only a small fraction of it. The global delay would not be affected
in order to find the best matching and giving preference to those
either since the beat detection can be performed concurrently
in its temporal context. A detailed explanation of this process
with baseline filtering with a shorter delay.
follows in the remaining sections: First, a beat characterization
and a template-based representation of the clusters; next, the
IV. CLUSTERING alignment technique and the measures used to compare beats
In this paper, the following notation is used. Bold face vari- and clusters; afterwards, the criteria for cluster selection and,
ables (e.g., x) to represent vectors and sequences, lower case finally, the process of updating the set of clusters.
alphabets with subscripts to represent their components (e.g.,
xi ) or superscripts when a temporal index is used as a subscript
A. QRS Characterization
(e.g., xin ), upper case alphabets (e.g., X) to represent sets, and
calligraphic letters to represent functions (e.g., F). We adopt a strategy inspired by dominant point detection [18]
The aim of the clustering method is to group those beats in to characterize the QRS morphology through its constituent
real time, which share the same activation area and propagation waves. Let S = {st | st ∈ RL ∧ t ∈ N} denote a time series
pattern in the cardiac tissue. The propagation of the electrical which represents the multilead ECG signal, where L is the
impulse through the heart is reflected in the ECG as a sequence number of leads and st = (s1t , . . . , sLt ) is the vector of samples
of waves corresponding to the activity in the atria and ventri- at time t for all leads. When the nth beat is detected with fiducial
cles. P wave and QRS complex are of particular interest since mark at time t, a fixed-length subsequence of w = w− + w+
they show the atria and ventricular depolarization, respectively, samples (w− before and w+ − 1 after t) is selected from each
thereby providing a fingerprint of the conduction pathway. lead l to represent its QRS complex (see Fig. 2)
Since the noise level of ambulatory signals makes the detec-
tion of the P wave a very difficult task, we focus on the QRS q ln = {q1l , . . . , qjl , . . . , qwl } (1)
CASTRO et al.: METHOD FOR CONTEXT-BASED ADAPTIVE QRS CLUSTERING IN REAL TIME 1663

where qjl = slt−w − −1+j . We set w− = 0.1 × fs  and w+ = In consequence, adjacent support regions can now overlap.
0.2 × fs , which are wide enough to capture the longest QRS A relevant point pj is said to be in a concave wave if qj > qj −
of abnormal beats [19] (V, F, and f beat types, typically). and qj > qj + . Otherwise, it is said to be in a convex wave. The
Most of this section describes operations over one lead; thus, wave height is defined as Δpj = min(Δqj,j − , Δqj,j + ).
for the sake of notation simplicity, the l superscript will be Finally, the nth beat is represented by the QRS signal segment
obviated unless multiple leads are involved. and the set of its relevant points and support regions Pn =
We define the curvature K at qj ∈ q n as {(pj , support(pj )) | pj ∈ Rn } and denoted by
K(qj , q n ) = max cos q
i qj qk (2) Bn =< q n , Pn > . (11)
i∈I j− ,k ∈I j+
There is not a consensus in the literature about the limits for
where 2 ≤ j ≤ w − 1. The terms Ij− and Ij+ denote the intervals width and height of QRS complex or individual QRS waves.
used for calculating the curvature and they are given by The AAMI standard [20] recommends a minimum amplitude of
Ij− = {i | (j − θ) ≤ i < j ∧ 50 μV and the duration of 10 ms for a QRS wave to be detected,
and 150 μV for peak-to-peak QRS amplitude with a minimum
∀a ∈ (i, j), ( max Δqj,b − Δqj,a ) < ρm in } (3) duration of 70 ms. On the other hand, the AHA [21] and CSE
b∈(a,j )
[19] report lower amplitude for QRS waves (down to 20 μV and
Ij+ = {k | j < k ≤ (j + θ) ∧ 10 ms) based on measures over averaged beats with increased
∀a ∈ (j, k), ( max Δqj,b − Δqj,a ) < ρm in } (4) signal-to-noise ratio. These limits were not established for phys-
b∈(j,a) iological reasons but for signal noise level or instrumentation
where Δqj,x = |qj − qx |. The term θ is the maximum physi- limitations. Nothing is stated about maximum QRS width be-
ologically meaningful width of a QRS wave between its peak yond a reference to case-based duration values (e.g. the CSE
location and its left or right end so that it is the upper limit of Ij− study [19] reports a maximum QRS width of 210 ms). In our
and Ij+ . The term ρm in is the minimum height for a signal de- case, due to the signal-to-noise ratio present in the ambulatory
flection to be considered physiologically relevant and, therefore, signals, the value of ρQRS is set to 150 μV in order to avoid the
to be excluded from the calculation of curvature. detection of small waves caused by noise and the value of θ is
We define the dominance region of a sample qj as set to 100 ms to accept QRS waves with a maximum width of
200 ms. The value of ρm in is set to 50 μV following the AAMI
dominance (qj ) = [r− , r+ ] (5) standard [20] and will be useful to detect noise contaminated

where r = min(arg maxi∈I j− cos q QRS complexes.
i qj qk ) for any fixed k ∈ Ij
+

− In order to perform the comparison between a new beat Bn


and r+ = max(arg maxk ∈I + cos qi qj qk ) for any fixed i ∈ Ij . and the current set of clusters Cn −1 , each cluster Cnc −1 is repre-
j
We define the set of dominant points of q n as sented by a template
Dn = {pj | pj = qj ∧ j Tnc −1 = < q cn −1 , Pnc −1 > (12)
= arg max K(qa , q n ) ∧ Δqj > ρm in } (6)
a ∈ dom inance(q j ) where q cn −1 = {q1c , . . . , qwc } is derived from the QRS of the
beats assigned to Cnc −1 as will be explained in Section IV-E.
where Δqj = min(Δqj,r − , Δqj,r + ).
We define the set of relevant points of q n as
B. QRS Temporal Alignment
Rn = {pj | pj ∈ Dn ∧ Δqj > ρQRS } (7) In order to compare a beat Bn with a cluster template Tnc −1 , a
where ρQRS is the minimum height for a signal deflection to be temporal alignment of q n and q cn −1 is performed using dynamic
considered a relevant QRS wave with ρQRS > ρm in . If Rn = , time warping (DTW) [22]. The aim of this alignment process
then it is redefined as Rn = {arg maxp j ∈D n Δqj }. is twofold. First, to correct any temporal misalignment due to a
The limits of dominance (qj ) can be located at any point in misplaced fiducial mark and second, to reduce the contribution
the edge of a wave. Since we are interested in capturing its full of the height and width variability of the QRS waves to the
extent, the support region of a relevant point pj ∈ Rn is defined dissimilarity measure.
as DTW was previously used for this purpose in [6], provid-
ing a relation m = (m1 , . . . , mK ) between q n and q cn −1 called
support(pj ) = [j − , j + ] (8) warping path, with mk = (xk , yk ) ∈ [1, w] × [1, w], k ∈ [1, K]
where j − ≤ r− and j + ≥ r+ are the sample numbers nearest to and K ≥ w. Each mk represents the alignment of the index xk
r− and r+ where slope sign changes of q n with the index yk of q cn −1 under three conditions: First,
m1 = (1, 1) and mK = (w, w); second, xi ≤ xk and yi ≤ yk
j − = min− ({i | i ≤ r− ∧ ∀a ∈ [i, r− ], Δqj,a > Δqj,a+1 }) (9)
i∈I j ∀i < k; and third, mk +1 − mk ∈ {(1, 1), (1, 0), (0, 1)}. These
conditions preserve the time-ordering of points and prevent
j + = max
+
({k | k ≥ r+ ∧ ∀a ∈ [r+ , k], Δqj,a < Δqj,a+1 }). some point being missed in the alignment.
k ∈I j
Let G denote the cost function associated to a warping path de-
(10) fined by G(m) = K k =1 Gl (xk , yk ), where Gl (x, y) = |qx − qy |
c
1664 IEEE JOURNAL OF BIOMEDICAL AND HEALTH INFORMATICS, VOL. 19, NO. 5, SEPTEMBER 2015

is the local cost function associated with each element of m.


The optimal warping path is the one that minimizes G.
DTW aligns the original signal samples, so any component
k from m where mk +1 − mk ∈ {(1, 0), (0, 1)} introduces a
horizontal segment into the aligned signals. Since this can lead
to unacceptable distortion of the QRS, we adopt the derivative
dynamic time warping (DDTW) [23], which uses the estima-
tion of the derivative instead of the signal itself. The derivative
is approximated by the first difference q̇ n = (q̇1 , . . . , q̇w −1 )
and q̇ cn −1 = (q̇1c , . . . , q̇wc −1 ) with q̇x = qx+1 − qx and q̇yc =
qyc +1 − qyc .
We imposed some additional conditions on the selected warp-
ing path so as to restrict the alterations of aligned signals.
A global restriction is set in the search process by defining a
warping window δ (named Sakoe-Chiba band [22]) to limit the
temporal distance between aligned samples so |xk − yk | < δ.
We set δ = 5, which corresponds to a distance of 14 ms with
fs = 360 Hz, and is long enough to deal with small misalign-
ments of beat marks. A local restriction is also used to limit
the number of times the same sample can be aligned, setting a
slope constraint: mk +a − mk ∈ / {(0, a), (a, 0)} ∀a > λ. We Fig. 3. Example of the DDTW alignment process. For each figure, the upper
set λ = 2 to limit the variation in the amplitude of the aligned solid and dashed lines represent the beat and template data, respectively; bottom
solid lines represent their absolute difference. (a) Shows qn and qcn −1 subse-
signals. Both conditions together allows the DDTW to cancel quences; (b) q̇n and q̇cn −1 derivative approximations; (c) optimally aligned
out wave differences up to three times in amplitude and up to δ derivatives of length K ≥ w − 1; (d) subsequences  qn and 
c
qn −1 of length
samples in width. K + 1 obtained from the optimally aligned derivatives. In (b) and (c), the dif-
Finally, after the optimal warping path m is found, the aligned ference is equivalent to the local cost function Gl (x, y) = |q̇x − q̇yc |. Notice the
temporal increment K − w in (c) and (d) as a result of the process. The absolute
signals q n and q cn −1 are obtained with coordinates qk +1 = qk + difference may also be increased in (d) outside the support regions but this is
q̇x k and qkc +1 = qkc + q̇yc k for k ∈ [1, K], where q1 = q1 and irrelevant.
q1c = q1c . Fig. 3 shows the result of the alignment of the current
QRS complex and a template.

C. Template Matching
In order to assign a beat Bn to an existent cluster Cnc −1 , we
design a similarity calculation that only considers the differ-
ence between signals over the support region of each relevant
point; thus, limiting the comparison to the constituent waves
of the QRS. Given a pair (pj , [j − , j + ]) ∈ Pn , we are interested
in verifying whether Tnc −1 contains a similar wave in the same
location of the QRS. In order to do so, the interval [ǰ − , ǰ + ]
of q cn −1 aligned with the interval [j − , j + ] of q n must be ob-
tained (see Fig. 4). To this end, the warping path m is used
to map j and [j − , j + ] from q n into q n obtaining the equiv-
alent index j for the relevant point, and [
 j−,  j + ] for its sup-
  −
port region where j = max{k | xk = j}, j = min{k | xk =
j − }, and j + = max{k | xk = j + }, being (xk , yk ) ∈ m. After-
wards, since q n are already aligned by the application
cn −1 and q
of DDTW, the same interval [ j−, 
j + ] from q cn −1 is selected and
mapped into q n −1 using the warping path. The interval [ǰ − , ǰ + ]
c Fig. 4. Parameters involved in calculating the concordance and local dissimi-
larity of a cluster with respect to a beat at a relevant point p j . Solid and dashed
is given by ǰ − = yj − and ǰ + = yj + . lines represent beat and template data, respectively. (a) Shows parameters in-
Once the aligned intervals are obtained, we proceed to volved in concordance checking; the support region [j − , j + ] and the derived
evaluate the concordance of both vectors. The segment intervals [j−,j + ] and [ǰ − , ǰ + ] are drawn; (b) signal segments within the inter-
q cn −1 is said to concord with q n at pj and denoted by val [
j −, 
j +] with a vertical alignment performed in the subintervals [ j−,j ] and
q cn −1 ≈p j q n if q cn −1 contains a deflection in [ǰ − , ǰ + ] with [
j, + − +
j ] independently; ΔA j and ΔA j areas are shaded; (c) the same signal
height Δpcǰ > ρm in likely to be considered a significant segments shown in (b) with A − +
j and A j areas shaded.

waveform where Δpcǰ = min(|qpc eak − q− c


|, |qpc eak − q+ c
|) being
CASTRO et al.: METHOD FOR CONTEXT-BASED ADAPTIVE QRS CLUSTERING IN REAL TIME 1665

peak = arg mini∈[ ǰ − , ǰ + ] qic , q−


c
= maxi∈[ ǰ − ,p eak] qic and q+
c
= as the local dissimilarity increases and, as a consequence, the
c
maxi∈[p eak,j + ] qi for pj in a convex wave [see Fig. 4(a)]. Oth- weight of a high dissimilarity value in the final piecewise dissim-
erwise, min and max functions are interchanged. ilarity. We limit the contributions of those points out of a range
We define the concordance ratio of q cn −1 with respect to q n of admissible local dissimilarity. In order to set such range, we
at pj , denoted by Cp j (q cn −1 , q n ), as consider the effect of amplitude and temporal variability of QRS
waves. A temporal misalignment of one signal sample between
min(Δpj , Δpcǰ )
Cp j (q cn −1 , q n ) = (13) the QRS waves of qn and qnc −1 can lead to local dissimilarities of
max(Δpj , Δpcǰ ) around 20%. Then, we set an interval of [0, 25%] with a slightly
greater upper bound and α = 4 so the maximum contribution
if q cn −1 ≈p j q n . Otherwise, Cp j (q cn −1 , q n ) = 0. out of this interval is 0.30.
We define the local dissimilarity of q cn −1 with respect to q n at The previous measure is asymmetric since it depends on the
pj , and denoted by Dp j (q cn −1 , q n ), as a weighted relative area relevant points and areas of one signal, so we define the simi-
difference between q cn −1 and q n at the interval [ j−, j+ ] larity between Bn and Tnc −1 as
 
(ΔA− j )
2
(ΔA+ j )
2
1 S(q n , q cn −1 ) = PS(q cn −1 , q n ) + PS(q n , q cn −1 ) (20)
Dp j (q n −1 , q n ) =
c
+ × − .
A−j A +
j A j + A+
j thus, obtaining a value which captures the concordance, simi-
(14) larity, and morphological complexity of both signal segments.
The terms ΔA− j and ΔA +
j represent the areas under a = This measure allows us to select the most similar template
qn − q
| −   
n −1 | over the intervals [j , j] and [j, j ], respectively,
c +
within a set but we need a reference scale to evaluate the degree
[see Fig. 4(b)]. Computing the area at each side of  j indepen- of matching. To this end, we define the normalized piecewise
dently allows us to minimize the effect of vertical misalignment similarity as
or amplitude variation on each interval by subtracting their own
PS(q cn −1 , q n ) = PS(q cn −1 , q n )/|Rn | (21)
median. Using the trapezoidal rule
 1 and the normalized similarity as
ΔA− j = ak + (aj − + aj ) − ( j −j − )M − (15)
2 S̄(q n , q cn −1 ) = S(q n , q cn −1 )/(|Rn | + |Rnc −1 |) (22)
k ∈(j ,j )

 1 where Rnc −1 is the set of relevant points of q cn −1 .


ΔA+
j = ak + (aj + aj + ) − (
j+ − 
j)M + (16)
2
k ∈(j ,j + ) D. Cluster Selection
− +
where M = mediank ∈[j − ,j ] ak and M = mediank ∈[j ,j + ] ak . The occurrence of different QRS morphologies in a seg-
The terms A−
and
j A+
j represent the areas below [
j−,  j] and ment of ECG signal is usually limited by a reduced set of
  activation points and conduction pathways. Thereby, we ex-
+
[j, j ] intervals of qn , respectively [see Fig. 4(c)]. They are
pect that the majority of QRS complexes in an ECG record-
estimated using the trapezoidal rule
  ing share their morphology with some of the QRS complexes
  present in a short previous temporal interval. For that rea-
  1 
A− =  q + (
q + 
q ) − (
j − 
j − −
)
q son, the search for the cluster Cnwin −1 ∈ Cn −1 that best matches
j  k
2
j − j  (17)
 k ∈(j ,j )
−  a beat Bn is first performed in the set of clusters present
  in its temporal context Cnctx −1 ⊂ Cn −1 (see Fig. 5). We de-
  
 1  fine the temporal context as the set of τ beats previous to
A+ =  
q + (
q + 
q ) − (
j +
− 
j)
q +
j  k
2
j j +  (18) Bn , τ –ctx− (Bn ) = {Bn −i | 1 ≤ i ≤ τ } and Cnctx −1 = {Cn −1 ∈
c
k ∈(j ,j + )  −
Cn −1 | ∃Bi ∈ τ –ctx (Bn ) ∧ Bi ∈ Cn −1 }. The context length
c

is set to τ = 15 beats, the number of beats displayed in the


where q− = maxk ∈[j − ,j ] qk and q+ = maxk ∈[j ,j + ] qk for pj in
typical 10 s ECG strip used by cardiologists for a heart rate of
a convex wave. Otherwise, max is replaced by min.
80 beats/min. This context is long enough to include every QRS
We define the piecewise similarity of q cn −1 with respect to
morphology present in multifocal arrhythmias. Throughout this
q n , denoted PS(q cn −1 , q n ), as the sum of two bounded contri-
section, the l superscript is used to denote the lead.
butions from the set of concordant and nonconcordant relevant
The similarity measure is used to identify the most simi-
points
 lar template for each lead as siml = arg maxc S(q ln , q c,l n −1 ) and
PS(q cn −1 , q n ) = Cp j (q cn −1 , q n ) . sig(Dp j (q cn −1 , q n )) then the best matching cluster is obtained by majority vote as
p j ∈R n sim = mode{siml | l ∈ [1, L]}. If multiple clusters are selected,
a second vote is performed to obtain a single one using the nor-
− max Dp j (q cn −1 , q n ) (19) malized similarity.
p j |q cn −1 ≈p j q n
sim ,,l
Beat Bn is assigned to Cnsim−1 if the condition S̄(q n , q n −1 ) >
l

where the sigmoid function sig(x) = 1 − αx/ 1 + (αx)2 win sim
γ is fulfilled in all leads. Then Cn −1 = Cn −1 . We set a value of
keeps the contribution of each point in the interval [0, 1]. The γ = 0.30, which corresponds to the maximum contribution of a
parameter α determines the decrease rate of the contribution point with local dissimilarity outside the admissible interval.
1666 IEEE JOURNAL OF BIOMEDICAL AND HEALTH INFORMATICS, VOL. 19, NO. 5, SEPTEMBER 2015

90% of the contributions to the current template. This allows


the template to be adapted to the evolution of the QRS morphol-
ogy. Afterwards, the set of relevant points and support regions
Pnwin,l is obtained from q win,l n and assigned to the template:
Tnwin,l = < q win,ln , Pnwin,l >.
3) Cluster Merging: During the clustering process, different
clusters can evolve to represent the same QRS morphology so
they should be merged. This situation is common when QRS
complexes suffer from transient distortions in their morphology
due to intrinsic variability, which makes them fall below the
similarity threshold for their proper clusters. In this case, a new
cluster is created which is subjected to an initial transient period
during which the template for each lead can evolve getting closer
to its most similar cluster.
In order to detect this situation, we define a relation closest
which links each cluster with its most similar one among pre-
vious clusters. The relation is set for each new cluster as
Cnwin = closest(Cnnew ). As templates evolve with new assigned
QRS complexes, the relation could have to be updated.
When Bn is assigned to Cnwin −1 , the cluster is updated to Cn
win

and its most similar cluster may change. The closest relation is
updated when multiple clusters in the same set than Cnwin −1 , be it
either Cnctx −1 or C n −1 − C ctx
n −1 , fulfill the assignment condition
Fig. 5. Flowchart of the cluster selection and cluster set updating processes. S̄(q ln , q c,l
n −1 ) > γ in all leads (see Section IV-D). Since Cn has
been updated, getting more similar to Bn , the best matching
cluster Cns −1 for Bn is selected within the remaining subset of
L c,l
l=1 S(q n , q n −1 )/L)
l
When Bn and Cnsim clusters, where s = arg maxC nc −1 = C nw −1 in (
−1 are not similar enough, a new comparison
is performed within the subset Cn −1 − Cnctx −1 , obtaining the most and the oldest of both clusters, Cnwin s
−1 or Cn −1 , is set as the
∗ sim ∗ new most similar cluster for the other. Then, the clusters Cnwin
similar cluster Cnsim
−1 . If B n and C n −1 are similar enough, the
sim ∗ and Cns are checked for possibly merging, since their templates
beat is assigned and Cnwin −1 = Cn −1 . Otherwise, the beat is not
assigned to any existing cluster and its most similar cluster have evolved to be similar enough to the last beat (see Fig. 5).
sim ∗
Cnwin sim
−1 is selected between Cn −1 and Cn −1 using the same voting The condition for merging those clusters will be analogous to
criteria previously seen. the condition for beat assignment: S̄(q s,l win,l
n , qn ) > γ  , where

γ = 0.40, which corresponds to the maximum contribution of
E. Cluster Set Updating a point with local dissimilarity over 20%. The threshold value
is increased with respect to γ since both signal segments are
In order to adaptively respond to the changing behavior of promediated templates with increased signal-to-noise ratio.
the ECG, clusters must be dynamically created, modified, or Afterwards, the special case of clusters within its transient
merged whenever a new beat is detected. period is considered. We establish the duration of this transitory
1) Cluster Creation: If Bn is not assigned to Cnwin −1 , a new state in terms of the number of assigned beats. Hence, if Bn
cluster Cnnew is created and its template is initialized for each is assigned to Cnwin −1 and |Cn | < μ, the cluster is checked for
win
lead using the beat representation: Tnnew ,l = Bnl . Then the clus- merging with its closest one Cns = closest (Cnwin ) (see Fig. 5).
ter set is updated as Cn = Cn −1 ∪ {Cnnew }. We set μ as the minimum number of beats assigned to the
2) Cluster Modification: If Bn is assigned to Cnwin −1 , then the cluster to confirm, it represents an independent morphology and
cluster is updated to Cnwin = Cnwin −1 ∪ {B n } and the template we consider μ = 10 enough for this purpose.
win,l win,l win,l win,l
Tn −1 = < q n −1 , Pn −1 > is modified to Tn for each lead. When two clusters Cnwin and Cnc are merged, the cluster set,
To this end, q nwin,l is calculated from q ln and q win,l
n −1 cluster template, and closest relation are updated accordingly
win,l (we suppose that Cnc = closest (Cnwin )).
,n = (1 − β)q̇y ,n −1 + β mean({q̇x,n | (x, y) ∈ m})
q̇ywin.l l
1) Cnc is updated to Cnc = Cnc ∪ Cnwin .
c,l
(23) 2) q c,l
n is calculated by merging q n −1 and q n
win,l

qywin,l
,n = qywin,l
−1,n + q̇ywin,l
,n (24) 
q̇yc,l,n = (1 − β)q̇yc,l,n +β win,l
({q̇x,n | (x, y) ∈ m}) (25)
win,l win,l
where q1,n
= q1,n
The term β is the coefficient of the
−1 .
exponential update. Setting a value for β implies a tradeoff qyc,l,n = qyc,l−1,n + q̇yc,l,n (26)
between plasticity and stability of the cluster template. We set
c,l
β = 1/8 so the last 16 beats assigned to the cluster provide where q1,n remains unmodified.
CASTRO et al.: METHOD FOR CONTEXT-BASED ADAPTIVE QRS CLUSTERING IN REAL TIME 1667

3) The template is modified to Tnc,l = < q c,l c,l


n , Pn >, where branch block beats. Additionally, if |Rnl | > η, the QRS complex
c,l
Pn is the set of relevant points and support regions ob- is considered distorted with relevant waves caused by noise. If
tained of q c,l
n . this happens in some but not all leads, such leads are ignored for
4) The closest relation is updated by removing the cluster assignment and updating, but if it happens in all leads,
(Cnc , Cnwin ) pair and replacing Cnwin by Cnc in all the pairs the beat is considered failed and it is assigned to its most similar
where the former appears. cluster.
After the cluster Cnwin gets merged, all the modified pairs of The context-based noise detection is activated when a new
the closest relation are checked for merging. Afterwards, the cluster is created for Bn . Then two possible explanations are
Cnc cluster is also checked for merging with its closest one. explored. A first explanation represents a hypothesis of noise
and every noisy beat will be assigned to its most similar clus-
ter. A second explanation simply represents a change in mor-
V. NOISE-CLUSTER PROLIFERATION CONTROL phology, so creation of new clusters is allowed. The evalu-
ation of these hypothesis is performed over a temporal con-
The dynamic creation of clusters entails the problem of iden- text of τ beats defined as τ –ctx+ (Bn ) = {Bn +i | 0 ≤ i <
tifying those QRS complexes contaminated by noise that could τ } which is long enough to check the evolution of cluster
cause the proliferation of clusters. When noise appears in an diversity.
ECG lead, the QRS can show different changes. In some cases, A hypothesis of noise, denoted by hyp noiseln +i , is set over
ECG segments with low signal-to-noise ratio present a high each lead for every beat Bn +i ∈ τ –ctx+ (Bn ). The hypothe-
number of waves, and these can be detected by an abnormal sis is initialized using the current noise state for the first beat,
number of dominant points. In other cases, domain knowledge hyp noiseln = lead noiseln −1 , and the value of the previous
is needed to discern if changes respond to a new QRS morphol-
beat for each new one, hyp noiseln +i = hyp noiseln +i−1 . This
ogy or to a noisy version of a previous one. Some alterations
value can be further modified for a beat Bn +i under three cir-
are well known and described in the literature, but others can
cumstances.
be challenging even for an expert cardiologist, who compares
1) If Bn +i is considered noisy in lead l by the beat-based
every beat with those present in its temporal context in order
noise detection, beat noiseln +i = true, then the hypoth-
to identify if it is related to a repetitive morphology change, a
esis is set to hyp noiseln +i = true.
noisy interval, or an isolated noisy beat. We follow a twofold,
2) If a new cluster is created for Bn +i , we define Lnoise n +i
beat-based and context-based, approach to detect noisy QRS
complexes. Noise can be present in one or more leads, and the as the set of leads with S̄(q ln +i , q win,l
n +i−1 ) ≤ γ, which are
influence of each lead in the clustering of a given beat will be responsible for its creation and candidates to be set as
analyzed in the following. noisy. For these leads, we check the assignment under
A state variable lead noiseln is defined to denote the exis- noisy interval conditions, PS(q ln +i , q win,l
n +i−1 ) > γ. If the
tence of a noisy interval in lead l containing the nth beat. Such assignment condition is now fulfilled in all leads, the sig-
noisy interval begins when the first noisy beat is detected in nal still resemble a previous QRS morphology and we set
that lead just after a sequence of previous noise-free beats. The hyp noiseln +i = true ∀l ∈ Lnoise n +i .
beats contained within this interval can be either noisy or noise 3) If Bn +i is the last of κth consecutive noise-free beat, we
free in l and such condition will be represented as an attribute set hyp noiseln +i−j = f alse ∀j ∈ [0, κ − 1].
of the beat denoted by beat noiseln . During the noisy interval, Once the τ beats have been processed, the detection of noisy
the characterization of any new beat Bn can represent not only leads is addressed. Let Cnctx−new
+τ −1 denote the set of new clusters
QRS waves but also noise artifacts, so the cluster selection and created in τ –ctx+ (Bn ). If |Cnctx−new
+τ −1 | > τ /3, we consider that
assignment rules (Section IV-D) are modified in lead l: The dom- an abnormal cluster proliferation exists since the appearance of
inant points of the beat are ignored, replacing S(q ln , q c,l more than five new QRS morphologies within an interval of 15
n −1 ) by
beats is an extremely rare condition. Hence, any lead l that is
PS(q ln , q c,l
n −1 ) and S̄(q l
, q c,l
n −1 ) by PS(q l
, q c,l
n −1 ). Therefore,
n n
a common cause of creation, that is, l ∈ Lnoise n +i , for all i such
the condition for beat assignment is PS(q ln , q win,ln −1 ) > γ. that Bn +i ∈ Cnc +i ∧ Cnc +i ∈ Cnctx−new
+τ −1 , is discarded as noisy,
The ending of a noisy interval in lead l is set just before κ = 3
setting hyp noiseln +i = true ∀i ∈ [0, τ − 1].
contiguous beats are considered noise free in that lead. A beat
Finally, the hypothesis is reviewed for every beat Bn +i ∈
Bn is considered noise free if beat noiseln = f alse and it is
τ –ctx+ (Bn ) which caused the creation of a new cluster so
assigned either to its winner cluster with S̄(q ln , q win,ln −1 ) > γ or as to decide about its noisy condition. If hyp noiseln +i = true
to a new cluster.
∀l ∈ Lnoise l
n +i then we set beat noisen +i = true, the created clus-
The beat-based noise detection is triggered when a new beat
ter is deleted and its beats assigned to its closest cluster. After-
Bn is detected. Then, the number of waves in the QRS is es-
wards, lead noiseln +i is updated for the whole τ –ctx+ (Bn )
timated as |Dnl | for each lead l. If |Dnl | > η, Bn is considered
noisy in lead l and beat noiseln is set to true. The term η is the using the beat noiseln +i data to set the beginning and ending
maximum number of waves that could be present in a noise-free of noise intervals for each lead. The resulting lead noiseln +τ −1
QRS. We set η = 6 to admit complexes with Q, R, and S waves, is the new noise state used in the analysis of the subsequent
mixed with R , S or spikes as occurs in paced, fusion, or bundle beats.
1668 IEEE JOURNAL OF BIOMEDICAL AND HEALTH INFORMATICS, VOL. 19, NO. 5, SEPTEMBER 2015

TABLE I
RULES FOR RHYTHM LABEL SELECTION

Rhythm label for the previous beat

ΔRRn GP P N− N N+ C D

∈ (3
σ n , ∞] D6 D2,6 D D 1 |1 0 D 2 |1 1 D D
C C N+ N+
∈ (2
σ n , 3
σn ] C C N+ N+ N+ D5,6 D 6 |9
N+ N+
∈ [−2
σ n , 2
σn ] N N N N N N N
σ n , −2
∈ [−3 σn ) GP 8 N −1 N− P 3,4,6 N− P6 P4
N− GP GP 3,8 GP 8 N−
N− N−
∈ [−∞, −3
σn ) GP GP P 3,4,7 P 3,4,7 P4 P 4,7 P4
GP 3,12 GP 3 GP GP GP
N− N−

1. R R n > R R n− + 4σn 2. R R n > R R n− + 3 σn


3. R R n < R R n− − 3σn 4. R R n < R R n+ − 3 σn

n + 3
5. R R n− > NN σn
n + 3
6. R R n+ > NN σn
Fig. 6. Excerpt of the temporal evolution of RR distance for record 117 of
n − 3
7. R R n+ > NN σn
n − 3
8. R R n+ < NN σn
MIT-BIH database is shown. Solid points and squares represent normal and
n − 2
9. R R n+ > NN σn 10. R R n+ > R R n− + 4 σn
n and the dotted
premature beats, respectively. The solid line represents NN 11. R R n+ > R R n− + 3σn 12. R R n+ < R R n− − 3 σn
lines enclose the ±2
σ n and ±3σ n intervals.
n . The superscripts refer the conditions listed below and
Δ R R n stands for R R n − NN
used when multiple candidate labels exist. They impose a minimum distance between
normal and premature or delayed beats. The precedence of label candidates is set by order
VI. RHYTHM ANALYSIS of appearance.

The absence of an analysis of the P wave leads to the inability then the context in T C is repeatedly moved forward one beat
to discriminate premature, normal, or ectopic beats which share until T CN = ∅ for a context τ –ctx− (Bτ +1+i ). Finally, we set
a common QRS morphology. All previous clustering proposals
n = T C N and σ
NN n = σT C N ∀n ∈ [1, τ + 1 + i].
include rhythm information within their beat characterization
and claim its separation capabilities for this kind of arrhyth-
mias. In order to make our results comparable, we include a B. Rhythm Labeling
rhythm processing stage that allows us to separate those beats The aim of rhythm processing is the discrimination of those
into different groups. abnormal RR values associated with arrhythmic beats from the
normal ones. To this end, the rhythm of the Bn beat is charac-
A. RR-Interval Characterization terized through a vector rr n = (RRn , RRn− , RRn+ , NN
n, σ n )
− +
The beat-to-beat interval (RR) between normal beats, com- where RRn and RRn are the RR values for the previous and
monly known as NN interval, is the result of a nonstationary next beat, respectively. Then, the model described in the previ-
stochastic process regulated by the sympathetic and parasym- ous section is used to establish a range of validity for the RRn
pathetic nervous systems. This implies that the RR value for value which allows us to detect any alteration in the normal
beat Bn , denoted by RRn , should be put in context using the rhythm.
rhythm of the surrounding beats to analyze its normality. To We use seven rhythm labels to discern between four beat
this end, we model the NN series as a stochastic process with rhythm types: Normal, with (C) or without (N , N − , N + ) com-
marginal distribution N̄ (NN n , σn2 ) at the nth beat. The mean is pensatory pause, premature (P ), group of prematures (GP ),

n = θRRn −1 + (1 − θ)NN
estimated as NN
n −1 , with θ = 0.2 and delayed (D). The explicit domain knowledge contained in
for RRn −1 values labeled as normal (as explained in next sec- Table I models, for each rhythm type, the relation of an RR

n = NN
n −1 . The standard deviation is value with the normal rhythm from its temporal context. It also
tion). Otherwise, NN

i using the last τ beats with reflects the dependence of the rhythm type for an RR value on
estimated as σn = i NNi − NN
2
the rhythm type of its adjacent beats. This model allows us to
normal rhythm. Fig. 6 shows the evolution of the RR in an ex-
assign a rhythm label to the beat Bn based on the rrn values
cerpt with a premature beat from the record 117 of the MIT-BIH
and the rhythm label of the previous beat.
database to illustrate this point.
The first complete context, τ –ctx− (Bτ +1 ), is used to ini-

n and σ
tialize NN n . Let T C denote the set of the first τ
VII. RESULTS
values of RR and let Ki denote any subset of RR val- We have applied our clustering method to all the records
ues from consecutive beats. A value RRj ∈ T C is said to of the MIT-BIH database. The parameters and threshold val-
be normal if ∃Ki such that RRj ∈ Ki ∧ σK i < 0.1, where ues of this method have been neither trained nor adjusted to fit
σK i is the normalized standard deviation of the Ki set. Let this database. These values have been justified by physiological
T CN = {RRj | RRj is normal}. If T CN = ∅, then T CN = reasons, or by the expertise or intuition of experienced cardiol-
{RRj | RRj ∈ [T C − 2σT C , T C + 2σT C ]}, where T C and ogists. The method shows low sensitivity to small changes in
σT C are the mean and standard deviation of T C. If T CN = ∅, parameter values; the results either improve or worsen slightly.
CASTRO et al.: METHOD FOR CONTEXT-BASED ADAPTIVE QRS CLUSTERING IN REAL TIME 1669

TABLE II computation time for the different stages. Only the baseline
NUMBER OF CLUSTERS PER RECORD IN MIT-BIH DB
filtering and rhythm labeling stages present an intrinsic latency
due to noncausality: 400 ms and one beat, respectively. Since
Rec. N NR R NcR R Rec. N NR R NcR R
they both are executed concurrently, their contribution to the
100 4 7 7 201 15 32 10 delay is given by the maximum of both. The time complexity of
101 4 6 6 202 9 18 18 the method is constant in all stages but two: QRS alignment and
102 10 13 13 203 33 87 25
103 10 12 12 205 14 20 20
template matching. In both cases, time complexity is constant
104 16 25 25 207 61 96 25 for the best case, corresponding to beats assigned to a cluster in
105 10 16 16 208 28 63 22 the context; this happens in 95.35% of the total number of beats
106
107
27
11
49
21
18
21
209
210
10
27
26
65
9
13
in MIT-BIH database. Time complexity is linear (O(|Cn |)) for
108 22 35 7 212 5 8 8 the worst case, which corresponds to beats assigned to a new or
109 13 18 18 213 17 29 11 an out-of-context cluster, representing the remaining 4.65% of
111 8 10 10 214 21 36 11
112 4 7 7 215 16 32 8
the total number of beats. Given the high degree of parallelism
113 5 9 9 217 28 50 19 in both stages and the computational cost of processing a single
114 8 13 13 219 14 24 24 cluster, it can be guaranteed that a beat is clustered before the
115 11 11 11 220 2 5 5
116 10 15 15 221 14 24 24
next one arrives even with a set of hundreds of clusters. In order
117 4 5 5 222 8 19 19 to support this claim, the MIT-BIH Arrhythmia database was
118 3 8 8 223 23 43 17 processed with a nonoptimized, nonparallelized MATLAB im-
119 6 13 13 228 14 25 25
121 5 7 7 230 3 5 5
plementation of the method using a single core of an Intel Q9550
122 1 1 1 231 5 6 6 CPU. The following computation times for a single beat were
123 3 5 5 232 4 9 9 obtained: QRS characterization (maximum, mean): 4 ms, 3 ms;
124 14 18 18 233 24 48 15
200 20 46 16 234 5 7 7
cluster set selection: 323 ms, 16 ms; cluster set updating: 110 ms,
5 ms; noise analysis: 9 ms, <1 ms; and rhythm-based labelling:
N column indicates the number of clusters created using QRS mor- 10 ms, 5 ms. Globally, the whole method summed a maximum
phology; NR R , the number of groups after using rhythm labels; of 358 ms and mean of 32 ms. Additionally, reducing groups
and NcR R , the number of groups after the merging process.
for validation required a maximum of 190 ms.

Although better results could be obtained by a fine tuning of B. Clustering Performance Measures
these parameters for each specific database, this is not the aim
of this paper but proving the validity of the present approach for Purity is usually used to measure the goodness of a clustering
continuous ECG monitoring. method. Nevertheless, in a multiclass problem like this one, after
For each record, a set of clusters is obtained reflecting the QRS characterizing the clusters, the values of sensitivity (Se), positive
morphologies present in them. Afterwards, the rhythm labels predictivity (+P), and false positive rate (FPR) should also be
are used to split each cluster into groups of beats with the same provided for each class, in order to obtain a multidimensional
rhythm type. In order to compare our results with the proposal measure of the quality of the results from the perspective of each
in [5] under equivalent conditions, we adopted a fixed number class involved. A global purity of 98.56% is obtained for MIT-
of clusters (25) as the maximum number of groups. Thus, if that BIH Arrhythmia database (98.84% with AAMI class labels)
limit is exceeded for a record, a merging process is applied to and a 99.56% for the AHA ECG database. The other values are
obtain a reduced set of groups with the most prevalent rhythm shown in the last row of Tables III–V.
and morphologies. If necessary, we keep merging the groups
with the lowest number of assigned beats until the maximum is VIII. DISCUSSION AND CONCLUSION
reached. Table II shows the results before and after the merging
process. We propose a new clustering method to dynamically separate
Each group is labeled with the majority class label of the beats QRS morphologies as they appear in a multichannel ECG sig-
assigned to this group from the database. An assigned beat is nal, representing them with a dynamic number of clusters. This
considered as correctly grouped if the class label in the database objective has not been previously addressed in the literature and
match the label of the group. A confusion matrix is obtained only some partial solutions can be found; all of them restricted
for each record comparing both labels for every beat. These to offline processing [5]–[7] and some of them even limited
matrices are summed to obtain the global confusion matrix for to single channel signals and to a fixed subset of beat classes
the whole validation set shown in Table III. Table IV shows the [6], [7].
results using the AAMI class labels obtained from MIT-BIH The performance of the QRS clustering technique without
labels as described in [15]. Table V shows the results on AHA using rhythm data shows a global purity of 97.15% and 99.43%
database. for MIT-BIH and AHA databases, respectively. This confirms
the validity of our approach since no method, as far as we know,
neither offline nor online, achieve this performance without us-
A. Real-Time Considerations ing RR derived information. As expected, the main source of
The proposed method processes an ECG recording with error is the group of supraventricular classes A, N, J, j, and e,
a bounded time delay comprising the intrinsic latency and that can only be separated using P wave and rhythm information.
1670 IEEE JOURNAL OF BIOMEDICAL AND HEALTH INFORMATICS, VOL. 19, NO. 5, SEPTEMBER 2015

TABLE III
CONFUSION MATRIX RESULTING FROM CLUSTERING MIT-BIH ARRHYTHMIA DATABASE

N L R a V F J A S E j / e f Q !

N 74618 0 3 15 167 108 11 196 2 1 60 1 15 38 9 0


L 0 8059 0 0 1 2 0 0 0 0 0 0 0 0 2 0
R 32 0 7245 0 1 3 29 8 0 6 6 0 0 0 0 4
a 7 0 0 120 1 0 1 2 0 0 5 0 0 0 0 0
V 131 1 0 11 6848 83 0 20 0 0 0 0 0 1 4 6
F 26 0 0 2 56 606 0 2 0 0 0 0 0 0 0 0
J 1 0 0 0 0 0 42 0 0 0 0 0 0 0 0 0
A 44 4 3 2 25 0 0 2317 0 0 0 0 1 0 0 59
S 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
E 0 0 2 0 10 0 0 0 0 93 0 0 0 0 0 0
j 145 0 0 0 0 0 0 0 0 0 158 0 0 0 0 0
/ 9 0 0 0 1 0 0 0 0 0 0 7010 0 127 0 0
e 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
f 9 0 0 0 5 0 0 0 0 0 0 13 0 816 15 0
Q 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0
! 0 8 0 0 12 0 0 0 0 6 0 0 0 0 0 403
Se 99.46 99.84 99.89 80.00 96.09 75.56 50.60 91.04 0.00 87.74 69.00 99.80 0.00 83.10 9.09 85.38
+P 99.17 99.94 98.79 88.24 96.38 87.57 97.67 94.38 - 88.57 52.15 98.08 - 95.10 100.00 93.94
FPR 1.79 0.00 0.09 0.01 0.25 0.08 0.00 0.13 0.00 0.01 0.13 0.13 0.00 0.04 0.00 0.02

The first row corresponds to the annotation labels of the database, and the first column, to the dominant annotation label in the clusters. Se, + P , and F P R denote
the sensitivity, positive predictivity, and false positive rate for each beat class, respectively.

TABLE IV TABLE V
CONFUSION MATRIX FOR MIT-BIH DB USING AAMI CLASS LABELS CONFUSION MATRIX FOR AHA ECG DATABASE

N S V F Q N V F E / Q

N 89957 342 176 113 50 N 318739 472 138 7 16 150


S 204 2648 26 0 0 V 229 32090 217 0 9 66
V 134 31 6951 83 5 F 33 115 885 0 16 1
F 26 4 56 606 0 E 0 0 0 5 0 0
Q 18 0 6 0 7984 / 5 23 26 0 3128 1
Se 99.58 87.54 96.34 75.56 99.32 Q 11 32 0 0 0 354
+P 99.25 92.01 96.49 87.57 99.70 Se 99.91 98.04 69.91 41.67 98.71 61.89
FPR 3.57 0.22 0.25 0.08 0.02 +P 99.75 98.40 84.29 100.00 98.27 89.17
FPR 2.07 0.16 0.04 0.00 0.02 0.01

Classes from the MIT-BIH label set without assigned beats are omit-
ted.
This is the reason for the difference between both results since
AHA database does not contain this type of beats.
The validation results after using rhythm labels show a high The NRR column of Table II shows a general increase in
sensitivity and positive predictivity for almost all classes while the number of groups in all records with a mean of 24 groups
the purity increases. We observe in accordance with [5], that the per record. This increment reflects the presence of different
largest number of errors in Table III are caused by beats with rhythm labels in the beats assigned to the clusters although
similar morphology. Fusion (F) of ventricular (V) and normal they do not always belong to different beat classes. Records
(N) beats are included with N or V clusters and viceversa. The with irregular rhythm like those with auricular fibrillation, or
same occurs with N, paced (/) and fusion of N and / beats (f). sudden rhythm change will render the RR information useless
Finally, beats with supraventricular or nodal activation points to discriminate premature or delayed beats. In such cases, the
(A, N, J, j, and e) with similar QRS are wrongly clustered when RR does not provide information about the beat activation point
the rhythm information does not result determinant for their and the discrimination cannot be performed without an analysis
discrimination. This kind of errors represent 66% of the total. of the P wave.
Besides the clustering performance, the analysis of the num- Since no other method for online clustering has been reported,
ber of clusters (N) generated for each record shows that it re- we compare our clustering performance with existing offline
mains reduced: 34 records (71%) have 15 or less clusters; 12 proposals. Only the work of Lagerholm et al. [5] provides com-
records (25%) have between 16 and 30 clusters, both included parable results since others [6], [7] are designed to deal with a
and only two records (4%) has more than 30 clusters. The high concrete subset of beat types and perform the evaluation over a
number of clusters for record 207 is caused by the presence of single channel (usually the one with lower noise). Compared to
an episode of ventricular flutter with QRS complexes replaced [5], our method provides a slightly better purity (98.56% ver-
by irregular waves. The clustering results would be improved sus 98.49%). The sensitivity is improved in our paper for 11
if an specific detection method were used for these kind of out of the 16 beat classes and slightly worsened for 3. Special
arrhythmias with absent QRS complex. mention should be made for classes a, A, R, j, and E where the
CASTRO et al.: METHOD FOR CONTEXT-BASED ADAPTIVE QRS CLUSTERING IN REAL TIME 1671

improvement is remarkable. Let us remember that Lagerholm ECG descriptors for heartbeat classification,” Med. Eng. Phys., vol. 28,
et al. [5] rely on a SOM with 25 clusters to represent the differ- no. 9, pp. 876–887, 2006.
[11] S. Osowski and T. H. Linh, “ECG beat recognition using fuzzy hybrid
ent beat classes. This approach has two main drawbacks, first neural network,” IEEE Trans. Biomed. Eng., vol. 48, no. 11, pp. 1265–
the clusters get saturated with dominant morphologies present 1271, Nov. 2001.
in the learning stage, while rare morphologies are ignored as [12] S. Osowski, L. T. Hoai, and T. Markiewicz, “Support vector machine-based
expert system for reliable heartbeat recognition,” IEEE Trans. Biomed.
well as new morphologies that appear afterwards. Second, the Eng., vol. 51, no. 4, pp. 582–589, Apr. 2004.
generated clusters are redundant in those records with a low [13] Y. H. Hu, S. Palreddy, and W. J. Tompkins, “A patient-adaptable ECG
number of morphologies. In contrast, our method dynamically beat classifier using a mixture of experts approach,” IEEE Trans. Biomed.
Eng., vol. 44, no. 9, pp. 891–900, Sep. 1997.
adapts the number of clusters to the number of morphologies [14] Z. Dokur and T. Olmez, “Ecg beat classification by a novel hybrid neural
detected. network,” Comput. Methods Prog. Bio., vol. 66, nos. 2/3, pp. 167–181,
The results of our proposal confirm the relevance of the tem- 2001.
[15] Testing and Reporting Performance Results of Cardiac Rhythm
poral context for beat clustering. It allows us to switch from an and ST-segment Measurement Algorithms. ANSI/AAMI Standard
offline to an online analysis achieving the same or even better EC57:1998/(R)2008, 2008.
results, and to address the temporal evolution of a beat morphol- [16] A. L. Goldberger, L. A. N. Amaral, L. Glass, J. M. Hausdorff, P. C.
Ivanov, R. G. Mark, J. E. Mietus, G. B. Moody, C.-K. Peng, and H. E.
ogy that otherwise would be projected into multiple clusters. Stanley, “PhysioBank, PhysioToolkit, and PhysioNet: Components of a
The results of the experiments on ECG standard databases also new research resource for complex physiologic signals,” Circulation, vol.
show the adequacy of the present method for real-time ECG 101, no. 23, pp. e215–e220, 2000.
[17] G. Moody and R. Mark, “The impact of the MIT-BIH Arrhythmia
monitoring. Database,” IEEE Eng. Med. Biol. Mag., vol. 20, no. 3, pp. 45–50, May/Jun.
Our proposal provides the cardiologists with the information 2001.
about the morphological diversity within a desired time frame [18] W.-Y. Wu, “An adaptive method for detecting dominant points,” Pattern
Recog., vol. 36, no. 10, pp. 2231–2237, 2003.
and its temporal evolution. This information allows them to [19] The CSE Working Party, “Recommendations for measurement stan-
promptly detect the different conduction patterns and evaluate dards in quantitative electrocardiography,” Eur. Heart. J., vol. 6, no. 10,
its relevance. It also can be useful for arrhythmia detection and pp. 815–825, 1985.
[20] Cardiac Monitors, Heart Rate Meters, and Alarms. ANSI/AAMI Standard
classification which can be later addressed either automatically EC13:2002/(R)2007, 2007.
by classification algorithms or manually by the cardiologists. [21] P. Kligfield, L. S. Gettes, J. J. Bailey, R. Childers, B. J. Deal, E. W. Han-
In conclusion, we have presented an adaptive, multichannel cock, G. van Herpen, J. A. Kors, P. Macfarlane, D. M. Mirvis, O. Pahlm,
P. Rautaharju, and G. S. Wagner, “Recommendations for the standardiza-
context-based method for clustering beat morphologies in real tion and interpretation of the electrocardiogram: Part I,” Circulation, vol.
time that has been validated over the whole MIT-BIH Arrhyth- 115, no. 10, pp. 1306–1324, 2007.
mia and AHA ECG databases with performance results that [22] H. Sakoe, and S. Chiba, “Dynamic programming algorithm optimization
for spoken word recognition,” IEEE Trans. Acoust., Speech, Signal Pro-
outperform its offline counterparts in the field. cess., vol. 26, no. 1, pp. 43–49, Feb. 1978.
[23] E. J. Keogh, and M. J. Pazzani, “Derivative dynamic time warping,” pre-
sented at the 1st SIAM Int. Conf. Data Mining, Chicago, IL, USA, 2001.
REFERENCES
[1] R. Sutton, “Remote monitoring as a key innovation in the management Daniel Castro received the B.Sc. and M.Sc. degrees in physics from the Uni-
of cardiac patients including those with implantable electronic devices,” versity of Santiago de Compostela, Santiago de Compostela, Spain, in 1998 and
Europace, vol. 15, no. 1, pp. i3–i5, 2013. 1999, respectively. He is a Researcher and currently working toward the Ph.D.
[2] P. DeChazal, M. O’Dwyer, and R. B. Reilly, “Automatic classification of degree at the Centro Singular de Investigación en Tecnoloxı́as da Información,
heartbeats using ECG morphology and heartbeat interval features,” IEEE University of Santiago de Compostela.
Trans. Biomed. Eng., vol. 51, no. 7, pp. 1196–1206, Jul. 2004. His research interests include signal processing and its application to biomed-
[3] M. Llamedo and J. P. Martı́nez, “Heartbeat classification using feature ical signals.
selection driven by database generalization criteria,” IEEE Trans. Biomed.
Eng., vol. 58, no. 3, pp. 616–625, Mar. 2011. Paulo Félix received the B.Sc. and Ph.D. degrees
[4] G. de Lannoy, D. François, J. Delbeke, and M. Verleysen, “Weighted con- in physics from the University of Santiago de Com-
ditional random fields for supervised interpatient heartbeat classification,” postela, Santiago de Compostela, Spain, in 1993 and
IEEE Trans. Biomed. Eng., vol. 59, no. 1, pp. 241–247, Jan. 2012. 1999, respectively.
[5] M. Lagerholm, C. Peterson, G. Braccini, L. Edenbrandt, and L. Sornmo, He is currently a Researcher at the Centro Singu-
“Clustering ECG complexes using Hermite functions and self-organizing lar de Investigación en Tecnoloxı́as da Información,
maps,” IEEE Trans. Biomed. Eng., vol. 47, no. 7, pp. 838–848, Jul. 2000. University of Santiago de Compostela. His research
[6] D. Cuesta-Frau, J. C. Pérez-Cortes, and G. A. Garcı́a, “Clustering of interests include temporal reasoning, machine learn-
electrocardiograph signals in computer-aided holter analysis,” Comput. ing, and signal processing.
Methods Prog. Bio., vol. 72, no. 3, pp. 179–196, 2003.
[7] D. Cuesta-Frau, M. O. Biagetti, R. A. Quinteiro, P. Micó-Tormos, and
M. Aboy, “Unsupervised classification of ventricular extrasystoles using
bounded clustering algorithms and morphology matching,” Med. Biol. Jesús Presedo received the B.Sc. and Ph.D. degrees
Eng. Comput., vol. 45, no. 3, pp. 229–239, 2007. in physics from the University of Santiago de Com-
[8] J. L. Rodrı́guez-Sotelo, D. Cuesta-Frau, and G. Castellanos-Domı́nguez, postela, Santiago de Compostela, Spain, in 1989 and
“Unsupervised classification of atrial heartbeats using a prematurity index 1994, respectively.
and wave morphology features,” Med. Biol. Eng. Comput., vol. 47, no. 7, He is currently a Researcher at the Centro Singu-
pp. 731–741, 2009. lar de Investigación en Tecnoloxı́as da Información,
[9] V. Krasteva and I. Jekova, “ QRS template matching for recognition of University of Santiago de Compostela. His research
ventricular ectopic beats,” Ann. Biomed. Eng., vol. 35, pp. 2065–2076, interests include biomedical digital signal processing,
Sep 2007. heart rate variability, nonlinear dynamics, soft com-
[10] I. Christov, G. Gómez-Herrero, V. Krasteva, I. Jekova, A. Gotchev, and puting, and the development of ubiquitous healthcare
K. Egiazarian, “Comparative study of morphological and time-frequency systems.

Anda mungkin juga menyukai