qrs cancellation

94
Contents 1 Introduction 1 2 Medical Background 3 2.1 Anatomy of the Human Heart .................... 3 2.2 Atrial fibrillation ........................... 4 2.2.1 Electrical Activity in NSR and in AF ........... 5 2.2.2 Classification of AF ..................... 6 2.3 ECG Signal .............................. 7 2.3.1 Formation of the ECG Signal ................ 8 2.3.2 ECG in Normal Sinus Rhythm and Fibrillatory Rhythm . 10 3 Methodology 13 3.1 Database ............................... 13 3.2 Noise Level Estimation ........................ 14 3.3 The Pan-Tompkins algorithm for QRS detection ......... 15 3.4 Feature Extraction .......................... 16 3.4.1 Feature Selection ....................... 19 3.5 Classification ............................. 19 3.5.1 Bayes Decision Theory .................... 19 3.5.2 Artificial Neural Network .................. 21 3.5.3 K Nearest Neighbor Classifier ................ 23 3.6 Post-processing and Diagnostic Decision .............. 24 4 QRST Cancellation 27 4.1 Straight Forward Averaging Algorithm for QRST Cancellation . 27 4.2 Improved QRST Cancellation .................... 30 4.2.1 Digital Filters ......................... 31 4.2.2 QRS Clustering ........................ 33 4.2.3 Sub-clustering based analysis on RR-interval ....... 38 4.2.4 Appropriate Templates and Subtraction .......... 39 4.2.5 Frequency Spectrum of AF ................. 44 4.2.6 Fourier Transform and Power Spectrum .......... 45 5 Results and Discussion 49 5.1 Results on Belt Database ...................... 49 5.2 Results on MIT Database ...................... 55 5.3 Discussion ............................... 58 5.3.1 Limitation of QRST Cancellation .............. 58

Upload: nguyen-trong-tuyen

Post on 04-Dec-2015

72 views

Category:

Documents


8 download

DESCRIPTION

dâdas

TRANSCRIPT

Page 1: QRS Cancellation

Contents

1 Introduction 1

2 Medical Background 32.1 Anatomy of the Human Heart . . . . . . . . . . . . . . . . . . . . 32.2 Atrial fibrillation . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2.2.1 Electrical Activity in NSR and in AF . . . . . . . . . . . 52.2.2 Classification of AF . . . . . . . . . . . . . . . . . . . . . 6

2.3 ECG Signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.3.1 Formation of the ECG Signal . . . . . . . . . . . . . . . . 82.3.2 ECG in Normal Sinus Rhythm and Fibrillatory Rhythm . 10

3 Methodology 133.1 Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.2 Noise Level Estimation . . . . . . . . . . . . . . . . . . . . . . . . 143.3 The Pan-Tompkins algorithm for QRS detection . . . . . . . . . 153.4 Feature Extraction . . . . . . . . . . . . . . . . . . . . . . . . . . 16

3.4.1 Feature Selection . . . . . . . . . . . . . . . . . . . . . . . 193.5 Classification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

3.5.1 Bayes Decision Theory . . . . . . . . . . . . . . . . . . . . 193.5.2 Artificial Neural Network . . . . . . . . . . . . . . . . . . 213.5.3 K Nearest Neighbor Classifier . . . . . . . . . . . . . . . . 23

3.6 Post-processing and Diagnostic Decision . . . . . . . . . . . . . . 24

4 QRST Cancellation 274.1 Straight Forward Averaging Algorithm for QRST Cancellation . 274.2 Improved QRST Cancellation . . . . . . . . . . . . . . . . . . . . 30

4.2.1 Digital Filters . . . . . . . . . . . . . . . . . . . . . . . . . 314.2.2 QRS Clustering . . . . . . . . . . . . . . . . . . . . . . . . 334.2.3 Sub-clustering based analysis on RR-interval . . . . . . . 384.2.4 Appropriate Templates and Subtraction . . . . . . . . . . 394.2.5 Frequency Spectrum of AF . . . . . . . . . . . . . . . . . 444.2.6 Fourier Transform and Power Spectrum . . . . . . . . . . 45

5 Results and Discussion 495.1 Results on Belt Database . . . . . . . . . . . . . . . . . . . . . . 495.2 Results on MIT Database . . . . . . . . . . . . . . . . . . . . . . 555.3 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

5.3.1 Limitation of QRST Cancellation . . . . . . . . . . . . . . 58

Page 2: QRS Cancellation

ii Contents

5.4 The first and the beat window II . . . . . . . . . . . . . . . . . . 625.5 QRS clustering Methods . . . . . . . . . . . . . . . . . . . . . . . 625.6 Survey of QRST cancellation using appropriate templates . . . . 645.7 Results summary . . . . . . . . . . . . . . . . . . . . . . . . . . . 66

6 Summary and Perspective 71

A Abbreviations and Acronyms 73

B COOKING BOOK FOR AF DETECTION TOOLBOX 75

C The M-file structure of AF detection using MIT [1] and OWNdatabase 81

References 85

Page 3: QRS Cancellation

List of Figures

2.1 The cardiac conduction system . . . . . . . . . . . . . . . . . . . 42.2 Diagram of electrical activity in NSR and during atrial fibrillation 52.3 Representative human ECG waveform . . . . . . . . . . . . . . . 72.4 The generation of the ECG signal in the Einthoven limb leads. . 92.5 ECG in sinus rhythm and fibrillatory rhythm . . . . . . . . . . . 10

3.1 A example from the MIT-BIH AF database . . . . . . . . . . . . 133.2 ECG miniature monitor and traces . . . . . . . . . . . . . . . . . 143.3 Noise Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153.4 Block diagram of the Pan-Tompkins algorithm for QRS detection 153.5 FeatureExctraction . . . . . . . . . . . . . . . . . . . . . . . . . . 173.6 DecisionTree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183.7 A neuron with a single scalar input and bias . . . . . . . . . . . . 223.8 layers of back propagation . . . . . . . . . . . . . . . . . . . . . . 223.9 An example of 5-Nearest Neighbor classifier . . . . . . . . . . . . 243.10 Post-processing classifier output using moving non-overlapping

window containing 6 beats in this example. . . . . . . . . . . . . 253.11 Example of receiver operating characteristic curve . . . . . . . . 26

4.1 Example of AF episode acquired by wearable belt system . . . . 274.2 ECG and their respective remainder ECG are shown for an ex-

ample of NSR and AF . . . . . . . . . . . . . . . . . . . . . . . . 284.3 ECG Example, uniform template and its respective residual sig-

nal after subtraction . . . . . . . . . . . . . . . . . . . . . . . . . 294.4 Flow chart of QT cancellation algorithm. . . . . . . . . . . . . . 304.5 Frequency response of the 50 Hz low-pass filter . . . . . . . . . . 324.6 Frequency response of the 50 Hz Notch filter . . . . . . . . . . . 334.7 Noisy ECG signal and filtered ECG signal . . . . . . . . . . . . . 344.8 Schematic representation of QRS clustering . . . . . . . . . . . . 364.9 Result of QRS clustering for the ECG example in the Fig. 4.3 . . 374.10 The appropriate templates superimposed on heart beats of each

cluster or subgroup for ECG example in Fig. 4.3 . . . . . . . . . 384.11 Flow chart of computing appropriate templates . . . . . . . . . . 394.12 An AF example, appropriate templates for QRST Cancellation

and its respective residual signal . . . . . . . . . . . . . . . . . . 404.13 Remainder of the AF Example using the forward averaging al-

gorithm and improved QRST Cancellation. . . . . . . . . . . . . 41

Page 4: QRS Cancellation

iv List of Figures

4.14 An NSR example, template for QRST Cancellation and its re-spective residual signal . . . . . . . . . . . . . . . . . . . . . . . . 42

4.15 Definition of beat window . . . . . . . . . . . . . . . . . . . . . . 434.16 Frequency spectra from the residual signals in the AF and non-

AF cases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

5.1 QT features averaged over AF and NSR records . . . . . . . . . . 515.2 Histogram of QTCan14 and QTCan11 . . . . . . . . . . . . . . . 525.3 ROC curve for combining features of QTCan14 and RR interval 545.4 Plot features of AF and NSR episode from record 04746 . . . . . 565.5 AF example with not apparent fibrillatory waves . . . . . . . . . 595.6 NSR example with chaotic atrial activity. . . . . . . . . . . . . . 605.7 Noisy ECG signal causes considerable error in QRST cancellation. 605.8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 615.9 K-mean clustering partitions the QRS complexes into three clusters 635.10 Frequency spectrum of the entire P wave . . . . . . . . . . . . . . 655.11 Decision curves comparison . . . . . . . . . . . . . . . . . . . . . 665.12 Performance comparision . . . . . . . . . . . . . . . . . . . . . . 675.13 QDC Density Estimation . . . . . . . . . . . . . . . . . . . . . . 675.14 Density function . . . . . . . . . . . . . . . . . . . . . . . . . . . 685.15 Decision curves comparison . . . . . . . . . . . . . . . . . . . . . 695.16 QDC Density Estimation . . . . . . . . . . . . . . . . . . . . . . 695.17 Density function . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

Page 5: QRS Cancellation

List of Tables

2.1 Classification of AF . . . . . . . . . . . . . . . . . . . . . . . . . 6

5.1 Features of QRST Cancellation of chronic AF patients for eachrecord . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

5.2 Features of QRST Cancellation of NSR patients for each record . 505.3 Averaging features for AF and NSR records . . . . . . . . . . . . 515.4 Results of AF detection using QRST Cancellation features on

wearable belt system. . . . . . . . . . . . . . . . . . . . . . . . . 535.5 Results of AF detection using features of RR interval and QRST

Cancellation on wearable belt system. . . . . . . . . . . . . . . . 545.6 The duration of annotated segment in minutes and the number

of heart beats for each MIT AF database . . . . . . . . . . . . . 575.7 AF detection using feature of RR interval, QRST Cancellation

and combining the both features on MIT database. . . . . . . . . 585.8 AF detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 665.9 AF detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

Page 6: QRS Cancellation
Page 7: QRS Cancellation

1 Introduction

Atrial fibrillation (AF) is a common arrhythmia with a prevalence of approxi-mately 0.4-1% in the general population. Prevalence increases with age and itis estimated to be present in 5% of those older than 65, and 10% of those olderthan 70. It is associated with an increased risk of stroke and mortality, as wellas congestive heart failure and cardio-myopathy. AF gives rise to a significantincrease in mortality [2].

To help in the fight against AF disease, a system is developed for the contin-uous monitoring of health status based on non-invasive wearable sensors inte-grated in the Philips strap. The disease knowledge is enriched over time as thesystem learns the patient’s behavior, for example, by monitoring and “remem-bering” the heartbeat during daily activities. Biometric signals, primarily ECG(electrocardiogram), are collected in the hospital or at home and displayed ona central station.

ECG signal, which is a graphical representation of the potential differencesmeasured between two points on body surface versus time, is produced byactivation front of cardiac depolarization and repolarization. ECG signals arelargely employed as a diagnostic tool in clinical practice in order to assess thecardiac status of the patient. As one of the most important pieces of vitalinformation, the ECG signal plays an important role in the continuous patientmonitoring for the people, who suffer from chronic cardiovascular diseases. Thisabnormal excitation propagation of AF patients results in morphology changesin ECG. The ECG of AF patients is characterized by irregular RR intervalscaused by chaotic atrial depolarization waves penetrating the AV node in anirregular manner. We can not see any consistent P wave due to chaotic atrialactivity, replaced by a fibrillatory wave, caused by random reentry wavelets.These features enable automatic diagnosis of AF.

This novel continuous ECG monitoring support automatic analysis of ECGsignal on pocket PC, e.g., mobile platform. Algorithms of ECG processing arethereby on demand under this circumstance. This study proposes a solutionfor automatic detection of AF available for pocket PC. The AF detection usesfeatures extracted from the ECG, which reflect the electrophysiological changesmanifest in ECG signal during AF. The most descriptive features were selected,and evaluated using various classifier on MIT-BIT atrial fibrillation database,as well as on a database collected from atrial fibrillation patients using a Philipsone lead ECG strap. This thesis contain the following contents:

• Medical Background: Anatomy of human heart, AF pathology, forma-tion of ECG signal are introduced to aid in comprehension of electrophys-iological changes in the ECG of AF patients.

Page 8: QRS Cancellation

2 Introduction

• Methodology: This chapter describes all the components in the frame-work of AF detection: database, preprocessing, features extraction, post-processing and evaluation.

• QRST cancellation: The vast majority of the AF detector is based onventricular irregularity, but the drawback is that rhythms other than AFcan also have irregular ventricular responses. Therefore, attempts havebeen made to detect AF fibrillatory activity using QRST cancellation.

• Results and Discussion: This chapter describes the results of AF de-tection on the two databases, using diverse features and combined featuresalong with various classifiers. This chapter also discusses the drawbacksof the QRST cancellation and the other possible approaches.

Page 9: QRS Cancellation

2 Medical Background

AF is the result of a fractionated atrial electrical activity mainly due to theshortening of atrial refractory period, which allows multiple wavelets passthrough the atrial mass. AF can probably cause both molecular modificationsof electrophysiological activity, and structural, functional, which contribute todisturbance of initiation and propagation of excitation pattern in atrial tissue.In the case of normal sinus rhythm (NSR), the excitation propagation originatesfrom the sinoatrial node, from the right atrium to the left atrium in a uniformpulse wave, after a 0.1 second delay in the AV node, the excitation along the Hisbundle musculature to the both ventricles. However, in the case of AF, reen-try wavelets occur instead of uniform excitation propagation. The excitationspreads throughout the atrium in a random pattern. These chaotic atrial depo-larization causes rapid atrial activity at 300 to 600 bpm. Fortunately, the AVnode does not permit all of the excitation to propagate to ventricles. Only 1 or2 among every 3 atrial signals can pass the AV node due to Wenckebach effect.However the ventricle contracts at a high rate of 110 to 180 bpm, depolarizedby a variant cycle length. To aid in comprehension of the methods for AF de-tection, this chapter introduces the medical background including anatomy ofhuman heart, AF pathology, formation of ECG, as well as the the characters ofthe ECG signal which distinguish between atrial fibrillation and normal sinusrhythm.

2.1 Anatomy of the Human Heart

The heart constitutes together with the blood vessels the cardiovascularsystem, which has the task of transporting blood through the body. In thissystem the heart acts as a cyclically working pump and as a blood reservoir.

From a macroscopic spatial view the mammalian heart is located insideof the thorax and near to the lungs enclosed in the pericardium. Large bloodvessels are connected to the heart. It is subdivided by septa into two functionallyand anatomically similar structures: the right and left half, which representsthe division of the blood circulation system in two different parts. The righthalf collects the deoxygenated blood from the body and pumps it to the lungs;the left half receives the oxygenated blood from the lungs to deliver it to thebody.

A constriction subdivides each half of the organ into two muscular regionsenclosing a cavity. The upper region is called the atrium, the lower is theventricle. The heart therefore consists of four chambers: i.e. left and rightatria as well as left and right ventricles. The atria collect the incoming blood,

Page 10: QRS Cancellation

4 Medical Background

Figure 2.1: The cardiac conduction system. The numbers in the brackets arethe conduction time of the excitation propagation in seconds [3].

which is transported to the ventricles. From there the blood is moved to supplythe body and the heart itself. The atria and ventricles are composed of wallssurrounding a cavity, which is normally filled with blood [4].

The excitation propagation in the human heart produces electrocardiogra-phy (ECG) and regulates the heart contraction. Figure 2.1 depicts the cardiacconduction system. The sinoatrial (SA) node emits an impulse from the lead-ing pacemaker site. The impulse spreads immediately into the atrial cardiomy-ocytes and is transmitted through the entire atrial muscle mass to the atrioven-tricular node (AV node) After a brief delay in AV node, during which the atriacan contract and fill the ventricles with blood, the impulse is conducted throughthe His bundle via Tawara bundles and a subendocardial network (Purkinje’sfibers). Finally both ventricles are activated from endocardium to epicardium.

2.2 Atrial fibrillation

Atrial Fibrillation (AF) is a common arrhythmia with a prevalence of ap-proximately 0.4-0.1% in the general population. Prevalence increases with ageand is estimated to be present in 5% of those older than age 65, and 10% ofthose older than 70. AF is associated with an increased risk of stroke andmortality, as well as congestive heart failure and cardiomyopathy [5][6].

In normal individuals, a brief episode of AF may cause palpitations, chestdiscomfort and light-headedness. Palpitations (a sensation of a rapid and ir-regular heart beat) are the most frequent symptoms in those patients withparoxysmal AF. When AF is persistent or permanent, patients suffer more of-

Page 11: QRS Cancellation

2.2 Atrial fibrillation 5

ten non-specific symptoms like poor effort tolerance, breathlessness on exertion,and lack of energy. AF can, by itself, cause severe CHF (congestive heart fail-ure) after several weeks to months. The loss of atrial contraction also leads tothe enlargement of atria, thus the stasis of blood in the atria, which promotesclot formation and the occurrence of thromboemboli. AF is the single mostimportant cause of ischaemic stroke in people older than 75 [5].

2.2.1 Electrical Activity in NSR and in AF

Figure 2.2: Diagram of electrical activity in NSR (a) and during atrial fibril-lation (b). Representative APs are shown from the SA node, atrial myocytes,AV node and ventricles. The vertical line on each AP recording corresponds toa common time reference. LA, left atrium; LV, left ventricle; RA, right atrium;R V, right ventricle [5].

The heart is a large muscular pump that drives blood around the body (seesection 2.1). To achieve this effectively, the heart’s chambers must be preciselycontrolled electrically. Figure 2.2 a) illustrates the normal regular activity inthe physiological heart. The normal heart beat is initiated in the SA nodeat the normal sinus rhythm, then is conducted regularly throughout the atria,causing them to contract. The contraction of the atria propels blood into theventricles. After about 0.1 s delay in the AV node, the excitation spreads rapidlythrough Hisbundle and the connected branches to the ventricles and initiatestheir contraction. As a consequence, the blood is pumped from the ventriclesto all of the organs around the body.

Page 12: QRS Cancellation

6 Medical Background

Figure 2.2 b) reflects the disturbed excitation propagation in the heart withAF. When episodes of AF occur, instead of the regular initiation of the heartbeat in the SA node, there is no single place where the heart activates in theatrium. The wavefronts of excitation spread throughout the atrium in a ran-dom pattern (re-entry wavelets: multiple wavefronts of depolarisation), findinganother small region of tissue to depolarize. The atria are constantly activatedin this chaotic pathway, until several of them are captured by the AV node andpropagate to the ventricles. Although the AV node filters most of these extraatrial signals, the heart rate still reaches 110 to 180 bpm. There is no effectivecontraction of the atrial muscle in this situation.

2.2.2 Classification of AF

It has been long recognized that an episode of AF may be self-terminatingor non-self-terminating. The terms chronic and paroxysmal have been used,but sometimes this definition results in difficulties in effectiveness of treatmentsand therapeutic strategies. It is important for clinicians to ascertain whetheran incident of AF is the very first episode, that is, the initial event; whether itis symptomatic or not; and whether it is self-terminating or not. If the patienthas had two or more episodes, AF is said to be recurrent. AF can be classifiedby (see table 2.1):

Terminology Clinical features Arrhythmia patternInitial event Symptomatic May not recur(first detected Asympotomatic (first detected)episode) Onset unknown (first detected)Paroxysmal Spontaneous termination < 7 days Recurrent

and most often < 48 hoursPersistent Not self-terminating RecurrentPermanent Not terminated or Established

terminated but relapsed

Table 2.1: Classification of AF [7].

Paroxysmal AF: Episodes of paroxysmal AF usually self-terminate within 48hours and, by definition, in fewer than 7 days. The heart changes from SRto AF episodes lasting from seconds to days. The patient may only have1 episode a year or be in AF most of the time, but the essential featureis that most episodes terminate spontaneously.

Persistent AF: When an espisode of AF has lasted longer than 7 days, AFis designated as persistent. Persistent AF may be the first presentationof the arrhythmia or may be preceded by recurrent episodes of paroxys-mal AF. When AF is persistent, termination using electrical cardioversionmay be required, which is used to restore NSR. Cardioversion delivers theelectrical shock instantaneous to the human heart, resulting in a momen-

Page 13: QRS Cancellation

2.3 ECG Signal 7

tary depolarisation of most cardiac cells simultaneously. It allows the SAnode to resume the normal pacemaker activity.

Permanent AF: When AF has been present for some time and fails to termi-nate using cardioversion or is terminated but replaces within 24 hours, itis said to be established or permanent [7].

Figure 2.3: Representative human ECG waveform, adapted from [8]

2.3 ECG Signal

Each individual heartbeat is comprised of a number of distinct cardiologicalstages, which in turn give rise to a set of distinct features in the ECG wave-form. These features represent either depolarization (electrical discharging) orrepolarization (electrical recharging) of the muscle cells in particular regions ofthe heart. This activation sequence generates ECG measured by electrode onthe patients skin in specific position, e.g. left, right hand and left leg. Thiselectrode locations on the extremities produce three different leads: Einthovenleads I, II and III. The activation front contributing to ECG signal is containedin Fig. 2.4. Figure 2.3 shows a human ECG waveform and the associated fea-tures. The standard features of the ECG waveform are the P wave, the QRScomplex and the T wave. Additionally a small U wave (following the T wave)is occasionally present.

The timing between the onset and offset of particular features of the ECG(referred to as an interval) is of great importance. The two most importantintervals in the ECG waveform are the QT interval and the PR interval. TheQT interval is defined as the time from the start of the QRS complex to the end

Page 14: QRS Cancellation

8 Medical Background

of the T wave, i.e. Toff -Q, and corresponds to the total duration of electricalactivity (both depolarization and repolarization) in the ventricles. Similarly,the PR interval is defined as the time from the start of the P wave to the startof the QRS complex, i.e. Q-Pon and corresponds to the time from the onset ofatrial depolarization to the onset of ventricular depolarization. In normal sinusrhythm [9][10][11],

• P-R interval 120-200 milliseconds (0.12 to 0.20 seconds)

• QRS interval under 120 milliseconds (0.12 seconds)

• Q-T interval under 380 milliseconds (0.38 seconds)

2.3.1 Formation of the ECG Signal

The cardiac cycle begins with the P wave (the start and end points of whichare referred to as Pon and Poff ), which corresponds to the period of atrialdepolarization in the heart. After the electric activation of the heart has begunat the sinus node, it spreads along the atrial walls. The resultant vector of theatrial electric activity is illustrated with a thick arrow in Fig. 2.4 (a). Theprojections of this resultant vector on each of the three Einthoven limb leadsis positive. After the depolarization has propagated over the atrial walls, itreaches the AV node. The propagation through the AV junction is very slowand involves negligible amount of tissue; it results in a delay in the progressof activation. (This is a desirable pause which allows completion of ventricularfilling.)

The P wave is followed by the QRS complex, which is generally the mostrecognisably feature of an ECG waveform, and corresponds to the period ofventricular depolarization. Once activation has reached the ventricles, propa-gation proceeds along the Purkinje fibers to the inner walls of the ventricles.The ventricular depolarization starts first from the left side of the interven-tricular septum, and therefore, the resultant dipole from this septal activationpoints to the right. The figure 2.4 (a) right shows that this causes a negativesignal in leads I and II. In the next phase, depolarization waves occur on bothsides of the septum, and the resultant vector points to the apex. After a whilethe depolarization front has propagated through the wall of the right ventricle.Because the left ventricular wall is thicker, activation of the left ventricular freewall continues even after depolarization of a large part of the right ventricle.Because there are no compensating electric forces on the right, the resultantvector reaches its maximum in this phase (see R peak in Fig. 2.4 (b)), andit points leftward. The depolarization front continues propagation along theleft ventricular wall toward the back. Because its surface area now continu-ously decreases, the magnitude of the resultant vector also decreases until thewhole ventricular muscle is depolarized. The last to depolarize are basal re-gions of both left and right ventricles. Because there is no longer a propagatingactivation front, there is no signal either in Fig. 2.4 (c).

Ventricular repolarization begins from the outer side of the ventricles andthe repolarization front ”propagates” inward (see Fig. 2.4 (d)). The inward

Page 15: QRS Cancellation

2.3 ECG Signal 9

(a) (b)

(c) (d)

Figure 2.4: The generation of the ECG signal in the Einthoven limb leads. (a)The cardiac cycle begins with the P wave, which corresponds to the period ofatrial depolarization in the heart. (b) and (c) The QRS complex is caused byventricular depolarization. (d) The T wave represents the ventricular repolar-ization. [8].

Page 16: QRS Cancellation

10 Medical Background

spread of the repolarization front generates a positive signal, denoted as Twave. Because of the diffuse form of the repolarization, the amplitude of thesignal is much smaller than that of the depolarization wave and it lasts longer[8].

2.3.2 ECG in Normal Sinus Rhythm and Fibrillatory Rhythm

Figure 2.5: Top: ECG in sinus rhythm. Buttom: ECG in finrillatory rhythm,adapted from [12][13]

Normal heart rhythm is termed as sinus rhythm (SR) or normal sinusrhythm (NSR). The ECG in sinus rhythms (see upper Fig. 2.5) are char-acterized by a conducted P-wave with a P-R interval between 0.12 and 0.20seconds. The QRS width should be 0.04 to 0.12 seconds and and a Q-T intervalof less the 0.40 seconds. The rate for a normal sinus rhythm is 60 to 100 beatsa minute. If the rate is below 60 beats a minute but the rest is the same it isa Sinus Bradycardia. If the rate is between 100 to 150 beats a minute with thesame intervals it is a Sinus Tachycardia.

The AF on ECG in figure 2.5 below is indicated by the absence of consistentP-waves, due to the chaotic atrial depolarization. Chaotic atrial depolarizationwaves penetrate the AV node in an irregular manner, resulting in irregularventricular contractions. The QRS complexes have normal shape, due to normalventricular conduction. However the RR intervals vary from beat to beat [7].In AF, the atria is excited rapidly and irregularly at a rate of 400 to 600 bpm.

Page 17: QRS Cancellation

2.3 ECG Signal 11

Fortunately, the AV node doesn’t permit all of the excitations to propagateto the ventricles. Only 1 or 2 among every 3 atrial signals can pass AV node(Wenckebach effect). However the vertricles contract at a high rate of 110 to180 bpm in the absence of drug therapy [6]. The ventricular rate during AF(the effective “heart rate”) is thus no longer under physiological control of theSA node, instead is determined by interaction between the atrial rate and thefiltering function of the AV node.

Page 18: QRS Cancellation
Page 19: QRS Cancellation

3 Methodology

The approach for AF detection uses data collected the Philips strap and MIT-BIH atrial fibrillation (AF) database [14]. The ECG signals were pre-processedby a R peak detection algorithm before the features were extracted. The fea-ture extraction using beat-to-beat features were chosen to reflect the physio-logical changes that manifest in the ECG signal. Various classifiers with inputof features were applied for pattern recognition. Finally, the accuracy of theclassification decision were measured by a statistical analysis.

3.1 Database

The first evaluation database is the MIT-BIH arrhythmia database. This data-base was the first generally available set of standard test material for evaluationof arrhythmia detectors, and has been used for that purpose as well as for basicresearch into cardiac dynamics at about 500 sites worldwide [12]. The originalanalog recordings were made at Boston’s Beth Israel Hospital (now the BethIsrael Deaconess Medical Center) using ambulatory ECG recorders with a typ-ical recording bandwidth of approximately 0.1 Hz to 40 Hz. The individualrecordings are each ten hours in duration, and include two channels of ECGsignals each sampled at 250 samples per second with 12-bit resolution over arange of ±10 millivolts. Eighteen long-term ECG signals of channel one werechosen from the MIT-BIH atrial fibrillation database, recordings of human sub-jects with paroxysmal AF. The remaining five recordings containing fewer AFepisodes were not adopted. The Fig. 3.1 shows a example from the MIT-BITAF database.

Another database was collected from chronic AF patients using a one leadECG strap. This Philips belt has been developed with three integrated dryelectrodes. The electrodes based on carbon-loaded rubber was integrated in

Figure 3.1: A example from the MIT-BIH Atrial Fibrillation Database Record04015, Grid intervals: 0.2 seconds (horizontal) and 0.5 mV (vertical) [13].

Page 20: QRS Cancellation

14 Methodology

(a) (b)

Figure 3.2: (a) ECG monitoring strap designed for convenience (b) ECG tracesin Sinus rhythm of a subject at rest, measured by the wearable belt on the chest[14].

strap with miniaturized shielded cable. The strap was worn around the chest.The representative P wave, QRS-complex, distinct R peak and T wave can beseen in Fig. 3.2, only slight morphology variation compared to the standardECG-leads [14]. In total seventeen patients were measured in Aachen clinic,Germany. Among them nine patients suffer from chronic AF, the rest arehealthy subjects. 9120 beats from fourteen recordings (three recordings werenot used due to its bad quality) in total duration of 130 minutes were used forprocessing. The data comes from regular but short recordings. The patientsare resting during measurement and the noisy data are not taken into account.

3.2 Noise Level Estimation

To determine the noisy parts of signal which were to be excluded, the discretewavelet transform with mother Daubechies 4 wavelet was used. We considerthe following model of a discrete noisy signal [15]:

y(n) = f(n) + σe(n), n = 1 . . . N (3.1)

The vector y represents a noisy signal and f is an unknown, deterministicsignal. We suppose that e is Gaussian white noise N(µ, σ) = N(0, 1).

Donoho and Johnstone [15] propose to use the ”universal threshold” estima-tion for estimating the noise σ.

δ =√

2 ln Nσ (3.2)

where σ is an estimation of the noise variance σ2 given by

σ = median(|C(1, k)|)/0.6745 (3.3)

Page 21: QRS Cancellation

3.3 The Pan-Tompkins algorithm for QRS detection 15

The first scale |C(1, k)| in the wavelet transform contains high frequencies,usually characteristic of noise. Afterwards, the energy function of the first scaleis computed to amplify the noisy parts of the signal and the estimation of”average” white noise variance is performed by taking the median value of thewavelet coefficients at this finest scale (3.3) - see Fig. 3.3.

Figure 3.3: Noise detection. The parts with saturation noise and high fre-quency noise have been successfully detected.

3.3 The Pan-Tompkins algorithm for QRSdetection

Pan and Tompkins [16][17] proposed a real-time QRS detection algorithm basedon analysis of the slope, amplitude, and width of QRS complexes. The algo-rithm includes a series of filters and methods that perform low-pass, high pass,derivative, squaring, integration, adaptive thresholds and search procedures.Fig. 3.4 illustrates the steps of the algorithm in schematic form.

Figure 3.4: Block diagram of the Pan-Tompkins algorithm for QRS detection [17].

Bandpass-filter The bandpass filter reduced the influence of muscle noise,power-line interference, baseline wander, and T wave interference. The desiredpass band to maximize the QRS energy is approximately 5-15 Hz.

Page 22: QRS Cancellation

16 Methodology

Derivative operator The derivative procedure suppresses the low frequencycomponents of P and T waves, and provides a large gain to high componentsarising from high slopes of the QRS complexes.

Squaring The squaring operation makes the result positive and emphasizeslarge large differences resulting from QRS complexes; the small differences aris-ing from P and T waves are suppressed. The high- frequency components inthe signal related to the QRS complex are further enhanced.

Integration The output of the derivative based operation will exhibit mul-tiple peaks within the duration of a single QRS complex. The Pan-Tompkinsalgorithm performs smoothing of the output of the preceding operations througha moving-window integration filter and produces transformed ECG.

Adaptive threshold Two set of thresholds are used to detect QRS complexesfor the transformed to improve the reliability compared to using onr threshold.The thresholds continuously adapt to the current characteristics of ECG signalssince they are based upon the most-recent signal and noise peaks. If a peakexceeds THRESHOLD I1 during the first step of analysis, it is classified as aQRS peak. If the search-back technique (described in the next paragraph) isused, the peak should be above THRESHOLD I2 to be called QRS. For irregularheart rates, the first threshold of each set is reduced by half so as to increasethe detection sensitivity and avoid missing beats. To be identified as a QRScomplex, a peak must be recognized as such a complex in both the integrationand bandpass-filtered waveform.

Search-back procedure The Pan-Tompkins algorithm maintains two RR-interval averages: RR AVERAGE1 is the average of the most-recent beats, andRR AVERAGE2 is the average of the most-recent beats having RR intervalswithin the range specified by

RR LOW LIMIT = 92%RR AVERAGE2RR HIGH LIMIT = 116%RRAVERAGE2 (3.4)

Whenever a QRS is not detected for a certain interval specified as

RR MISSED LIMIT = 166%RRAVERAGE2, (3.5)

the QRS is taken to the peak between the established two thresholds.

3.4 Feature Extraction

There are three important feature groups used in detection of atrial fibrillation:features using RR interval information, features using P-wave morphology, andfeatures using QRST cancellation. We consider a combination of features fromall these groups.

Page 23: QRS Cancellation

3.4 Feature Extraction 17

The features were extracted in a sliding window consisting of 30 beats,rather than breaking the heart beats into separately blocks. Each time thewindow was shifted in one heart beat (1 R-R interval) forward. In this way,an attempt was made to label each beat individually, rather than in a group,e.g, the first ECG block extending from the first to thirtieth heart beats formedthe 1st features array, and the second ECG block extending from the second tothirty-first intervals formed the 2nd features array, etc. This technique resultsin one-to-one correspondence between features and beats in the stream- see Fig.3.5.

Figure 3.5: Features were calculated in moving window containing 30 beats.

1. An attractive approach for extraction of ventricular activity is to modelthe R-R interval sequence as a three-state Markov process [18]. Eachinterval is characterized as representative of one of the three states S, R,L by classifying it as short, regular or long. Intervals were called short ifthey did not exceed 85% of the mean interval, long if they exceeded 115%of the mean, and regular otherwise. The mean interval is determinedrecursively by the relation for all observed R-R intervals rr(i) which donot exceed 1.5 seconds:

rrmean(i) = 0.75 ∗ rrmean(i− 1) + 0.25 ∗ rr(i) (3.6)

Assume that R-R interval sequence

T = t1, t2, . . . , tn (ti ∈ S,R,L) (3.7)

is controlled by a stationary first-order Markov process characterized bythe transition probability matrix

Pi,j,R = P (ti|tj , R) (R ∈ AF, other) (3.8)

where AF and other denote AF and other rhythms of the databases re-spectively. This matrix gives the probability moving from state i to j.

Page 24: QRS Cancellation

18 Methodology

Further features apart from Moody’s matrix were calculated. In the timedomain, the following parameters were extracted: standard deviation ofthe NN interval (SDNN), the standard deviation of the average NN inter-val (SDANN), the square root of the mean squared differences of successiveNN intervals (RMSSD), the number of interval differences of successiveNN intervals greater than 50ms (NN50). In the frequency domain, powerin very low (VLF [0-0.01Hz]), low (LF [0.01-0.15Hz]), high (HF [0.15-0.5Hz]) frequency range and ratio LF/HF were estimated. Furthermore,the two following non-linear parameters were computed as well: approx-imate entropy, a measure of complexity [19], and dentrended fluctuationanalysis [20], a measure of long-term correlations.

2. The second feature group is a test for a presence of P wave. In normalsinus rhythm, the P wave can be observed before QRS complex whilein case of AF, there is no P wave presented. The P wave detection isdone using template matching where correlation coefficient is used as adissimilarity measure between actual P wave and template. A thresholdhad to be chosen (0.1) to allow acceptance of very similar beats. In thisway, each beat was labelled as beat with P wave present or P wave absent.

3. Finally, the last feature group are frequency and domain properties ofECG remainder obtained after QRST cancellation. The frequency spec-tra of ventricular and atrial activity overlap. The remainder electrogramis needed to cancel the ventricular component and isolate the atrial activ-ity component of the signal. The remainder was calculated by averagingmethod [21]. Fiducial points for ventricular complexes were marked usinga method based on the algorithm presented by Pan and Tompkins [22].This involved calculating the first and second derivatives of the electrocar-diogram, adding their absolute values together, and marking the maximaas fiducial points. Basically, the average beat was aligned with the fiducialpoints of all dominant beat windows and subtracted.The other featuresderived from QRST cancellation will be discussed in chapter 4.

Figure 3.6: Example of feature selection using decision tree algorithm. Todemonstrate the selection process, the validation set on which the tree was builtwas much smaller than the validation set for training and testing classifiers.

Page 25: QRS Cancellation

3.5 Classification 19

3.4.1 Feature Selection

In total we obtained 45 features. In order to reduce the dimension of the featurespace we applied the decision tree C4.5 algorithm using the WEKA package [23].We retained the two most significant features by looking at the first levels ofthe resulting decision tree. One simplified example of the decision tree processis shown in Figure 3.6 where two features of the R-R interval analysis and theP wavelet template matching were selected.

3.5 Classification

These features were fed to classifiers to categorize the ECG data into two classes:patients with or without AF. The database was split randomly into a trainingset (30%) and test set (70%). For each beat, the correct classification intoAF / non-AF was known as 1 for AF and 0 for non-AF. The classifier wastrained using the ECG signal from the training set, and evaluated on the testset. Different classifiers were tested from a toolbox for pattern recognition(PRTools4) to get highest specificity and sensitivity. In the first case the equalcovariances matrices for Bayes classifier were assumed, which results in a lineardiscriminant function based on Bayes normal densities (LDC). In thesecond case the covariance matrices are different for each category. The Bayesclassifier for normally distributed classes with unequal covariant matrices istermed as quadratic classifier based on Bayes normal densities (QDC).The third classifier is a back propagation (BP) neural network with onehidden layer of 10 neuron units and one output neuron unit (10-ANN). Thefourth one is 3-nearest neighbor classifier (3-KNN). These classifiers aredescribed in the subsections below.

3.5.1 Bayes Decision Theory

Bayes decision theory is a fundamental statistical approach to the problem ofpattern classification. For two category classification (AF and non-AF), we letω1 and ω2 denote the two states to be classified with priori probability P (ω1)and P (ω2), and suppose x is the feature value. The joint probability densityof ωj can be written in two ways: P (ωj, x) = P (ωj |x)P (x) = P (x|ωj)P (ωj).Therefore the Bayes formula is given by

P (ωj |x) =P (x|ωj)P (ωj)

P (x)(3.9)

where in this case of two categories

P (x) =2∑

j=1

P (x|ωj)P (ωj) (3.10)

The posteriori probability P (ωj |x) is the probability of the state being ωj

given that feature value x is measured. P (x|ωj) is density function of x givenby ωj . P (x) is unimportant as far as making a decision is concerned. It is

Page 26: QRS Cancellation

20 Methodology

basically just a scale factor that states how frequently we will actually measurea pattern with feature value x. It only guarantee us that P (ω1|x)+P (ω2|x) = 1.By eliminating this scale factor, we obtain the following completely equivalentdecision rule:

Decide ω1 if P (x|ω1)P (ω1) > P (x|ω2)P (ω2) otherwise decide ω2 (3.11)

There are many ways to represent pattern classifiers. One of the most usefulis in terms of a set of discriminant functions, gi(x), i = 1, . . . , c. The classifieris said to assign a feature vector x to class ωi if

gi(x) > gj(x) for all j 6= i (3.12)

For the maximum a posteriori rule (MAP), the associated discriminantfunctions become

gi(x) = P (ωi|x) = P (x|ωi)P (ωi) (3.13)

Since the logarithm is monotonically increasing, the classification is un-changed if we take natural logs.

gi(x) = log P (ωi|x) = log P (x|ωi) + log P (ωi) (3.14)

Let’s assume that the likelihood densities are Gaussian distribution.

P (x|ωi) =1√2πσ

exp[−12

(x− µ

σ

)2

] (3.15)

The normal density is completely specified by two parameters: its mean µand variance σ2. The general multivariate normal density in d dimensions iswritten as

P (x|ωi) =1

(2π)d/2|∑

i |1/2exp

[− 1

2(x− µi)T (

∑)−1i (x− µi)

](3.16)

where x is a d-component column vector, µ is the d-component mean vector,∑is the d-by-d covariance matrix. |

∑| and

∑−1 Eliminating constant term,the MAP discriminant functions become

gi(x) = |∑

i

|1/2exp[− 1

2(x− µi)T (

∑)−1i (x− µi)

]P (ωi) (3.17)

expressed in logarithm

gi = −12(x− µi)T (

∑)−1i (x− µi)−

12log(|

∑i

|) + log(P (ωi)) (3.18)

This know as Quadratic Discriminant Function. The quadratic term,called as Mahalanobis Distance:

Page 27: QRS Cancellation

3.5 Classification 21

‖x− y‖2(∑

)−1i

= (x− y)T (∑

)−1i (x− y) (3.19)∑

−1 can be thought of as a stretching factor on the space. Note for anidentity covariance matrix (

∑i = 1), the Mahalanobis distance becomes familiar

Euclidean distance.When the features are statistically independent and each feature has the

same variance σ2. In this case gi can be rewritten as

gi(x) = −(x− µi)T (x− µi)2σ2

+ log P (ωi)

= − 12σ2

[xxT − 2µTi x + µT

i µi] + log P (ωi) (3.20)

However, the quadratic term xT x is the same for all i, making it an ignor-able additive constant. Thus, we obtain the equivalent linear discriminantfunctions

gi(x) = wTi x + ωi0 (3.21)

where

wi =1σ2

µi (3.22)

and

ωi0 = − 12σ2

µTi µi + log P (ωi) (3.23)

In short, the Bayes classifier for normally distributed classes is quadratic,whereas the Bayes classifier for normally distributed classes with equal covari-ance matrices is a linear classifier [24][25].

3.5.2 Artificial Neural Network

Artificial neural networks are computational systems, either hardware or soft-ware, which mimic the computational abilities of biological systems by usinglarge numbers of simple, interconnected artificial neurons. Artificial neuronsare simple emulation of biological neurons [26]. Fig. 3.7 shows a neuron unitwith a single input. The scalar input p is transmitted through a connection thatmultiplies its strength by the scalar weight w to form the product wp, which isargument of the transfer function f . The bias b is viewed as a threshold. If thewp greater than the threshold, the output is 1, otherwise it is 0.

The back propagation (BP) network is the most widely used training algo-rithm, consisting at least three layers: an input layer, at least one intermediatehidden layer, and an output layer (see Fig. 3.8). With BackProp networks,learning occurs during a training phase in which each input pattern in a train-ing set is applied to the input units and then propagated forward. The patternof activation arriving at the output layer is then compared with the correct

Page 28: QRS Cancellation

22 Methodology

Figure 3.7: A neuron with a single scalar input and bias [27]

(associated) output pattern to calculate an error signal. The error signal foreach such target output pattern is then backpropagated from the outputs tothe inputs in order to appropriately adjust the weights in each layer of the net-work. After a BackProp network has learned the correct classification for a setof inputs, it can be tested on a second set of inputs to see how well it classifiesuntrained patterns [28].

Figure 3.8: Back propagation network consists at least three layers: an inputlayer, at least one intermediate hidden layer, and an output layer.

The simplest implementation of back propagation learning updates the net-work weights and biases in the direction in which the performance functiondecreases most rapidly - the negative of the gradient. One iteration of thisalgorithm can be written [29]

xk+1 = xk − αgk (3.24)

where xk is a vector of current weights and biases, gk is the current gradient,and α is the learning rate. Learning in a backpropagation network is in twosteps. First each pattern is presented to the network and propagated forwardto the output. Second, a method called gradient descent is used to minimizethe total error on the patterns in the training set. In gradient descent, weights

Page 29: QRS Cancellation

3.5 Classification 23

are changed in proportion to the negative of an error derivative with respect toeach weight [28]:

∆wji = −ε[δE/δwji] (3.25)

where wji is the weight connecting unit i to unit j, and ε is constant. Weightsmove in the direction of steepest descent on the error surface defined by thetotal error:

E =12

∑p

∑j

(tpj − opj)2 (3.26)

where opj be the activation of output unit uj in response to patter p and tpj

is the target output value for unit uj . The gradient is computed by summingthe gradients calculated at each training example, and the weights and biasesare only updated after all training examples have been presented. In summary,the BP network learns by example, when it is provided with a learning setthat consists of some input examples and the known-correct output for eachcase. The computational cycle is repeated until the network learns the problem“well enough”, that means overall error value drops below some pre-determinedthreshold. However, this operation is unpredictable, since the network finds outhow to solve the problem by itself.

3.5.3 K Nearest Neighbor Classifier

The KNN classifier is a very intuitive method. The KNN requires an integer k,a set of labelled examples and a measure of “closeness” calculated by a distancefunction. For a given unlabelled example x, the algorithm finds the k “closest”labelled examples in the training data set and assign the new point x to the classthat appears most frequently within the k-subset. In other words, a decisionis made by examining the labels on the k-nearest neighbors and taking a vote.Expressing in mathematic formula, the discriminant functions are given by [24]:

gi(x) =ki

k(3.27)

ki is the number of example, labelled as class ωi, and enclosed in a sphericalvolume around unlabelled example x. k is the total number of examples insidethe spherical region. Fig. 3.9 illustrates an example of 5-Nearest Neighborclassifier.

Advantage:

• Analytically tractable, simple implementation

• Uses local information, which can yield highly adaptive behavior

• Lends itself very easily to parallel implementation

Disadvantage

• Large storage requirements

Page 30: QRS Cancellation

24 Methodology

Figure 3.9: The test point is labelled by a majority vote of these samplesenclosed in a spherical region. In the case k = 5, the test point is labelled asred [30].

• computationally intensive recall

• Highly susceptible to the curse of dimensionality

3.6 Post-processing and Diagnostic Decision

The results of classifier on testing data are further post-processed as shownin Fig 3.10. The number of AF beats detected in the sliding non-overlappingwindow of 30 beats was counted. An interval is marked as an AF interval, if anumber of AF, exceeding a particular threshold, is detected in the ECG block.This particular threshold, designated as AF number threshold was conse-quently used as decision variable for receiving operator curve (ROC) analysis.The threshold is designed for each block containing 30 heart beats to smoothingthe signal from small flauctuation, rather than evaluating each heart beat.

The diagnostic accuracy can be expressed through sensitivity, specificity andpredictability in a certain study population. Let the prior probabilities P(A)and P(N) represent the fractions of data with the AF and the fraction of datawithout AF, respectively. Let T+ represent a positive test result (indication ofthe presence of AF) and T− a negative result (indication of the absence of AF).The following possibility arises.

• A true positive is the situation when the test is positive for a datawith AF. The true-positive fraction (TPF) or sensitivity s+ is given asP(T+|A) or

S+ =number of TP decitionsnumber of data with AF

=TP

TP+FN(3.28)

The sensitivity of a test represents its capability to detect the presence ofAF.

Page 31: QRS Cancellation

3.6 Post-processing and Diagnostic Decision 25

Figure 3.10: Post-processing classifier output using moving non-overlappingwindow containing 6 beats in this example. If the segment contains normalsinus beats more than a threshold is classified as AF absent, otherwise as AFpresent.

• A true negative(TN) represents the case when the test is negative fora data without AF. A true negative fraction (TNF) or specificity S− isgiven as P(T−|N) or

S− =number of TN decitions

number of data without AF=

TNTN+FP

(3.29)

The specificity of a test represents its accuracy in identifying the absenceof AF.

• A false negative(FN) is said to occur when the test is negative for adata with AF; that is, the test has missed the case P(T−|A).

• A false positive(FP) is defined as the case where the results of the testis positive when the individual being tested not have AF. The probabilityof this type of error or false alarm, known as the false-positive fraction(FPF) is P(T+|N).

The efficiency of a test may also be indicated by its predictive values. Thepositive predictive value (Predictability) PPV of a test, defined as

PPV = 100 · TP

TP + FP(3.30)

represents the percentage of the cases labelled as positive by the test thatare actually positive [31].

Page 32: QRS Cancellation

26 Methodology

Figure 3.11: Example of receiver operating characteristic curve

It is desired to have a diagnostic test that is both highly sensitive and highlyspecific. An ROC (receiver operate curve) is a graph that plots FPF (1-specificity), TPF (sensitivity) points obtained for a range of decision thresholdor cut points of the decision method. An example of ROC curve is illustrated inFig. 3.11. In this case, this decision variable is particular threshold of detectedAF beats contained in ECG block (AF number threshold), as mentioned above.By tuning the threshold parameter in the window of 30 beats, the optimaltrade-off between sensitivity and specificity can be found. The optimal trade-off between sensitivity and specificity is defined as the point which has minimaldistance to the point (0,1) on the ROC curve, see the point connected to (0,1)in red line in the Fig. 3.11. Here we assume that sensitivity and specificity areequal important. For example, this test has a sensitivity of 99.6% and specificityof 98.7 %, as the threshold is set to be 27. By varying the decision threshold,we get different decision fractions, i.e, choose to operate the sensitivity andspecificity at any point along the curve. The ROC curve is independent of theprevalence of AF.

Page 33: QRS Cancellation

4 QRST Cancellation

4.1 Straight Forward Averaging Algorithm forQRST Cancellation

AF is indicated by the absence of consistent P waves, due to the chaotic atrialdepolarization. The RR intervals vary in time. In AF, the atria are excitedrapidly and irregularly at a fibrillatory rate of 300 to 600 bpm caused by re-entry wavelets (see section 2.2). Fig. 4.1 depicts ECG of a chronic AF patientmeasured by Philips strap. To sum up, AF is characterized by

1. ventricular irregular rhythm

2. presence of atrial fibrillatory activity

Figure 4.1: Example of AF episode acquired by wearable belt system

The most important feature in detecting AF involves ventricular irregular-ity. A vast majority of the cases of AF do, in fact, have marked ventricularirregularity, but the drawback of this criterion is that rhythms other than AFcan also have irregular ventricular responses. So many studies propose to detectthe fibrillatory activity in the surface electrogram. The challenge in detectionof fibrillatory waves is due to its chaotic nature and small amplitude in com-parison to ventricular activity, buried in QRS complexes and T wave in some

Page 34: QRS Cancellation

28 QRST Cancellation

Figure 4.2: High-voltage lead ECG and their respective remainder ECG areshown for an example of (top) NSR and (bottom) AF. The right single heartbeat is template for subtraction in each case [32].

cases. Sometimes, the amplitude of the fibirllatory waves is small enough to beinvisible to the ECG reader.

Janet Slocum [21] presented a method to cancel the ventricular activity fromECG, and used the power spectrum of the atrial fibrillatory wave to detect AF.A mean beat was generated by averaging over all beat windows aligned bythe fiducial points, which is defined as R peak location. For all rhythm, themean beat was aligned with the fiducial points of all the beats windows andsubtracted. Figure 4.2 shows a result of QRST cancellation. Observe that thefluctuating waves in place of P waves, sometimes also T waves, have a meanvalue close to baseline. The average beat subtraction approach uses the fact thatAF is uncoupled to ventricular activity and, therefore the average is subtractedto produce a residual signal which contains the fibrillation waveforms, whereasthe ECG of NSR has a small remainder after subtraction.

The above QRST cancellation relies on the assumption that the averagebeat can represent each individual beat accurately. However, QRS morphologyvaries often dynamically, caused by respiration, premature ventricular beats,fusion beats, etc. The signal may be polluted by a wide range of phenomenaincluding myopotential and electromagetic noise and several other acquisitionrelated events. Fig. 4.3(a) depicts an ECG example of 20 seconds, collectedfrom a chronic AF patient using Philips strap (see section 3.1). Fig. 4.3(b)illustrates a template in red dashed line superimposed on the example of ECGin blue solid line. Obviously this template, calculated by averaging all the heartbeats does not match the ECG data well. The poor fits are due to dissimilarQRS complexes, i.e, high variation in QRS morphology and a different STinterval. Fig. 4.3(c) is the residual signal after subtraction, ranged from -1635

Page 35: QRS Cancellation

4.1 Straight Forward Averaging Algorithm for QRST Cancellation 29

Figure 4.3: (a) An ECG example of chronic AF patient with the length of20 s, measured by wearable ECG-monitoring. (b) The Template averaging allthe heart beats and superimposed on the original ECG segment. (c) Remainderusing the uniform template

Page 36: QRS Cancellation

30 QRST Cancellation

to 710 mV. This cancellation has a poor performance, since the amplitudes ofsome residual QRS complexes are even greater than the amplitudes of originalones, and residual T wave are clearly present in ECG signals. For this purpose,improvements in the cancellation method are carried out in this study, whichare discussed below.

4.2 Improved QRST Cancellation

Figure 4.4: Flow chart of QRST cancellation algorithm.

Fig. 4.4 represents the main sequence of the improved QRST cancella-tion algorithm. The fundamental frequency of the residual signal of fibrillatorybaseline is well below the 4 – 10 Hz range. However, preliminary study re-vealed that harmonics arising from the QRST often produce more energy inthe relevant frequency spectrum range than much lower amplitude fibrillatoryactivity [33]. Therefore, accurate assessment of frequency spectrum of atrialcomponent required selective attenuation of the QRST. In general, the QRSTcomplex is attenuated using a template matching and subtraction technique.The improvement was focused on computing appropriate templates. Appro-priate templates are specified as more than one templates, created for eachmorphology. Nevertheless only one template is calculated if the signal is veryregular. Linear-phase, low and high pass filtering were used to reduce baselinewander and suppress noise before performing QRST cancellation. A Notch filtereliminated the power-line interference. Clustering and RR-interval based beatclassification was performed so that beats with different morphology and cyclelength were separated into different classes. Anomalous beats were rejected infurther analysis. A beat average was then computed for each of the classes.Finally, the remainder was subjected to Fourier Transform and displayed as apower spectrum. Each step will be discussed in great detail in the followingsubsections.

Page 37: QRS Cancellation

4.2 Improved QRST Cancellation 31

4.2.1 Digital Filters

ECG are often polluted by many other noise of various origins. Noise includesmuscle noise, artifacts due to electrode motion, power-line interference, baselinewander, and T waves with high-frequency characteristics similar to QRS com-plexes. The linear digital filters reduce the influence of these noise sources, andthereby improve the signal-to-noise ratio. In this study recursive digital filtersare used, with only small integer multipliers meaning they are both simple toprogram and fast in execution [34].

Low-pass filter This class of filters is designed based on the formula:

yn = xn − xn−m (4.1)

where yn represents the the current (filtered) output sample value from thefilter, xn represents the current input sample, and xn−m represents the inputsample delivered to the filter m sampling periods previously. This time-domaindescription of the filter is converted into a transfer function G(z), which isderived as:

G(z) =Y (z)X(Z)

= (1− z−m) (4.2)

G(z) is the transfer function. X(z) and Y (z) are z transforms of input x(n)and y(n), respectively. In this case, there are m zeros equally spaced around theunit circle, each of which gives rise to a transmission zero in the correspondingfilter frequency response. Cancellation of one of the zeros by coincident givesthe low-pass characteristic. The addition of the pole causes G(z) to be modifiedto

G(z) =1− z−m

1− z−1=

Y (z)X(z)

(4.3)

So that the time-domain recurrence formula becomes:

yn = yn−1 + xn − xn−m (4.4)

The filter is recursive, since each output depends upon a previous outputas well as inputs. The integer m can be adjusted to give the desired cutofffrequency. Filters of this type have the advantage of having a pure linear phasecharacteristic. The phase is said to have a linear phase response if its phaseresponse satisfies one of the following relationships [35]:

θ(ω) = β − αω (4.5)

The cutoff slope and the attenuation my be greatly reduced by using higherorder zeros, and cancelling pole, instead of first order. The transfer functionbecomes:

Page 38: QRS Cancellation

32 QRST Cancellation

G(z) =(1− z−m)n

(1− z−n)n(4.6)

The transfer function of second-order low-pass filter applied in this algorithmis:

G(z) = [1− z−2

2(1− z−1)]2 (4.7)

with the cutoff frequency is 50 Hz at the sampling frequency of 250 Hz.Frequency response of the filter is shown in Fig. 4.5.

Figure 4.5: Top: Magnitude response of the 50 Hz low-pass filter, Button:Phase response of 50 Hz low-pass filter

High-pass filter This class of filter can be extended to the high-pass filterwhich is designed to remove the base-line drift in the ECG signal. The design ofthe high-pass is based on subtracting the output of a first-order low-pass filterfrom an all-pass filter. The transfer function for such a high-pass filter is

G(z) =− 1

128 + z−64 − z−65 + 1128z128

1− z−1(4.8)

The low cutoff frequency of this filter is 0,5 Hz at the sampling frequency250 Hz. The components of 0,05 Hz is reduced in amplitude by about 50 dB.

Removal of power-line interference A well-known method capable of re-ducing power-line interference is the use of a notch filter characterize by a unitgain at all frequencies except at notch frequency where gain is zero. The transferfunction of a second-order notch filter is given by [10]:

Page 39: QRS Cancellation

4.2 Improved QRST Cancellation 33

G(z) =Y (z)X(z)

=12· (1 + a2)− 2a1z

−1 + (1 + a2)z−2

1− a1z−1 + a2z−2(4.9)

The notch frequency ω0 and 3-dB rejection bandwidth related to the filtercoefficients a1 and a2 by the following:

a1 =2cos(ω0)

1 + tan(Ω2 )

, a2 =1− tan(Ω

2 )1 + tan(Ω

2 )(4.10)

In application, if the sampling frequency, sinusoidal frequency (50 Hz in thiscase) and notch band width are fs, fd and BW Hz, then

ω0 = 2π(fs

fd), Ω = 2π(

BW

fs) (4.11)

The desired rejection bandwidth can be obtained by adjusting BW. Themagnitude and phase response of the 50 Hz Notch filter are plotted in Fig. 4.6.

Figure 4.6: Top: Magnitude response of the 50 Hz Notch filter, Button: Phaseresponse of 50 Hz Notch filter

Figure 4.7 compared the noisy ECG signal and the filtered signal after re-moval of ECG signal after removal of baseline wandering, low frequency noiseand power-line interference using the filters described above.

4.2.2 QRS Clustering

In stead of subtraction by an uniform template for the whole block, several tem-plates are designed due to differences in even interpersonal ECG morphology.For this purpose, non-supervised clustering of QRS morphologies is performedon the filtered ECG signal. Clustering creates groups of objects, or clusters,in such a way that the morphologies of objects in the same cluster are very

Page 40: QRS Cancellation

34 QRST Cancellation

(a)

(b)

Figure 4.7: (a) Noisy ECG segment (b) ECG signal after removal of baselinewandering, low frequency noise and power-line interference.

Page 41: QRS Cancellation

4.2 Improved QRST Cancellation 35

similar and the morphologies of objects in different clusters are quite distinct.The cluster analysis on a data set is performed as following procedures:

1. At first, the QRS complex is extracted from QRS onset to QRS offset,which is detected by segmentation program. Each QRS complex is alignedwith fiducial point and stored in an array in equal length. Short QRScomplexes were padded with zero to make them with the required length.

2. A dissimilarity matrix stores distances that are available for all pair ofobjects. This matrix is represented by an m × m (the number of totalheart beats in a segment) table. The subscripts of the distance matrixis consistent with the index of R peak. Equ.(4.12) is the dissimilaritymatrix, where each element d(i, j) represents the difference or dissimilaritybetween the objects i and j. The row and column represents the objects.

DM =

0 d(1, 2) d(1, 3) . . . d(1,m)

0 d(2, 3) . . . d(2,m)...

......

0 . . . d(m− 1,m)0

(4.12)

For all points x, y and z, a distance function must have following proper-ties.

• Nonnegativity: D(x, y) ≥ 0

• Reflexivity: D(x, y) = 0 if and only if x = y

• Symmetry: D(x, y) = D(y, x)

• Triangle inequality: D(x, y) + D(y, z) ≥ D(x, z)

d(i, j) is very small when objects i and j are very similar to each other,and becomes larger the more they differ. To calculate the dissimilaritybetween the objects i and j the most popular distance measure is usedcalled Manhattan or city block distance distance between i and j is givenby:

d(i, j) =b∑

k=a

|xik − xjk| (4.13)

where a, b is the first and last index of QRS array, respectively.

3. The distance information generated in the Equ. (4.12) is used to deter-mine proximity of objects to each other. The pair of QRS complexes isdenoted as similar when their distance is less than the predefined cut-off,termed as similarity threshold. The similarity threshold values are em-pirically selected to assure a sufficient number of QRS complexes includedin the several initial clusters. Fig. 4.8 illustrates the way the algorithmgroups objects into clusters. Let’s treat the QRS as green circles in space

Page 42: QRS Cancellation

36 QRST Cancellation

Figure 4.8: Schematic representation of QRS clustering

(see Fig. 4.8 a). The algorithm searches the similar pair of QRS complexesalong each row, and clusters them at first level (see the circles enclosedby blue ellipse in Fig. 4.8 b). These newly formed clusters are linked toother objects to create bigger clusters at higher level until there are nooverlapping elements in these groups, presented as the contents enclosedby purple ellipse.

4. The remaining objects, which can’t be grouped into any clusters, arelabelled as abnormal QRS complexes (see the isolated circles in Fig. 4.8 b).Unfortunately, the number of labelled abnormal QRS complexes dependsupon threshold similarity. To assure a strong correlation between theobjects of the same cluster, a small initial similarity threshold is selected.In some instances, most QRS complexes could be categorized as abnormalbecause of the different scale, irregularity of ECG, subtle abnormalitiesin shapes. Therefore a second patient specific threshold is used.

5. To verify the constructed cluster, a second threshold is set to control theamount of rejected QRS complexes. The similarity threshold (1st thresh-old) increases and clustering is computed at each iteration, till the finalamount of rejected QRS is less than a second threshold, called as ab-normal threshold. More circles are gathered together for the enlargedblue ellipse in the Fig. 4.8. The abnormal threshold is specified for theindividual data. In progressive iterations, the similarity threshold is in-creased. In later iteration, If the increment of similarity threshold doesnot change the clustering, the abnormal threshold is also increased. Agreater abnormal threshold is assigned to a longer ECG segment.

Each beat in the ECG block was classified as either a dominant or anom-alous beat. Heart beats that contained QRS complexes of the most commonmorphology and amplitude for the rhythm strip were defined as dominantbeats, in another word, the heart beats except for outlier beats derived fromQRS clustering. Premature ventricular beat, fusion beats or beats that sat-urated the amplifiers are defined as anomalous beats, in another word, theoutlier beats derived from QRS clustering. Fig. 4.9 a) plots the ensemble of

Page 43: QRS Cancellation

4.2 Improved QRST Cancellation 37

(a)

(b)

Figure 4.9: (a) The ensemble QRS complexes of the ECG example in the Fig.4.9. (b)Result of QRS clustering for this ECG example.

Page 44: QRS Cancellation

38 QRST Cancellation

QRS complexes of the ECG example in the Fig. 4.3. Fig. 4.9 (b) depicts theresult of QRS clustering for this ECG example, containing 22 heart beats. Thealgorithm above divides 22 heart beats into two clusters: cluster 1 in magentacolor and cluster 2 in green color, made up of 14 and 5 objects, respectively.Three heart beats are labelled as abnormal, plotted in blue color.

(a) (b)

(c) (d)

Figure 4.10: The appropriate templates (red line) superimposed on heart beats(blue line) of each cluster or subgroup for the ECG example in Fig. 4.3. TheQRS complexes of this example are grouped into clusters in the Fig. 4.9. (a)and (b) Cluster 1 in Fig. 4.9 containing medium, long and short RR interval isdivided into 2 subgroups further for short and medium rhythm. (c) Cluster 2made up of only medium heart beats were not divided further. (d) The templateand residual signal for anomalous heart beats are set to zero.

4.2.3 Sub-clustering based analysis on RR-interval

AF is always associated with irregular heart rhythm, meaning the R to R beatscan have very different lengths. Here we want to subtract an average full beattemplate from the ECG signal. In order to accommodate for the different beatlengths, we calculate three different templates of short, medium and long lengthfor every QRS cluster if there are sufficient numbers for the subgroups. Thereby,each RR interval is characterized as one of three state by classifying it as short(S), medium (M) and long (L). Intervals are called short if they do not exceed

Page 45: QRS Cancellation

4.2 Improved QRST Cancellation 39

85% of the mean interval, long if they exceeded 115% of the mean, and mediumotherwise. The running mean interval is given by [18].

rrmean(i) = 0.75 ∗ rrmean(i− 1) + 0.25 ∗ rr(i) (4.14)

where i is the current heart beat index. Subsequently, each cluster is ana-lyzed based on RR interval classification. The cluster that contains heart beatsof different RR classes is divided into subgroups. For instance, cluster 1 con-taining 9 medium, 1 long and 4 short RR interval is divided into 2 subgroupsfor short and medium rhythm (see Fig. 4.10 (a) and (b)). The single longheartbeat is merged with medium subgroup.

4.2.4 Appropriate Templates and Subtraction

Figure 4.11: Flow chart of computing appropriate templates for the examplein the Fig. ??.

Each heart beat is segmented by two kinds of beat windows. The heart beatsfor each class are averaged to generate appropriate templates. Cluster 2 in Fig.4.10 (c) includes only medium heart beats, thus one template is calculated forthis class. In this way, appropriate templates are computed for similar QRSmorphology and RR interval. The template and residual signals for anomalousbeats in Fig. 4.10 (d) are set to zero to prevent their large remainders fromcontributing to evaluation. Fig. 4.10 plots the computed template (red line)superimposed on heart beats (blue line) of each cluster or subgroup for ECGexample in Fig. 4.3. Fig. 4.11 illustrates the steps of computing the appropriatetemplates for this example in schematic form.

Page 46: QRS Cancellation

40 QRST Cancellation

Figure 4.12: (a) An ECG example of chronic AF patient with the length of20 s, measured by wearable ECG-monitoring. (b) Appropriate Templates (redline) superimposed on the original signal (blue line) (c) Remainder after QRSTcancellation using appropriate templates.

Page 47: QRS Cancellation

4.2 Improved QRST Cancellation 41

Figure 4.13: (a) Remainder of the AF Example using the forward averagingalgorithm with a uniform template. (b) Remainder of the AF Example usingthe improved QRST Cancellation with several appropriate templates.

Page 48: QRS Cancellation

42 QRST Cancellation

Figure 4.14: (a) An ECG example of NSR patient with the length of 20 s, mea-sured by wearable ECG-monitoring. (b) The template (red line) superimposedon the original signal (blue line) (c) Remainder after QRST cancellation.

Page 49: QRS Cancellation

4.2 Improved QRST Cancellation 43

(a)

(b)

Figure 4.15: (a) the beat window I is defined as interval from Qon(i) to Qon(i+1), (b) Beat window II is defined as interval from PR+Qon(i) to PR+Qon(i+1).

Two different definitions of beat window are established. Beat window Iis specified as interval form current QRS onset to the subsequent QRS onset(from Qon(i) to Qon(i + 1)), see Fig. 4.15 (a). Beat window II is specifiedas interval from the onset of the current P wave Pon(i) to the onset of thesubsequent P wave Pon(i + 1), see Fig. 4.15 (b). The boundaries of the beatwindow distinguish between the beat window I and II.

Afterward, the corresponding templates are subtracted from the originalsequence after alignment at the fiducial point of each QRS complex. The tem-plate is padded with zero so that its length is equal to the longest heart beatin the same class. Fig. 4.12 (b) depicts the template in red color superimposedon original ECG data in blue color. The three blue heart beats observed in Fig.4.12(b) are abnormal heart beats rejected in averaging, whose template andremainder are set to zero. Fig. 4.12 (c) illustrates the residual signal, rangedfrom -279 mV to 349 mV. Fig. 4.13 compared the residual signal using the

Page 50: QRS Cancellation

44 QRST Cancellation

QRST cancellation algorithm described in section 4.1 (see Fig. 4.13 (a)) andimproved QRST cancellation algorithm (see Fig. 4.13 (b)). This comparisonshows that, the improved algorithm performs considerably better than the for-ward averaging algorithm in the section StraightForwardAveraging. The QRSremainder reduced significantly due to clustering and appropriate templates.The minor residual signal for T wave was achieved by consideration of variationin heart rate related ST interval.

In comparison to the AF example in the previous figures, Fig. 4.14 (a)shows an ECG example of a patient in normal sinus rhythm with the length of20 s, measured by wearable ECG-monitoring. The averaging template in redcolor is superimposed on the original signal in blue color in Fig. 4.14 (b). Theremainder contains very small pieces of QRS complexes and noise in Fig. 4.14(c)

4.2.5 Frequency Spectrum of AF

The fibrillatory wave is usually the result of multiple simultaneous reentrantactivation wavefronts. The average size of reentrant pathways during AF isdependent on atrial wavelength, defined as the product of conduction velocityand refractory period. Long wavelengths are associated with larger and fewerwavefronts, occurring in paroxysmal AF patients, whereas short wavelengthsresults in a great number of small circuits, occurring in chronic AF patients.

The vast majority of ECG recordings analyzed in previous investigationshave exhibited single-narrow banded frequency spectra when applying theQRST cancellation [33][36][37][38][39][21]. Spectral decomposition of residualECG signal revealed that the dominant frequency may result from repetitiveactivations by a reentrant source such as a single focal source within pulmonaryvein. The lower frequency components may represent various degree of spa-tiotemporal organization of waves propagating from that source to the rest ofthe atria [40].

Fibrillatory frequency in human AF determined from the surface ECG ex-hibits a marked individual variability ranging between 4 and 10 Hz or 5 and10 Hz [33][36][37][38][39][21][41], which is in agreement to the values obtainedfrom intra-atrial recordings in previous investigations [42] and physiological in-vestigation: fibrillatory wave typically have a rate between 300 and 600 bpm[43][21][44][39][6]. Asano et al induced AF with rapid pacing in 30 patientsundergoing an electrophysiological study [42]. Those patients where AF ter-minated spontaneously had an average fibrillatory frequency of 5.7 Hz, sig-nificantly lower than the 6.4 Hz recorded in the group of patients where thearrhythmia persisted. Estimating fibrillatory frequency from the surface ECG,Bollmann et al illustrated the fibrillatory frequency increases from paroxysmal(mean 5.1 Hz) to chronic AF (mean 6.9 Hz). Chronic atrial fibrillation hadthe highest frequency. Low frequency fibrillation is more likely to terminatespontaneously or to respond to antiarrhythmic therapy, while high frequencyfibrillation is more often persistent and drug refractory [36].

Page 51: QRS Cancellation

4.2 Improved QRST Cancellation 45

4.2.6 Fourier Transform and Power Spectrum

The Fourier Transform decomposes a signal into purely harmonic wave, whichis given by [45]:

X(f) =∫ ∞

−∞x(t)e−j2πftdf (4.15)

This transform breaks down a signal into its frequency-spectrum as a setof sinusoidal components, converting it from the time domain to the frequencydomain. In practice the Fourier components of data are obtained by digitalcomputation rather than by analogue processing. It is not possible to applythe Fourier transform in the Equ. 4.15 because it is defined for continuousdata. However, a Discrete Fourier Transform (DFT) is available for discretedata. Assume that a waveform has been sampled at regular time intervalsT to produce the sample sequence x(nT ) = x(0), x(T ), . . . , x[(N − 1)T ] of Nsample values, where n is the sample number from n = 0 to n = N − 1. TheDFT of x(nT ) is then defined as the sequence of complex values X(kΩ) =X(0), X(Ω), . . . , X[(N − 1)Ω] in the frequency given by Ω = 2π/NT . The Nreal data values (in the time domain) transform to N complex DFT values (inthe frequency domain) is given by:

X(k) = ΣN−1n=0 e−jkΩnT = ΣN−1

n=0 e−j2πnk/N , with k = 0, . . . , N − 1 (4.16)

However, a large number of multiplication and additions are required for thecalculation of the DFT. For an N-point DFT, there will be N2 and N-12 of themrespectively. If N = 1024, approximately one million complex multiplicationand one million complex additions are required. Clearly some means of reduc-ing these numbers is desirable. The fast Fourier transform (FFT) is a discreteFourier transform algorithm which reduces the number of computations neededfor N points from 2N2 to 2NlgN , where lg is the base 2 logarithm using sym-metric property. The computational redundancy in DFT is reduced applyingthe periodic inherence of e−j2π/N [46]. 1024-points Fast Fourier Transform wasused to calculate the power spectrum in 0-fs

2 Hz frequency band, where fs issampling frequency. The ith element of the power spectrum (PS) is computedfrom Xi of Fourier Transform X as [45]:

PS = (XjX∗j )/1024 (4.17)

Fig. 4.16 depicts the frequency analysis of the residual signals from differentrecords of AF patients in the left panel (Fig. 4.16 (a), (c) (e)) and this of NSRpatients in the right panel: (4.16 (b), (d), (f)). Among them Fig. 4.16 (e)and 4.16 (f) show the power spectra of the remainder from Fig. 4.12 (c) andFig. 4.14 (c). These six records are collected by Philips strap from independentsubjects (see section 3.1). Observe that in the AF case, the absolute powerare concentrated in the frequency band 4 – 10 Hz, either exhibiting a narrowpeak or great power component in this frequency band, whereas the residualsignal has a lower frequency component in this frequency band. Noise enhances

Page 52: QRS Cancellation

46 QRST Cancellation

(a) AF (b) Non-AF

(c) AF (d) Non-AF

(e) AF (f) Non-AF

Figure 4.16: (a), (c) and (e): Frequency spectra from the residual signals areestimated using FFT in the AF cases. (b), (d) and (f): Frequency spectra fromthe residual signals in the non-AF cases.

the power components over the frequency band 0 – 4 Hz in the Fig. 4.16 (b)and (d). The residual QRS signals in the remainder contribute to high powercontent in the Fig. 4.16 (f).

The PS in the frequency band extending from 4 to 10 Hz and from 5 to10 Hz are analyzed, since the start frequency of the band is still ambiguous(see section 4.2.6). Two feature groups are extracted from the power spectrum:mean values of dominant heart beats (see subsection 4.2.2) in the ECG block(QTCan1 – QTCan10) and the evaluation of whole ECG block (QTCan11 –QTCan16), including 30 heart beats. PR10

5 is the percentage of the absolutepower in the frequency band 5 – 10 Hz to the total power from 0 – 125 Hz

(PR105 =

∑10Hz

f=5P∑125

f=0P

) in the ECG remainder, and PR104 is related with power

ratio of frequency band 4 – 10 Hz (PR104 =

∑10Hz

f=4P∑125

f=0P

). Peak ratio denotes the

ratio of the numbers of the heart beats exhibiting maximal power in the 4 –10 Hz frequency band to the amount of the dominant beats in the ECG block.

Page 53: QRS Cancellation

4.2 Improved QRST Cancellation 47

The list enumerates the features extracted from the PS of remainder.

1. QTCan1: The mean PR105 using the the beat window I (see Fig. 4.15

(a)).

2. QTCan2: The mean PR104 using the the beat window I (see Fig. 4.15

(b)).

3. QTCan3: Peak Ratio using the beat window I.

4. QTCan4: The mean PR105 using the beat window II.

5. QTCan5: The mean PR104 using the beat window II.

6. QTCan6: Peak Ratio using the beat window II.

7. QTCan7: The sum of QTCan1 and QTCan3.

8. QTCan8: The sum of QTCan2 and QTCan3.

9. QTCan9: The sum of QTCan4 and QTCan6.

10. QTCan10: The sum of QTCan5 and QTCan6.

11. QTCan11: PR105 using the beat window I.

12. QTCan12: PR104 using the beat window I.

13. QTCan13: Peak frequency in the PS using the beat window I.

14. QTCan14: PR105 using the beat window II.

15. QTCan15: PR104 using the beat window II.

16. QTCan16: Peak frequency in the PS using the beat window II.

Page 54: QRS Cancellation
Page 55: QRS Cancellation

5 Results and Discussion

The most features using the QRST cancellation algorithm noted in chapter 4were fed into various classifiers, which categorize the ECG data into two classes:AF or non-AF. This chapter will discuss the results using diverse features andseveral classifiers on both databases: belt data acquired by Philips strap andMIT-BIH AF database. The features are selected by statistical methods andvisualized. This chapter covers also the drawbacks of QRST cancellation al-gorithm. Possible approaches for QRS clustering and QRST cancellation areintroduced as well as their performances.

5.1 Results on Belt Database

At first the validation of the QRST cancellation algorithm has been done usingthe database acquired by the Philips strap. A total of 6930 beats from 14records in duration of 130 minutes were used for processing, including 8 recordsof chronic AF patients (4650 heart beats) and 6 records from patients in normalsinus rhythm (2280 heart beats). 16 features were extracted for each heart beatbased on QRST cancellation algorithm, defined in section 4.2.6. The table 5.1shows the mean value of the features for each AF record, as well as the numberof heart beats, whereas the table 5.2 shows the similar analysis on 6 records innormal sinus rhythm.

In general, the energy and spectral peak of remainders are concentratedon frequency band 4 – 10 or 5 – 10 Hz in the case of chronic AF patients,extracted by QT1 – QT6 and QT11 – QT16. However the remainders of NSRhave a lower frequency content in this area. These results are in agreementwith the statement mentioned in section 4.2.5. QT7 – QT10 combined peakand power percentage features should be greater in the case of AF than NSR.Higher QT3, QT6, QT13 and QT16 indicated that peak frequency between 4and 10 Hz occurs more frequently in the AF records than the NSR records.We expect the remainder exhibiting a spectral peak in 4-10 frequency band. Infact, this is not always the case. The shift in the peak frequency of AF ECGfor some instances is due to noise, insufficient subtraction, etc. The reason willbe discussed in the section 5.3.1. Bollmann et al [33] didn’t detect the the peakfrom 4 to 10 Hz for each data, either. The features QT7 – QT10 displayed awide range of values over the different patient.

The 16 features are averaged over the whole AF and NSR records, shown intable 5.3. These results of AF and NSR are also plotted in Fig. 5.1, expressedin purple and red bar respectively. As expected, all the mean values of the 16features are much greater in the AF data than in the NSR case data, consistent

Page 56: QRS Cancellation

50 Results and Discussion

Table 5.1: Features of QRST Cancellation for each AF record. HB-Heart beats.

AF(1) AF(2) AF(3) AF(4) AF(5) AF(6) AF(7) AF(8)QT1 55.44 45.06 39.06 35.31 47.38 23.12 29.24 38.35QT2 63.90 53.48 47.58 40.05 55.19 29.53 36.57 46.05QT3 81.21 57.56 41.51 31.42 60.28 23.44 22.33 44.06QT4 55.73 43.80 39.02 37.16 46.84 22.20 32.39 35.60QT5 63.87 51.92 46.44 40.24 54.46 28.20 40.25 42.91QT6 81.27 54.41 38.29 30.07 59.59 23.17 28.58 37.36QT7 136.65 102.62 80.57 60.73 107.67 36.56 51.57 82.41QT8 145.11 111.04 89.09 68.02 115.67 42.97 58.91 90.12QT9 147.01 98.22 77.32 50.23 106.43 35.37 60.97 72.95QT10 145.14 106.33 84.73 61.31 114.05 41.37 68.83 80.27QT11 46.92 32.34 32.36 29.28 38.97 16.63 24.46 26.37QT12 52.17 39.09 38.29 32.49 43.85 22.78 32.03 32.29QT13 6.06 4.80 4.93 3.55 5.08 3.29 3.09 3.60QT14 47.83 31.76 33.34 30.58 38.91 16.07 25.70 24.87QT15 52.03 37.88 39.34 36.67 43.67 21.36 33.40 30.71QT16 6.18 4.82 4.31 4.04 5.09 3.02 3.10 3.20HB 540 690 900 330 1470 120 240 360

Table 5.2: Features of QRST Cancellation for each NSR record. HB-Heart beats.

NSR(1) NSR(2) NSR(3) NSR(4) NSR(5) NSR(6)QT1 36.20 16.21 21.32 44.81 33.89 27.37QT2 42.05 21.89 30.32 52.38 41.81 34.8QT3 39.71 2.82 31.26 54.93 17.92 16.14QT4 16,67 14.39 17.83 44.64 32.38 26.63QT5 19.16 20.19 24.03 52.93 40.07 33.36QT6 5.77 1.79 7.29 52.18 15.15 15.09QT7 75.90 19.03 37.58 99.74 51.81 43.52QT8 81.76 24.71 43.58 107.31 59.73 50.98QT9 22.44 16.19 25.12 96.82 47.53 41.73QT10 24.93 21.99 31.33 105.11 55.23 48.46QT11 25.36 12.48 19.19 36.10 30.65 20.86QT12 29.16 17.16 24.13 41.89 38.72 27.40QT13 7.49 1.87 2.39 3.83 2.82 2.28QT14 14.84 10.96 13.01 32.21 30.30 20.55QT15 16.46 15.42 17.75 44.23 38.05 27.06QT16 10.78 1.94 2.18 3.79 2.69 2.31HB 300 690 480 210 300 300

Page 57: QRS Cancellation

5.1 Results on Belt Database 51

with the higher spectral component in the relevant region.

Table 5.3: Averaging features for AF and NSR records

QT1 QT2 QT3 QT4 QT5 QT6 QT7 QT8AF 42.82 50.83 51.50 42.26 49.88 49.68 94.31 102.32NSR 30.08 36.78 22.90 24.42 30.54 14.45 52.98 56.89

QT9 QT10 QT11 QT12 QT13 QT14 QT15 QT16AF 91.94 99.56 34.07 39.82 4.66 34.14 39.62 4.92NSR 38.88 45.00 23.79 29.41 3.43 29.19 25.4543 3.34

Figure 5.1: 16 QT features are averaged over the whole AF and NSR records

Apart from mean value of features, histograms are displayed to show thedistribution of the features. This histogram counts the number of elementswithin the range of features and displays each range as a rectangular bin. Theheight of the bins specifies the number of values that fall within each range.To simplify comparison, the Y axis in Fig. 5.2 is normalized by the amountof total heart beats and represented in percentage. Fig. 5.2 (a) refers to adistinct feature QTCan14, which is centered on the range 30 – 45 in case of AF(upper) and well below 20 in case of NSR (bottom). In comparison, QTCan11in Fig. 5.2 (b) are overlapping over the range 20 – 40 in the both cases, thuslittle differentiation appears to be present. The histograms show that QTCan1and QTCan2, QTCan4 and QTCan5, QTCan7 and QTCan8, QTCan9 andQTCan10, QTCan14 and QTCan15 are highly correlated.

Page 58: QRS Cancellation

52 Results and Discussion

(a)

(b)

Figure 5.2: Histogram of QTCan14 (a) and QTCan11 (b) comparing the AFrecords (upper) with NSR records (bottom). QTCan11 and QTCan14 are thepower percentages in the frequency band 5 – 10 Hz using the beat window I andusing the beat window II, respectively.

Page 59: QRS Cancellation

5.1 Results on Belt Database 53

Table 5.4: Results of AF detection using QRST Cancellation on wearable beltsystem. The measures are expressed in %. Legend:Met.-classification method,Se.-Sensitivity, Sp.-Specificity, Pr.-Predictability.

Feature Met. Se. Sp. Pr.QTCan1 QDC 80.77 78.19 64.29QTCan2 3-KNN 83.21 85.66 78.43QTCan3 QDC 80.77 81.90 78.57QTCan4 3-KNN 91.56 80.71 71.43QTCan5 3-KNN 86.04 86.50 78.57QTCan6 QDC 84.19 86.19 78.57QTCan7 3-KNN 89.61 83.43 71.43QTCan8 3-KNN 91.80 83.04 78.57QTCan9 3-KNN 93.59 83.57 78.57QTCan10 3-KNN 92.45 83.57 78.57QTCan11 3-KNN 86.77 88.47 64.29QTCan12 3-KNN 88.72 86.22 71.43QTCan13 QDC 98.07 57.74 50.00QTCan14 KNN 81.51 96.60 85.71QTCan15 3-KNN 85.61 91.53 78.57QTCan16 QDC 100.00 55.71 50.00

These features are fed into classifiers trained to recognize the AF data fromNSR data using the training set. Different classifiers were applied: normaldensity based linear classifier (LDC), normal density based quadratic classifier(QDC), back-propagation neural network with one hidden layer of 10 neuronunits (10-ANN) and K-nearest neighbor classifier (KNN). Classification deci-sions on testing set were evaluated by statistical parameters: sensitivity, speci-ficity and predictability. Table 5.4 summarized the best results using the fourclassifiers noted above, which received one single QTCan feature independently.For input of one feature KNN and QDC have the best performance on thisproblem. The highest sensitivity, specificity and predictability are achieved us-ing the feature QTCan14: 81.51%, 96.60% and 85.71%. The features using thebeat window II (QTCan4 – QTCan6 and QTCan14 – QTCan16) provide highersensitivity and specificity than the ones using the beat window I (QTCan1 –QTCan3 and QTCan11 – QTCan13). The features QTCan7 – QTCan11 dis-tinguish AF and NSR data more efficiently than the single feature QTCan1,QTCan2, QTCan4 and QTCan5. The power spectra of the whole ECG blockof 30 heart beats (QTCan11 – QTCan12 and QTCan14 – QTCan15) yieldthe better sensitivity and specificity than the mean power spectra (QTCan1 –QTCan2 and QTCan4 – QTCan5). Here we assume that the sensitivity andspecificity are equal important, and the optimal cur-off between sensitivity andspecificity is determined by ROC curve.

The ventricular irregularity plays an important role in differentiating be-tween AF and other irregular rhythm. To test the effect on the combination

Page 60: QRS Cancellation

54 Results and Discussion

Table 5.5: Results of AF detection using features of RR interval andQRST Cancellation on wearable belt system. The measures are expressedin %. Legend:Met.-classification method, Se.-Sensitivity, Sp.-Specificity, Pr.-Predictability.

Features Met. Se. Sp. Pr.RR interval QDC 95.24 94.64 92.61

RR interval, QTCan1 QDC 96.43 96.43 92.86RR interval, QTCan2 LDC 97.32 95.71 88.71RR interval, QTCan3 QDC 98.21 96.43 92.86RR interval, QTCan4 10-ANN 99.11 96.43 92.86RR interval, QTCan5 QDC 96.43 97.02 92.86RR interval, QTCan6 KNN 99.35 94.64 92.86RR interval, QTCan7 QDC 97.32 95.83 92.86RR interval, QTCan8 QDC 96.43 96.43 92.86RR interval, QTCan9 QDC 95.54 97.62 92.86RR interval, QTCan10 QDC 97.32 96.00 85.71RR interval, QTCan11 QDC 98.17 98.40 92.68RR interval, QTCan12 QDC 98.56 98.21 92.68RR interval, QTCan13 QDC 98.27 98.69 85.71

RR interval, QTCan14 QDC 99.46 100.00 100.00RR interval, QTCan15 QDC 98.56 98.81 92.86RR interval, QTCan16 QDC 98.42 98.10 85.71

Figure 5.3: Receiver operating characteristic curve for combining features ofQTCan14 and RR interval.

Page 61: QRS Cancellation

5.2 Results on MIT Database 55

of features, RR interval (see section 3.4) was input the classifiers in additionalto the features of QRST cancellation. The results of AF detection using thecombined features are described in the table 5.5. As expected these combiningfeatures improve the sensitivity, specificity and predictability of AF detectionsignificantly in comparison to the single feature. The best result using featuresof only RR interval is sensitivity: 97.90%, specificity: 93.33% and predictability:85.71%. The performance of KNN with multi-input features is not as superioras it was on the single input feature. QDC classifier has a better performance,which yielded sensitivity: 99.46%, sensitivity: 100% and predictability 100%using combination of the RR interval and QTCan14. Figure 5.3 depicts theROC curve for this instance, illustrating the change in sensitivity and false pos-itivity (expressed in percentage in the figure) determined by decision variable,presented as diagonal cross. False positivity is defined as one minus specificity.The decision threshold is here the number of detected AF beats (NAF = 2 . . . 29)in sliding window of 30 beats. If the threshold exceeds NAF , the segment isdefined as AF. The cut-point 28, connected with (0,1) in red line, is optimaltrade-off between sensitivity and specificity. The fact that only chronic AF andNSR data was evaluated without paroxysmal AF, has a big influence on theresult of 100%.

5.2 Results on MIT Database

A comparative study using MIT Atrial Fibrillation database was performed.This database includes twenty-three long-term ECG recording of paroxysmalAF patients. Among them, eighteen recordings were analyzed, which containAF as well as NSR episodes. The other five recordings (ID: 05091, 07162,07859, 08405 and 08455) were excluded in the further analysis due to too shortor no segment of AF episodes. Table 5.6 enumerates the duration of annotatedsegment in minutes as well as the number of heart beats for each record. Intotal eighteen records in duration of 7937 minutes were selected to validate thealgorithms, including 246600 heart beats of AF episodes and 435600 heart beatsof NSR episodes.

The results on belt data have already given a sense, how well the features ofQRST cancellation differentiate between AF and NSR. The features extractedfrom MIT data were analyzed using the same method: visualization, calculationof the mean value and distribution histogram. These features have the similarperformance with those extracted from the belt data. Generally the most energyderived from remainder of AF data is contained within 4 – 10 Hz, whereas theremainder of NSR has a lower frequency content in this area. Therefore the fea-tures from AF data are greater than NSR data, except QTCan13 and QTCan16.More distinct features were obtained using the beat window II (QTCan4 – QT-Can6, QTCan9 – QTCan10 and QTCan14 – QTCan16) than using the beatwindow I (QTCan1 – QTCan3, QTCan7 – QTCan8 and QTCan11 – QTCan13).The reason will be explain in the section 5.4. QTCan1 and QTCan2, QTCan4and QTCan5, QTCan7 and QTCan8, QTCan9 and QTCan10, QTCan11 andQTCan12, QTCan14 and QTCan15 are strongly correlated. For example, Fig.

Page 62: QRS Cancellation

56 Results and Discussion

(a) (b)

(c) (d)

(e) (f)

Figure 5.4: Plot features (a) QTCan4 (b) QTCan6 (c) QTCan10 (d) QTCan15(e) QTCan2 and (f) QTCan11 of AF (red solid line) and NSR (blue dashed line)episode from record 04746.

Page 63: QRS Cancellation

5.2 Results on MIT Database 57

Table 5.6: The duration of annotated segment in minutes and the number ofheart beats for each MIT AF database. ID-patient ID, Pos. HB-the numberof heart beats in AF episodes, Neg. HB-the number of heart beats in NSRepisodes, HB-the number of total heart beats in each record.

ID AF(min) NSR(min) AF+NSR Pos. HB Neg. HB HB04015 3.85 93.41 97.26 600 7680 828004043 130.04 466.75 596.79 16170 45420 6159004048 5.73 506.39 512.12 960 34170 3513004126 22.59 531.24 553.83 3150 36750 3990004746 206.46 173.90 380.36 30900 10170 4107004908 37.62 535.14 572.76 5910 54330 6024004936 439.55 114.52 554.07 40350 6960 4731005121 385.11 141.12 526.23 33240 10800 4404005261 7.91 485.77 493.68 1110 36210 3732006426 384.10 27.80 411.90 35940 2340 3828006453 4.51 492.66 497.17 510 31140 3165006995 93.86 159.02 252.88 8730 27570 3630007879 370 118.98 488.98 40080 9210 4929007910 33.51 137.05 170.56 2490 29970 3246008215 95.32 118.3 213.62 7170 10170 1734008219 131.76 273.29 405.05 15060 26820 4188008378 24.32 371.03 395.35 1980 30270 3225008343 16.39 150.06 166.45 2190 10350 12540Total 2394.45 5542.20 7936.65 246600 435600 682200

(5.4) plots the features QTCan4, QTCan6, QTCan10, QTCan15, QTCan2 andQTCan11 of AF (red solid line) and NSR (blue dashed line) episode from record04746. Obviously QTCan2 and QTCan11 can not distinguish AF from non-AFwell.

Effective features were selected by statistical methods manually: visualiza-tion, mean values and histogram. The performance of combining features wasalso analyzed by varying the number of features input to the classifier. Distinctfeatures of RR interval and QRST cancellation were given to LDC, QDC and10-ANN classifiers, instead of all the features due to computation constrains.3-KNN was not applied due to its expensive computation for large amount ofdata. The table 5.7 summarized the best outcoming results of these three clas-sifiers using the feature of RR interval, QRST Cancellation and combinationof the both features. These results revealed that significant ventricular irreg-ularity is crucial criterion to distinguish AF from NSR data, giving the bestresult: sensitivity 89.85%, 89.14 % and 76.50%, in comparison to the otherone single feature. The performance of QTCan features on MIT data is notas good as this on belt data. MIT data is much longer and noisier than beltdata, containing diverse ECG morphology, thus the analysis of MIT data ismuch more complicated and difficult. Therefore the sensitivity, specificity and

Page 64: QRS Cancellation

58 Results and Discussion

Table 5.7: AF detection using feature of RR interval, QRST Cancellation andcombining the both features on MIT database. The measures are expressedin %. Legend:Met-classification method, Se.-Sensitivity, Sp.-Specificity, Pr.-Predictability.

Features Met. Se. Sp. Pr.RR interval QDC 89.85 89.14 76.50QTCan4 10-ANN 76.83 77.45 60.89QTCan5 10-ANN 77.03 78.65 61.23QTCan6 QDC 79.11 77.25 56.73QTCan9 10-ANN 81.06 75.29 56.91QTCan10 LDC 78.39 79.50 60.26QTCan14 LDC 72.01 60.32 51.74QTCan15 LDC 73.72 75.31 61.51

RR interval, QTCan4 QDC 93.07 90.38 78.90RR interval, QTCan5 QDC 93.83 90.12 79.15RR interval, QTCan6 ANN 91.11 91.96 79.17RR interval, QTCan9 10-ANN 91.74 91.53 79.56RR interval, QTCan10 10-ANN 91.80 91.62 80.00RR interval, QTCan14 10-ANN 91.33 90.04 78.30

RR interval, QTCan15 10-ANN 91.14 92.01 82.08

predictability obtained using MIT data is lower than these using the belt data,although the same QRST cancellation algorithm was utilized. Combining theQTCan features with the RR interval features enhance the sensitivity, speci-ficity and predictability of AF detection. A similar sensitivity, specificity andpredictability is achieved using QTCan4, QTCan5, QTCan9, QTCan10, QT-Can14, QTCan15. The combination of the features RR interval and QTCan15have a slightly superior performance, sensitivity: 91.14%, specificity: 92.01%and predictability: 82.08%.

5.3 Discussion

5.3.1 Limitation of QRST Cancellation

It is well known that AF is associated with chaotic and rapid atrial activity.The estimation of atrial activity in the surface ECG based on spectral analysisis attempted by separating ventricular activity. Subtraction of the averagedQRST complex from each individual beat is the standard method for producinga signal which mainly contains atrial activity – the residual ECG signal. Itis highly desired, the dominant energy lies in frequency band extending from4 to 10 Hz, since this frequency band is identified as the atrial frequency infibrillatory rhythm. Unfortunately, it is not always this case in reality. Thereasons of shifted peak frequency were investigated in order to provide a precisedetection of fibrillatory waves in the future.

Page 65: QRS Cancellation

5.3 Discussion 59

1. Invisible Fibrillatory waves: Fibrillatory waves are often of very lowamplitude or not apparent in the ECG data. For example, few fib-rillatory waves are presented in the ECG of Fig. 5.5. But the heartbeat variability of this episode is clearly higher than the NSR data,thus it is labelled as AF.

Figure 5.5: The fibrillatory waves in this AF example (Record 04015, MIT AFdatabase) are not apparent.

2. Annotation: Sometimes chaotic atrial activity is observed in the ECGdata labelled as NSR (see Fig. 5.6). This chaotic waves results ina peak or high spectral energy exhibiting in the frequency band 4-10 Hz. But the ventricular activity is regular relatively, thus it islabelled as NSR episode.

3. Noise: Noise in ECG signal causes considerable errors, e.g., false detec-tion of QRS on- and offset, missing R peak, great distances calculatedfor each pair of QRS complexes, which may be denoted as abnormalheart beat and false QRS clustering depending upon R peak detec-tion, QRS on- and offset. More energy in the relevant frequencyspectrum range is produced by this noisy than much lower ampli-tude fibrillatory activity. Filters can not handle this problem in asatisfactory way. This noise is inside the physiological bandwidth(0.5 – 50 Hz), thus can not be eliminated by the low pass filter witha cutoff frequency of 50 Hz. Fig. 5.7 shows an example of a noisysignal, containing noise below 50 Hz after filtering, and an accuratedelineation of QRS complexes is impossible.

4. Insufficient subtraction This algorithm is based upon a combinedQRS and RR interval template. However a variable P wave, QTinterval and T wave may require separate templates, which are notconsidered in this study. For some data, P wave, QT interval and

Page 66: QRS Cancellation

60 Results and Discussion

Figure 5.6: NSR example (the 6th NSR record of belt database) with chaoticatrial activity.

Figure 5.7: ECG signal from record 06426 (MIT database) is polluted by noiseand causes considerable error in QRST cancellation.

T wave change dynamically and frequently, which have impact onthe precision of the technique. The uniform templates of P wave,QT interval and T wave cannot match the signal well and result ininefficient subtraction of P wave and T wave. The pieces of QRS, Twave and P wave in the remainder increase the power spectrum inthe related frequency band.

Page 67: QRS Cancellation

5.4 The first and the beat window II 61

(a)

(b)

Figure 5.8: (a) One ECG example from NSR(1) of belt data (see table 5.2) inblue solid line superimposed onto the template using beat window I in red dashedline, remainder and its power spectrum. (b) This ECG example superimposedonto the template using the beat window II, remainder and its power spectrum.

Page 68: QRS Cancellation

62 Results and Discussion

5.4 The first and the beat window II

The results on the belt database and MIT database revealed that the featuresextracted by template using the beat window II distinguish AF and NSR databetter than using the beat window I. Beat window I is defined as interval formcurrent QRS onset to the subsequent QRS onset (from Qon(i) to Qon(i + 1)),see Fig. 4.15 (a). In the second case, the heart beat is counted from Pon(i) toPon(i + 1) see Fig. 4.15 (a). The beat window I placed the P wave in the endof beat window, whereas the second one placed the P wave in the beginning.The location of P wave changes over a large range as a result of QT dispersion.Consequently the subtraction using the beat window I cannot remove the Pwave efficiently, because the P waves in different locations are averaged. The Pwave has a high frequency component in the bandwidth of 4-10 Hz (specifiedlater in Fig. 5.10), which affects the specificity of QRST cancellation algorithm.Nevertheless, the PR interval is relative constant, thus the template using thebeat window II represents the P wave in most heart beats accurately. Fig. 5.8(a) shows one ECG example from the first NSR record of belt data (see NSR(1)in the table 5.2) in blue solid line superimposed onto the template using the beatwindow I in red dashed line, the remainder, as well as the its power spectrum.Fig. 5.8 (b) shows the results using the beat window II. P wave present inthe remainder1 resulted in a peak of 5.8 Hz exhibiting in the power spectrum,thus false detection of AF. In comparison, there are no P waves observed in theremainder2. Therefore the peak location in Fig. 5.8 (b) is outside the relevantfrequency band.

5.5 QRS clustering Methods

Numerous clustering algorithms are available in the literature. Different QRSclustering methods were studied. Choosing the correct number of clusters is achallenge. Too few clusters result in QRS complexes with very different mor-phologies being clustered together, and thus inaccurate templates. Too manyclusters result in too few QRS complexes being used to train each cluster andresults in over-fitting.

One possible approach of unsupervised QRS clustering is to form a pluralityof different templates by placing the first QRS complexes within a first clusterand comparing the second QRS complexes to the beat window I derived byaveraging the QRS in the first cluster. If, for instance, the second QRS complexconforms to the beat window I within a certain degree set by a threshold, thesecond QRS complex is placed in the first cluster, otherwise forms a secondcluster. In each iteration the templates are updated when the new beats areallocated to it. Each subsequent QRS complexes is compared to the existingtemplates and is either grouped into the one that provides the closest distanceor forms a entirely a new cluster. The clusters contain one or two heart beatsare labelled as anomalous heart beats and excluded in the further analysis. Iftoo many heart beats fall into abnormal groups, the steps for establishmentof cluster structure are repeated with a increased threshold. This algorithm

Page 69: QRS Cancellation

5.5 QRS clustering Methods 63

yielded similar results to the algorithm described in section 4.2.2 on ECG blockin short length. But this time-consuming algorithm is not suitable for largedatabase. Hence this algorithm is not incorporated in AF detection framework.

(a) (b)

(c) (d)

Figure 5.9: (a) Ensemble QRS complexes in the example of Fig. 4.9. (b) – (c)Three clusters created by K-mean clustering. The number in title of each figureis the cluster size.

A conventional clustering algorithm: K-mean clustering was tested, whichis one of the simplest unsupervised learning algorithm. K-means treats eachobservation in the data having a location in space. It finds a partition in whichobjects within each clusters are as close to each other as possible, and as farfrom objects as possible. Each cluster in the partition is defined by its centroid.The centroid for each cluster is the point, to which the sum of distances from allobjects in the cluster is minimized. K-means uses an iterative algorithm thatminimizes the sum of distances from each object to its cluster centroid, over allclusters. This algorithm moves objects between cluster until the sum cannot bedecreased further. The algorithm is composed of the following steps [47]:

1. Place K points into the space represented by the objects that are beingclustered. These point represents initial group centroids.

2. Assign each object to the group that has the closest centroid.

Page 70: QRS Cancellation

64 Results and Discussion

3. When all objects have been assigned, recalculate the position of K cen-troids.

4. Repeat steps 2 and 3 until the centroids no longer move, that means thesum of distances from each object to its cluster centroid are minimized.

Fig. 5.9 depicts partitioning the QRS complexes in the example (see Fig.4.9) into three clusters, created by K-mean clustering. Note that the anomalousheart beats are not separated and fall in incompact cluster 2. Furthermore, theobjects in cluster 1 are not distinct from these in cluster 2. The last problemis particularly troublesome, since we do not know how many clusters the heartbeats in ECG block should be partitioned in. Therefore, K-mean clustering isnot incorporated in AF detection framework, either.

5.6 Survey of QRST cancellation using appropriatetemplates

In the study [33] it was proposed to obtain the fibrillatory frequency using QRSTcancellation algorithm with appropriate templates. Appropriate templates areadopted by comparing each QRST interval with the mean duration for all theheart beats. Each QRST interval is then determined to occur from its ownonset to the onset of subsequent QRST interval. The heart beat is consideredto be ectopic if the duration of QRST exceeds the product of 1.2 times mean,otherwise to be normal heart beats. Based on the comparison, the QRSTcomplexes are either added and averaged in with a conducted a template or anectopic template. Based on the result of this step, the signal processor selectsthe appropriate template and subtracts the normal and ectopic templates fromthe corresponding heart beats respectively. This technique does not take thevariation in QRS morphology into account, which occurs very frequently. Morethan 10% of ECG recordings were not analyzable using this technique.

Hnatkova stated an approach to compute the templates of QRS and T waveand subtraction of QRS and T wave separately, based on self-similarities of theECG signals in [48]. Self-similarities between corresponding QRS and corre-sponding T wave were accessed using correlation coefficients. It was performedin two steps; the first phase evaluated the template, and the second phase es-timated the similarity using correlation coefficients. The first QRS sample wasidentified with the predefined window, 200 ms window around the QRS fidu-cial point. The cross-correlation coefficient was computed within a segment ofthe ECG that followed/preceded the fiducial point by the same distance. Thepoint and the value of correlation coefficient was saved for each QRS sample.The pair of ECG samples giving the maximum correlation, which exceeded thepredefined cut-off was then selected as basic template. If no basic template atthe upper required correlation coefficient the next ECG sample was tested. Thesecond step of the algorithm used the basic template which was correlated withthe rest of ECG signal. The above described method was again utilized. Theremaining un-matched ECG were repeatedly tested with the required cross-correlation decreased in steps of 0.01 until the lower limit was reached. The

Page 71: QRS Cancellation

5.6 Survey of QRST cancellation using appropriate templates 65

actual content of each QRS sample was again used to update the template. Insuch a way, there was assigned a template for most of ECG samples. The samemethods was utilized to compute the template for T wave. The generation ofT wave template used a 450 ms window, which started 100 ms after the QRSfiducial point.

The study population consisted of 23 patients, but only in 20 was QRSand T wave subtraction feasible. According to the experience, the recognitionof T wave requires clean signal. In the case of atrial fibrillation, a less cleansignal is present due to continuous atrial fibrillatory wave in the signal. Forinstance, it’s difficult to delineate T wave in Fig. ??, where the fibrillatorywaves are superimposed into T waves. An variable QT interval requires separatetemplate. This algorithm generated only one most common template, which isnot suitable under some circumstances, e.g., the AF example in Fig. 4.13.

Figure 5.10: Frequency spectrum of the entire P wave presented in 10 – Hzfrequency bands in patients and controls. PAF: paxoxysmal atrial fibrillation.adapted from [49]

In the beginning of the final thesis, only the templates of QRS complexesand T wave were subtracted from ECG signal instead of the mean heart beat.As a result, some remainder of the NSR data exhibited a high spectral energyin 4 – 10 Hz frequency band, which did not allow the differentiation of AFfrom NSR. Fig. 5.10 depicts the high frequency contents from 4 to 10 Hz inthe power spectrum of entire P wave in the case of PAF and NSR enclosed inyellow area. Fig. 5.8 (a) shows the frequency spectrum of a remainder of NSRdata presented with P waves.

Page 72: QRS Cancellation

66 Results and Discussion

5.7 Results summary

Feature extraction was performed both automatically using a decision treestructure and manually by looking at different scattered plots and statisticalparameters such as the correlation matrix. Only two features as an input forclassifier were selected. We found that automatic analysis delivered one featurefrom the R-R interval analysis (fifth element of Moody matrix RR5 [18]) andone feature from the group of P template matching (number of found P waves inthe window of 30 beats long-PtemMatch). In manual selection we concentratedon the selection of parameters only from the first R-R group in order to obtainless computational expensive system (first and sixth element of Moody matrix[18] - RR1 and RR6 ). The results are summarized in Table 5.8.

Table 5.8: AF detection using wearable belt system incorporated to intelligenttextile. The measures are expressed in %. Legend:Met-classification method,V.Er.-validation error, Se.-Sensitivity, Sp.-Specificity, Pr.-Predictability.

Feature Met. V.Er. Se. Sp. Pr.

RR1,PtemMat,QTCan

LDC 2.65 99.32 95.71 88.71QDC 2.67 99.46 100 100

3-KNN 0.71 99.35 94.64 92.8610-ANN 0.69 99.11 96.43 92.86

RR5,PtemMat

LDC 4.50 98.13 96.79 78.57QDC 3.68 98.27 98.10 85.71

3-KNN 3.43 98.17 95.12 85.7110-ANN 2.24 99.85 96.31 85.71

RR1,RR6

LDC 4.63 97.90 93.33 85.71QDC 3.65 95.24 94.64 92.86

3-KNN 7.52 92.25 91.79 85.7110-ANN 2.96 95.10 94.64 92.86

Figure 5.11: Decision curves comparison demonstrated on R-R interval parameters.

In terms of the error on the validation data (beat-to-beat based detection),QDC yields the best results in both cases. After post-processing of classifier

Page 73: QRS Cancellation

5.7 Results summary 67

output - see Fig. ??, the results are summarized using sensitivity, specificityand predictability measures. The decision surface curves for the R-R featuresare depicted in Fig. 5.11.

Figure 5.12: Performance comparision using ROC approach. The decisionthreshold is here the number of detected AF beats (from NAF = 2 . . . 29) insliding window of 30 beats. If the threshold exceeds NAF than the segmentis labelled as AF. OTO is the optimal trade-off between Sensitivity and Speci-ficity.Legend: ’dash-3KNN’, ’solid-LDC’, ’dot’-QDC, ’dashdot’-10ANN.

Since the classifier results are further post-processed in a sliding window, adesign parameter determining the final segmentation classification can be usedto obtain receiver-operating curve. This threshold determines if the segment isAF or not-see Fig. 3.10. By tuning the threshold parameter in the fix windowof 30 beats, the optimal trade-off between sensitivity and specificity can befound-see Fig. 5.12. The optimal trade-off is defined as the minimum distancebetween the point (0,1) and the points on the ROC curve. It can be seen thatbest results in terms of sensitivity are achieved using with combination of threefeatures RR5, PtemMat, QTCan - PR ratio in 5-10Hz frequency band withcombination of ANN classifier.

Finally, in the last two Fig. 5.13-5.14, the density estimation of underlyingdata is shown. The two densities are slightly overlapping resulting in final error3.6% on validation data set.

Figure 5.13: Bayes density estimation of underlying data. The covariancesmatrices are not equal which result is quadratic discrimination function.

Page 74: QRS Cancellation

68 Results and Discussion

Figure 5.14: Density estimation in three dimensional space.

In case of MIT-Database, the results are depicted in Table 5.9. The numbersare not so high like in case of Belt data due to bigger presence of noise andartifacts in Holter recordings that were used for MIT AF Database creation.

Table 5.9: AF detection using MIT AF Database. The measures are expressedin %. Legend:Met-classification method, V.Er.-validation error, Se.-Sensitivity,Sp.-Specificity, Pr.-Predictability.

Feature Met. V.Er. Se. Sp.

RR5,PtemMat,QTCan

LDC 4.32 90.00 84.68QDC 3.61 93.83 90.12

3-KNN NA NA NA10-ANN 2.12 91.45 92.01

RR5,PtemMat

LDC 4.50 89.23 86.12QDC 3.68 91.15 87.96

3-KNN NA NA NA10-ANN 2.24 91.65 87.47

The similar comparison proceeding was carried out like in case of Belt Data-base. In Fig. 5.15 the four classifiers are compared. The best separation of bothclasses is achieved by QDC classifier again. To visualize better its statisticalcharacteristic, the density function in two dimension in form of contours and itsthree dimensional counterparts are shown in Fig 5.16, Fig. 5.17 respectively.

Page 75: QRS Cancellation

5.7 Results summary 69

Figure 5.15: Decision curves comparison demonstrated on R-R interval and Pwave template matching parameters.

Figure 5.16: Bayes density estimation of underlying data. The covariancesmatrices are not equal which result is quadratic discrimination function, MITAF Database.

Figure 5.17: Density estimation in three dimensional space, MIT AF Database.

Page 76: QRS Cancellation
Page 77: QRS Cancellation

6 Summary and Perspective

AF is common arrhythmia, arising from the disturbance of initiation and prop-agation of excitation pattern in atrial tissue. In the ECG AF is indicatedby irregular ventricular rhythm, absence of consistent P wave and presence ofrandom fibrillatory waves. An automatic method for the detection of atrialfibrillation has been developed, differentiating the ECG signals with AF andwith NSR.

The QRST cancellation algorithm was evaluated for two databases: the beltdatabases, collected from 8 chronic AF patients and 6 healthy subjects at restusing a chest belt with dry electrodes yielding 1 lead ECG; and 23 long-termECG of paroxysmal AF patients including AF episodes and NSR episodes fromMIT-BIH atrial fibrillation database. Based upon straight forward averagingalgorithm, the QRST cancellation algorithm was improved to generate appro-priate template. This algorithm combined QRS clustering and RR intervalclassification, so that the template presented the individual heart beat moreaccurately. This algorithm is comprised of four major steps.

• First, the ECG signals were preprocessed, and only the region between0.5 – 50 Hz was kept for analysis to avoid contributions from noise of highfrequency noise, baseline wonder and power-line interference. Fiducialpoints were detected using our existing processing system.

• In a second step all beats were divided into classes of heartbeats withsimilar QRS morphologies and ventricular cycle length using unsupervisedapproach. Abnormal heart beats were rejected in the further analysis. Foreach class of normal heartbeat, an averaged heartbeat was calculated asappropriate template. Hereby two definitions of heart beats window weretested.

• The third step was the subtraction of the corresponding averaged heartbeats from the original sequence after alignment with each QRS complexin order to remove the regular ventricular signal parts.

• Finally, the residual signals were subjected to Fast Fourier Transformationto analyze the power spectrum. Regarding the survey on frequency spec-trum of AF, the features which reflects the electrophysiological changesmanifest in the power spectrum of AF remainder, were extracted in a slid-ing window consisting of 30 beats. The results revealed that the energyand spectral peak of remainders are concentrated on frequency band 4 –10 or 5 – 10 Hz in the case of chronic AF patients, whereas the remainderof NSR data has a lower frequency component.

Page 78: QRS Cancellation

72 Summary and Perspective

The features of power percentage and peak location were handled into var-ious classifiers for pattern recognition which classify the ECG into two classes:AF present and AF absent. The outcomes of classifiers are post-processed togive a optimal cutoff between sensitivity and specificity. Finally, the accuracyof classification decision were measured by statistical parameters. The bestresults of sensitivity: 99.46%, specificity: 100.00% and predictability 100.00%was achieved on belt data. The best result on MIT data is sensitivity: 91.14%,specificity: 92.01% and predictability: 82.08%.

In this study the QRST algorithm which accounts for rapid variations inQRS morphology and RR interval, were developed and validated on two data-bases. The results show that this method performs considerably better thandoes straightforward averaging method. Application of QRST cancellationfeatures allowed improved differentiation of AF from other non-AF irregularrhythm than using the RR interval series alone. The method for automatic AFdetection using simple features along with LDC, QDC, KNN and ANN clas-sifiers has been presented. The system works with high sensitivity, specificityand predictability.

There is some room to improve the QRST cancellation algorithm. Super-vised clustering methods can be tested, e.g, artificial neural network. Thevariation in P wave, T waves and QT interval should be taken into consider-ation in the further work. The remainders of P wave and T wave contributeto high spectral power in the relevant frequency band, which affect the sensi-tivity and specificity of the algorithm. For classifiers a hierarchical structurecould be established, in which the features are combined in a weighted fash-ion. RR interval which plays an important role in a differentiating between AFand other irregular rhythm, should be considered at first level. This approachwould lead to a system of AF detection with personalized feature extractionand personalized classifiers for individual recording in the future.

Page 79: QRS Cancellation

A Abbreviations and Acronyms

AF = atrial fibrillationAP = action potentialAPD = action potential durationAPG = right appendageAV = atrioventricularAVR = atrioventricular ringbpm = beats per minuteCHF = congestive heart failureCS = coronary sinusCT = crista terminalisERP = effective refractory periodJSR = junctional sarcoplasmic reticulumNSR = network sarcoplasmic reticulumMDP = maximum diastolic potentialSR = sinus rhythmWM = working myocardium

Page 80: QRS Cancellation
Page 81: QRS Cancellation

B COOKING BOOK FOR AFDETECTION TOOLBOX

I. Configuration

1. Open Config AFDetection.m and AFConfig.m and edit the pathswhere your data and your source code is saved.

2. Call Config AFDetection.m to install the toolbox

II. Segmentation (R,P waves peaks detection) Both database

1. Open SegmentationSignal.m

a) Choose database,e.g. Database=’MIT’;b) Uncomment the section for MIT or Own databasec) The files will be save to D:\AtrialFibrillationData\

, e.g. Segmentationnor_a_050725_1.mat

III. Noise Level Detection

In case of OWN database, an algorithm for noise section determinationwas developed. Just start DetectNoise.m.

IV. Feature Extraction

MIT Data - Small Training & Test set = validation set

1. P wave template selection

a) The nice P waves was selected for each signal in SelectPWave-forMITDat.m

b) First, the appearance of P waves for each signal is defined usingvariables NPwave_Segment_lengthTEMP=2;StartNormalTemp=60+Sampling_Rate*60*1;EndNormalTemp=StartNormalTemp+Sampling_Rate*60*NPwave_Segment_lengthTEMP;

c) than the longer segment is defined for eval-uation of the selection using ROC analysisNPwave_Segment_length=20; StartNormal=EndNormalTemp;EndNormal=StartNormal+Sampling_Rate*60*NPwave_Segment_length;

d) E.g., the following file will be generated:PwaveTemMat04015_1.mat

Page 82: QRS Cancellation

76 COOKING BOOK FOR AF DETECTION TOOLBOX

2. Open AFProcessingBatch.m

3. Choose channel Channel=1; and functionalityFUNCTION_BATCH=’ExtractFeaturesSignal’;

4. In ExtractFeaturesSignal.m are for each signal defined the represen-tative segment of NSR (normal sinus rhythm) and AF data. The fol-lowing file will be for example produced FeatExtract04936_1.mat.

5. If you want to change training set than you must redefine the seg-ments in ExtractFeaturesSignal.m, e.g.

case ’04015’; %Very few data of AF - no possibility ofmerging training and validating set MERGE=0;

%Train-Normal-BAD example:StartNormalTrain=30NPwave_Segment_lengthNormal=3; NPwave_Segment_lengthNormalactually means Segment_lengthNormal, and has nothing to do withthe normal P-wave. (MH)StartNormalTrain=166857+Sampling_Rate*60*21;%AnnotECG.Beg_Seg_N_All(4)EndNormalTrain=StartNormalTrain+Sampling_Rate*60*,...

NPwave_Segment_lengthNormal;%Train-AF NPwave_Segment_lengthAF=2; StartAFTrain=133348;%AnnotECG.StartAF(3);EndAFTrain=StartAFTrain+Sampling_Rate*60*NPwave_Segment_lengthAF;%Validate-Normal NPwave_Segment_lengthNormal=3;StartNormalTest=166857+Sampling_Rate*60*25;%AnnotECG.Beg_Seg_N_All(4)EndNormalTest=StartNormalTest+Sampling_Rate*60*,...

NPwave_Segment_lengthNormal;%Validate-AF NPwave_Segment_lengthAF=2; StartAFTest=133348;%AnnotECG.StartAF(3);EndAFTest=StartAFTest+Sampling_Rate*60*NPwave_Segment_lengthAF;

6. The Validation set must be created by merging the already extractedfeature files like FeatExtract04936_1.mat. This is done by callingComposeTrainingSet.m. You can specify which record shouldcontributed to validation set by filling variable DataID, e.g.,DataID=’04015’;’04746’;’04908’;’04936’;’06995’;’07879’;’08219’;’08378’;The following file will be generated :FeaturesTrainingValidationAll1.mat

MIT Data - BIG Testing set

1. Open AFProcessingBatch.m

2. Choose channel Channel=1; and functionalityFUNCTION_BATCH=’ExtractFeaturesWhole’;

Page 83: QRS Cancellation

77

3. The features will be selected for the whole signal. Note, that this isquite consuming task, normally it takes like one day.

OWN Data - The whole data set

1. P wave template selectiona) No patients suffering from paroxysmal AF are presented. There-fore the P wave template selection was selected by trial & error forall the NSR records using SelectPwaveOwn.mb) The following file will be generated PwaveTemMatOwn.mat

2. Open AFProcessingBatchOwn.m3. Create Annotation using functionality

FUNCTION_BATCH=’CreateAnnotationOwn’;

4. Choose functionality FUNCTION_BATCH=’ExtractFeaturesSignal’;

5. In ExtractFeaturesSignalOwn.m are for each signal de-fined the representative segment of NSR and AFdata. The following file will be for example producedFeatExtractOwnFullnor_a_050725resampleTrainNormal.mat

6. If you want to change training set than you must redefine the seg-ments in ExtractFeaturesSignalOwn.m, e.g.

case ’ned_r_070440resample’; WhichLabel=’Normal’;WhichSet=’Train’; Start=84397; End=179931; %6.4m

7. The OWN database is quite small, that means that training set andtesting set is equal to sets of extracted features for the whole data-base. To compute it, open AFProcessingBatchOwn.m

8. Choose functionality FUNCTION_BATCH=’CreateTrainingSet’;

9. The following files will be gener-ated: ValidationSetOwnFullNormal.mat andValidationSetOwnFullNormal.mat

V. Classifier Training

For both databases

1. The training is done using PrToolsTrain.m. For training the patternrecognition toolbox is used !!!a) Choose appropriate database, e.g . DatabaseAF=’Own’;b) Choose features to be used, e.g.

FS=[1 6];

c) Choose classifiers, e.g. W1 = qdc(C);

d) You can also enable scatter plots by SCATTERPLOT=1;e) Or automatic feature selection by FEATURESELECTION=1;

VI. Classifier Evaluation

It is quite easy because the GUI was developed. Just start SignalEvalua-tion.m

Page 84: QRS Cancellation

78 COOKING BOOK FOR AF DETECTION TOOLBOX

MH Notes:

Most of the training and testing optimisation is carried out on a small subsetof the MIT AF database (called ’Signal’. The whole database is called ’Whole’.).This small subset is divided into two parts, called training and test. The p-wave template determination is carried out on this small subset of the MIT AFdatabase. 10 p-wave are selected randomly from the training part of this smallsubset, and tested on a fixed set of p-waves from the test part of this subset.This process is repeated until the template matches the test p-waves well.

1. AFProcessingBatch.m carries out all sorts of batch functions, given byFUNCTION_BATCH.

2. FUNCTION_BATCH=’ExtractFeaturesSignal’ generates the features (us-ing the p-wave templates just generated, among other things) for the’Signal’ part of the database.

3. ExtractFeaturesSignal.m extracts the features for the hand found startand end points of the NSR (normal sinus rhythm), which are hard codedin the .m file.

4. NPwave_Segment_lengthAF actually means Segment_lengthAF, and hasnothing to do with the normal P-wave.

5. The start and end times of the normal and AF segments were found byhand (using ReadOwn.m which uses eegplot.m).StartNormalTrain=166857+Sampling_Rate*60*21; The 166857 is fromthe annotation file (the starting point of a normal segment). It was foundthat this start was noisy, and the first 21 minutes were skipped.

6. If have path problems, can call Config AFDetection.m. This updates theMatlab path variable.

7. Various paths are stored in AFConfig.m. This defines various DataPathvariables. SelectPWaveOwn.m uses the p-waves from certain patients togenerate a p-wave template. It was found that it was better to only useone patient to generate this template rather than using all the patients.For many of the patients, the p-wave boundaries were poorly determined,resulting in a poor template. This could be improved by improving thep-wave detection algorithm (or tuning it). The best p-wave boundarydetection occurred with patient ned_r_070440resample, and this wastaken to generate the p-wave template.

8. Need to add the annotation directory for our data.

9. To create the annotation, need to change if 0, if 1 at various places inthe code. (Line 200 in ExtractFeaturesSignalOwn.m.) Now changed toCreateAnnotationOwn.m.

Page 85: QRS Cancellation

79

10. a) For our data set, the full feature matrix was created, done usingFUNCTION_BATCH=ExtractFeaturesSignal. From this matrix, thetraining and test set feature matrix was extracted in CreateTrain-ingSet.m.

b) For MIT DB, it is time consuming creating the full feature matrixfor the whole data set (can take 1-2 days). For this reason, a vali-dation set was created (a small training and test set) for which thefeatures can be quickly computed. When the features work well onthe validation set, the full feature matrix for the whole data set canbe computed. In theory, the validation set matrix can be extractedfrom the whole data set matrix. The validation set feature matrixwas created using FUNCTION_BATCH=ExtractFeaturesSignal. Thewhole feature matrix was created usingFUNCTION_BATCH=ExtractFeatureWhole.

11. In PrToolsTrain, A is structure containing all stuff necessary for the pat-tern recognition toolbox. Can examine A using struct(A).

12. In PrToolsTrain.m, the validation training set is divided into a sub train-ing set (30chosen randomly from the PR Toolbox (using the command[C,D] = gendat(A,0.3);). The sub test set is used to evaluate the clas-sifier trained using the sub training set. This process can be repeatedseveral times, giving different classifiers each time (trained from differentsub training sets, with different initial conditions), and evaluated on dif-ferent sub test sets. This can be repeated until a satisfactory classifier isobtained.

13. TestWholeSignalDiffClassifier.m tests the newly generated classifier onthe test part of the validation set.

Page 86: QRS Cancellation
Page 87: QRS Cancellation

C The M-file structure of AFdetection using MIT [1] andOWN database

*NUBU - Abbreviation of NotUsedButUseful directory. All files that are notcurrently used were placed under those directories.

• AFProcessingBatch.m - Segmentation, Feature extraction and Testing isdone for the whole AF database

• AFProcessingBatchOwn.m - Feature extraction and Testing is done forthe whole OWN database

DatabaseTools

• SegmentationSignal.m - It performs signal segmentation.

– SegmentationPeace.m - Pan Tompkins algorithm implementation[50], pp.187.

. rdsign212.dll - Read data in 212 format, the source code is inrdsign212.c

. readheader.m - Read MIT header, (ReadMITData.m - read datain 212 format)

• ReadOwn.m - Read OWN Belt data and manually select segments withoutnoise

FeatureExtraction

• SelectPWaveforMITDat.m It is necessary to select suitable representativeP wave. Select suitable P wave. It evaluates the selection using templatematching with correlation coefficient and dynamic time warping as mea-sures. This function can be also view as a training procedure for P wavesuitable selection and use ONLY the template matching for AF detection.

– ReadAnnot.m - Read annotations of AF database (here is also se-lected the channel!!!.

– SelectPwaveTemplate\_Method.m - Performs template selection

. ReadSegData.m - Reads AF data into first nth blocks, performssegmentation

Page 88: QRS Cancellation

82 The M-file structure of AF detection using MIT [1] and OWN database

. TemplateComputation.m - Select P wave template

. CorrCoefCalc.m\verb - Compute correlation coefficient [50],pp. 95.

. Dtw.m - Compute Dynamic Time Warping measure RRInterval-Training.m computes the Moody matrix [18]. However, duringtesting we use the matrix provided in Moody article.

• SelectPWaveOwn.m- Select COMMON P wave TEMPLATE from Normalsinus ECG signals of our OWN database.

• ExtractFeaturesSignal.m It extracts features from signal. We repeat itseveral times by calling ExtractFeatures.m to get the training and testingset (validation set) for classifier.

– ComputeMatrix.m - RR intervals matrix [18].

– entropy.m - Compute Shanon entropy

– sdann.m - Compote RR time parameters SDANN and SDNNind (in-dex)

– hrtach.m - Constructs evenly sampled rrintervals - interpolate RRinterval for further frequency analysis

– hrpowsfp.m - Compute FFT Spectrum in different frequency bandth

– QTCancellationInt.m - QT calculation and feature calculation [21].P wave matching

. time_normalization.m - normalization of beats to have thesame length.

. TraceSegmentation.m - the method for normalization is polyg-onal approximation

. CorrCoefCalcTestInt.m - template matching using correlationcoefficient or DTW.

ClassifierTraining

• ComposeTrainingSet.m - It creates training set for classifier.

• PrToolsTrain.m - Training and testing using Pattern Recognition toolboxfrom Delf university.

ClassifierTesting

• TestWholeSignalDiffClassifier.m Classifier TESTING for MITAF &OWN database

– ComputeClassifierROCMITAF.m. ROC analysis over the whole AFand OWN Belt database. Classifiers can be compared by loadingROC curve from ClassName ROC.mat file.

– EvaluationGraph.m - Results evaluation

Page 89: QRS Cancellation

83

. Plotgui.m - Prints out a graph containing the rr intervals anddetected AF

• PrintClassifierAFDetectionResultsROC.m. Print the results of classi-fier testing for particular record.

• NUBU\NeuralNetworkTrain.m ANN training [51]. It uses Neural NetworkMatlab toolbox.

• NUBU\NeuralNetworkTestValidationData.m Because the testing of onesignal takes several hours we firts test the ANN perfomance on smallertest of data. Using this set, the best feature combination and ANN topol-ogy is determined and consequently the whole signals are tested usingNeuralNetworkBatch.m.

– NUBU\NeuralNetworkBatch.m - ANN testing

– NUBU\NeuralNetworkTestWholeSignalPCA.m - All features selectedby PCA analysis

– NUBU\NeuralNetworkTestWholeSignalRRP.m - Only RR matrix andP wave template matching

– NUBU\NeuralNetworkTestWholeSignalRR.m- Only RR matrix asfeature

Personalization - so far only in case of NN Mathworks toolboxThe main goal is to develop algorithm adapted to each patient. Most m files

are the same for common (training over the whole database) and personalizedapproach. Some kind of personalization is already P wavelet matching. Themain idea is to have for each patient adapted NN. Called by AFProcessing-Batch.m

• NUBU\NeuralNetworkTrainPersonalize.m - Training

• NUBU\NeuralNetworkTestWholeSignalRRPersonalize.m\ - Testing forRR feature

• NUBU\NeuralNetworkTestWholeSignalRRPPersonalize.m- Testing forRR+P feature

• NUBU\NeuralNetworkTestWholeSignalPCAPersonalize.m - Testing forRR+P +QT feature

• \NUBU\PrintMITAFDetectionResultsROCPersonalize.m - Results eval-uation using ROC curve

File structure of AF detection - AtrialFibrillation directory

• AFDetectionDemos - demos for AF/OWN Belt database

• ClassifierTesting - Classifier evaluation with help of ROC curve

Page 90: QRS Cancellation

84 The M-file structure of AF detection using MIT [1] and OWN database

• ClassifierTraining - Classifier Training using PRTools toolbox

• DatabaseTools - Databases records Reading and Segmentation

• FeatureExtraction - RR interval, Pwave template matching, QT can-cellation FeatureExtraction\FeatExtUtils - support files for extraction

File structure of MIT-AF [1] database detection

• D:\AtrialFibrillation - the above mentioned m-files are placed in thisdirectory

• D:\AtrialFibrillation\Doc - it includes results excel tables

• D:\AtrialFibrillation\help - it includes help for AF Detection Tool-box

• AtrialFibrillationData\!!AfExtract\FeaturesTrainingbyHong -feature extraction of both channels fir training computed by ExtractFea-turesSignal.m (45 features in window of 30 beats)

• AtrialFibrillationData\!!Af\ExtractWholeSignalbyHong - featureextraction for the whole signals computed by AFProcessingBatch.m(FUNCTION_BATCH=’ExtractFeaturesWhole’)

• AtrialFibrillationData\!!Af\ValidationSet - Validation set for clas-sifier training created by ComposeTrainingSet.m

• AtrialFibrillationData\!!Af\WEKA - Conversion of Validation set forWEKA system

• AtrialFibrillationData\!!Af\Results - results of AF detection com-puted by TestWholeSignalDiffClassifier.m

• AtrialFibrillationData\!!Af\Results\ANNxxx - results of AF detec-tion for both channels and personalizes approach computed by Neural-NetworkBatch.m

• AtrialFibrillationData\!!Af\PwaveTemMat - P wave Templates forboth channels computed by SelectPWaveforMITDat.m

• AtrialFibrillationData\!!Af\Segmentation - segmentation for bothchannels computed by SegmentationSignal.m

Page 91: QRS Cancellation

Bibliography

[1] 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. Stan-ley, “PhysioBank, PhysioToolkit, and PhysioNet: Components of a newresearch resource for complex physiologic signals,” Circulation, vol. 101,no. 23, pp. e215–e220, 2000.

[2] D. S. R. S. D. Bialy, M. Lehmann and M. Meissner, “Hospitalization forarrhythmias in the united states: importance of atrial fibrillation,” J AmColl Cardiol, vol. 19 (Suppl. A), no. 41 A, pp. 612–627, 1992.

[3] J. Robbins and G. W. Dorn, “Listening for hoof beats in heart beats,”Nature Medicine, vol. 6, pp. 968–970, 2000.

[4] F. B. Sachse, “Modeling of the mammalian heart,” 2002. Habilitation-sschrift at Institute fur Biomedizinische Technik, Universitat Karlsruhe(TH).

[5] S. Nattel, “New ideas about atrial fibrillation 50 years on,” in Nature,vol. 415, pp. 219–226, 2002.

[6] J. Waktare, “Cardiology patient page. atrial fibrillation,” Circulation.,vol. 106(1), pp. 14–6, 2002 Jul.

[7] A. S. Levy, J. Camm, and S. Saksena, “International consensus on nomen-clature and classification of atrial fibrillation: A collaborative of the work-ing group on arrhythmias and the work group of cardiac pacing of theeuropean society of cardiology and the north american society of paingand electrophysiology,” Cardiovasc. Electrophysiol., vol. 14, pp. 443–445,2003.

[8] J. Malmivuo and R.Plonsey, Bioelectromagnesium, ch. Chapter 15: 12-leadECG system. New York: Oxford University Press, 1995.

[9] “Activity b13: EKG demo (ecg sensor).” http://www.clarion.edu/edu-humn/science education/biologylabs/B13%20EKG%20Demo.doc.

[10] D. Novak, “Processing of ECG signal using wavelets,” 2000. Masterthesis,Faculty of Electrical Engineering, Department of Cybernetics at CzechTechnical University in Prague.

[11] “The EKG waveform.”http://sprojects.mmi.mcgill.ca/cardiophysio/EKGPRinterval.htm.

Page 92: QRS Cancellation

86 Bibliography

[12] PhysioBank, “The mit-bih atrial arrhythmia database.”http://www.physionet.org/physiobank/database/mitdb/.

[13] PhysioBank, “The mit-bih atrial fibrillation database.”http://www.physionet.org/physiobank/database/afdb/.

[14] J. Muhlsteff, O. Such, and R. Schmidt, “Wearable approach for continu-ous ECG - and activity patient-monitoring,” in 26th Annual InternationalConference of the IEEE EMBS, vol. 1, pp. 2184–2187, 2004.

[15] D. Donoho, “De-noising by soft-thresholding,” IEEE Trans Inform Theory,vol. 41, no. 3, pp. 612–627, 1995.

[16] J. Pan and W. Tompkins, “A real-time QRS detection algorithm,” IEEETransactions on Biomedical Engineering, vol. 32, pp. 230–236, 1985.

[17] R. M. Rangayyan, ch. Chapter 4: Event Detection, pp. 466–471. IEEEPress Series on Biomedical Engineering, 2002.

[18] G. B. Moody and R. G. Mark, “A new method for detecting atrial fibrilla-tion using R-R intervals,” in Computers in Cardiology, vol. 10, pp. 227–230,1983.

[19] F. Beckers, D. Ramaekers, and A. A.E,“Approximate entropy of heart ratevariability: Validation of methods and application in heart failure,”Cardio-vascular Engineering: An International Journal, vol. 1, no. 4, pp. 177–182,2001.

[20] C. Peng, S. Havlin, H. Stanley, and G. A.L., “Quantification of scaling ex-ponents and crossover phenomena in nonstationary heartbeat time series,”Chaos, vol. 5, pp. 82–87, 1995.

[21] J. Slocum, A. Sahakian, and S. Swiryn, “Diagnosis of atrial fibrillationfrom surface electrocardiograms based on computer-detected atrial activ-ity,” Journal of Electrocardiology, vol. 25(1), pp. 1–8, January 1992.

[22] J. Pan and W. Tompkins, “A real-time qrs detection algorithm,” IEEETransactions on Biomedical Engineering, vol. 32, pp. 230–236, 1985.

[23] I. H. Witten and E. Frank, Data Mining. Morgan Kaufmann, 1999.

[24] “Lecture 12: Classification.”http://research.cs.tamu.edu/prism/lectures/iss/iss l12.pdf.

[25] R. O. Duda, P. E. Hart, and D. G. Stork, ch. Bayes Decision Rule, pp. 20–83. New York: A Wiley-Intersicience Publication, 2001.

[26] A. Maren and C. Harston, Handbook of Neural Computing Application,ch. Chapter 1: Introduction to Neural Network. 24-28 Oval Road, London:Academic Press, 1990.

[27] H. Demuth and M. Beale, “Chapter2: Neuron model and network architec-tures,” in Documentation of neural network toolbox: For user with MAT-LAB, vol. 4, pp. 2 1–2 32, 2002.

Page 93: QRS Cancellation

Bibliography 87

[28] D. McAuley, “The backpropagation network: Learning by example,” 1997.http://www2.psy.uq.edu.au/∼brainwav/Manual/BackProp.html.

[29] H. Demuth and M. Beale, “Chapter5: Backpropagation,” in Documentationof neural network toolbox: For user with MATLAB, vol. 4, pp. 5 1–5 74,2002.

[30] S. Akosoy, “Non-bayesian classifiers part I: k-nearest neighbor classifier and distance functions.”http://www.cs.bilkent.edu.tr/∼saksoy/courses/cs551/slides/cs551 nonbayesian1.pdf.

[31] R. M. Rangayyan, ch. Chapter 9: Pattern Classification and DiagosticDecision, pp. 466–471. IEEE Press Series on Biomedical Engineering, 2002.

[32] S. Shkurovich, A. V. Sahakian, and S. Swiryn, “Detection of atrial activ-ity from high-voltage leads of implantable ventricular defibrillators usinga cancellation technique,” IEEE Transaction on Biomedical Engineering,vol. 45(2), pp. 229–234, Feb. 1998.

[33] A. Bollmann, N. K. Kanuru, and K. K. McTeague, “Frequency analysisof human atrial fibrillation using the surface electrocardiogram and its re-sponse to ibutilide,”The American Journal of Cardiology, vol. 81, pp. 1439–1445, June 15, 1998.

[34] P. A. Lynn, “Online digital filters for biological signals: some fast designsfor a small computer,”Med. & Biol. Eng. & Comput., vol. 15, pp. 534–540,1977.

[35] E. C. Ifeachor and B. W. Jervis, Digital Signal Processing A PracticalApproach, ch. Chapter 6: Finite impulse (FIR) filter design. EdinburghGate, Harlow, England: Addison-Wesley, 1993.

[36] A. Bollmann, K. Sonne, and H. Esperer, “Non-invasuve monitoring of span-taneous and antiarrhythmic drug induced changes in fibrillatory frequencyin human atrial fibrillation,” Cardiovasc Res., vol. 44, pp. 60–66, 1999.

[37] A. Bollmann, K. Sonne, and H. Esperer, “Non-invasive assessment of fibril-latory avtivity in patients with oaroxysmal and persistent atrial fibrillationusing the holter ecg,” IEEE Computers in Cardilogy, vol. 26, pp. 695–698,1999.

[38] M. Holm, S. Pehrson, and M. Ingemansson,“Non-invasive assessment of theatrial cycle length during atrial fibrillation in man: introducing, validatingand illustrating a new ecg method,” Cardiovasc Res., vol. 38, pp. 69–81,1998.

[39] S. Pehrson, M. Holm, and C. Meurling, “Non-invasive assessment of mag-nitude and dispersion of atrial cycle length during chronic atrialfibrillationin man,” European Heart Journal, vol. 19, pp. 1836–1844, 1998.

[40] J. P, H. M, and S. DC, “A focal source of atrial fibrillation treated bydiscrete radiofrequency ablation,” Circulation, vol. 95, pp. 527–526, 1997.

Page 94: QRS Cancellation

88 Bibliography

[41] D. Raine, P. Langley, and A. Murray, “Surface atrial frequency analysis inpatients with atrial fibrillation,” J Cardiovasc Electrophysiol., vol. 16(8),pp. 838–844, 2004.

[42] Y. Asono, J. Saito, and K. Matsumoto, “Onthe mechanism of terminationand perpetuation of atrial fibrillation,” Am J Cardiol., vol. 69, pp. 1033–1038, 1992.

[43] “Cleveland clinic heart center.”http://www.clevelandclinic.org/heartcenter/pub/guide/disease/electric/afib.htm.

[44] A. Bollmann, D. Husser, and M. Stridh, “Frequency measures obtainedfrom the surface electrocardiogram in atrial fibrillation research and clinicaldecision-making,” J Cardiovasc Electrophysiol., vol. 14(10 Suppl), pp. 154–161, 2003.

[45] U.Kincke and H. Jaekel, Signale und Systeme, ch. Chapter 5: ZeitdiskreteSignale. Munchen: Oldenbourg Verlag, 2002.

[46] E. C. Ifeachor and B. W. Jervis, Digital Signal Processing A PracticalApproach, ch. Chapter 2: Discrete Transform. Edinburgh Gate, Harlow,England: Addison-Wesley, 1993.

[47] “A tutorial on clustering algorithm.”http://www.elet.polimi.it/upload/matteucc/Clustering/tutorial html/kmeans.html.

[48] K. Hnatkova, J. Waktare, and C. Meurling, “A computer package generat-ing non-invasive atrial electrograms: Detection and subtraction of qrs andt wave,” Computers in Cardiology, vol. 25, pp. 533–536, 1998.

[49] R. P. Stafford, P. Denbigh, “Frequency analysis of the P wave: comparativetechniques,”Pacing Clin Electrophysiol., vol. 18(2), pp. 261–270, Feb. 1995.

[50] R. M., Biomedical Signal Analysis. John Wiley & Sons, 2000.

[51] S. Artis, G. Moody, and R. Mark, “Detection of atrial fibrillation usingartificial neural networks,” in Computers in Cardiology, vol. 14, pp. 173–176, 1991.