Docstoc

SIM UNIVERSITY

Document Sample
SIM UNIVERSITY Powered By Docstoc
					           SIM UNIVERSITY
 SCHOOL OF SCIENCE AND TECHNOLOGY




ATRIAL FIBRILLATION DETECTION
  ALGORITHM OF AF RECORDER




STUDENT                  : ITA SUZANA BTE MAT JAIS
PI NO                    : H0605409
SUPERVISOR               : MR. HOE SWEE LONG
PROJECT CODE             : JUL2009/BME/007



       A project report submitted to SIM University
 in partial fulfilment of the requirements for the degree of
      Biomedical Engineering (Bachelor of Science)
                         May 2010
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


ABSTRACT

Atrial Fibrillation, or AF, is one of the most progressive cardiac arrhythmia in the
world, affecting millions of people worldwide. AF, which can be asymptomatic, can
occur randomly or in a sudden, and if left undiagnosed, it could lead to a more serious
complication such as stroke. The common, conventional approach of monitoring and
detecting AF is for patients to use a Holter monitor, portable event recorder, or
implanted loop recorder. However, each of these devices has their own limitation, and
studies have been carried out to find the most effective way of detecting arrhythmia.
The main objective of this project is to develop an algorithm that is capable to detect
Atrial Fibrillation episode in random ECG automatically. The approach adapted was
based on the observation that patients with similar cardiac arrhythmia usually have
similarities in their ECG, particularly in terms of wave shapes. Thus, the method
developed was designed towards Template-based matching algorithm, whereby a
positive match is determined based on the similarities between the template created
and the ECG tested. After series of test, the algorithm has been observed to be able to
successfully detect positive Atrial Fibrillation episodes in random ECG recordings,
with an overall sensitivity of 83.3%, specificity of 71.1%, and accuracy of 78.6%.




BME 499 Capstone BME Project                        ii                         SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


ACKNOWLEDGEMENT

I would like to sincerely thank my project supervisor, Mr. Hoe Swee Long, for giving
me the opportunity to work on this project, as well as for his encouragement and
valuable guidance throughout the project term. His willingness to share his
knowledge with me contributed significantly to my understanding of the essential part
in this project, hence making this capstone a successful one. It has been a pleasure to
work with him.


Last but not least, my utmost gratitude towards my family and loved ones for their
continuous support and encouragement.




BME 499 Capstone BME Project                        iii                        SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


TABLE OF CONTENT


ABSTRACT                                                           ii
ACKNOWLEDGEMENT                                                    iii
TABLE OF CONTENT                                                   iv
LIST OF FIGURES                                                    vi
ABOUT THE MATLAB FILES                                             vii


CHAPTER 1: INTRODUCTION
        1.1 Introduction to Atrial Fibrillation                    1
        1.2 Project Objectives                                     2
        1.3 Overall Objectives                                     2
        1.4 Approach                                               3


CHAPTER 2: REVIEW OF THEORY
        2.1 ECG and Signal Characteristics                         4
                 2.1.1 Characteristics of Atrial Fibrillation      5
                 2.1.2 Types of Atrial Fibrillation                5
        2.2 Review of Literature
                 2.2.1 Digital ECG Analysis                        6
                 2.2.2 ECG Shape Similarities                      6


CHAPTER 3: METHODOLOGY
        3.1 The Template-Based matching Algorithm                  8
        3.2 The Work Flow Diagram                                  9
        3.3 First Part: Signal Extraction
                 3.3.1 Baseline Wander Elimination                 11
                 3.3.2 Detecting the R-Peaks                       12
                 3.3.3 Segmenting the Signals                      14
        3.4 Second Part: Templates
                 3.4.1 Extracting & Averaging the Samples          15
                 3.4.2 Calculating the Mean Values                 17



BME 499 Capstone BME Project                        iv                  SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


        3.5 Third Part: Template Recognition
                 3.5.1 Flow of Process                             19
                 3.5.2 Similarities Search                         20
                 3.5.3 Adaptive Thresholding                       24
        3.6 Final Part: ECG Analysis and Classification
                 3.6.1 Classification & its Definition             26
                 3.6.2 The Classification of Results               26
        3.7 Graphic user Interface                                 28


CHAPTER 4: RESULTS AND DISCUSSION
        4.1 Results Obtained
                 4.1.1 Phase one – Training                        29
                 4.1.2 Phase two – Testing                         31
                 4.1.3 Phase three – Re-evaluation                 32
        4.2 Specificity and Sensitivity                            33
        4.3 Discussions
                 4.3.1 Review of Theory & Approach                 34
                 4.3.2 Interpretation of Result                    35
                 4.3.3 Review of Methods                           35
                 4.3.4 Problems Encountered                        38
        4.4 User Interface Simulation                              39


CHAPTER 5: CONCLUSION AND FUTURE WORK
        5.1 Conclusion                                             41
        5.2 Recommendation for Future Work                         41


CHAPTER 6: CRITICAL REVIEW AND REFLECTION                          42


REFERENCES                                                         43
APPENDICES
        APPENDIX A1: Matlab Codes                                  45
        APPENDIX A2: Templates                                     57



BME 499 Capstone BME Project                        v               SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


LIST OF FIGURES/TABLES

FIGURES:

Figure 1       Comparison with Normal Sinus Rhythm and Atrial Fibrillation                1
Figure 2       The waves and intervals of Normal ECG                                      4
Figure 3       ECG demonstrating a Normal Sinus Rhythm and AF                             5
Figure 4       ECG from several patients all diagnosed with same diseases                 7
Figure 5       Illustration of Template-Based Algorithm during similarity search          8
Figure 6       Baseline Wander Removed                                                   11
Figure 7       Example of ECG with R-Peaks detected                                      13
Figure 8       How the ECG was Segmented                                                 14
Figure 9       Example of two cardiac cycles with 90 sample intervals                    16
Figure 10      A template created with each of the fiducial points                       17
Figure 11a     A GUI displaying a template created from 10-seconds AF recordings         18
               A GUI displaying a template created from 10-seconds Normal Sinus
Figure 11b                                                                               18
               Rhythm
Figure 12a     A length of 44 fiducial points used                                       20
Figure 12b     Magnified view of the thresholds (red) and ECG (Blue)                     21
Figure 12c     GUI of the template-based matching process                                23
Figure 13      Magnified view of the cardiac cycle and its corresponding template        24
Figure 14      GUI to create the template and run template-matching process              28
Figure 15      Similarities of shape between AF cases                                    34
Figure 16a     Example of Cardiac Cycle Segmented 0.2 and 0.6 sec from peak              36
Figure 16b     Example of Cardiac Cycle Segmented 0.35 from peak                         36
               Unnecessary part of the cardiac cycle that can be seen in both AF and
Figure 17                                                                                38
               normal ECG
Figure 18      Example of undetected R-Peaks                                             39
Figure 19a     GUI/Controls to execute the simulation                                    40
               Personal impression of what the future AF will may look like and what
Figure 19b                                                                               40
               users/patient will be able to see upon positive detection

TABLES & DIAGRAMS:

Table 2.1         Duration values and intervals for normal arrhythmia                     4
Table 4.1.1a      Normal Sinus ECG Datasets Results - Phase 1                            30
Table 4.1.1b      Atrial Fibrillation ECG Datasets Results – Phase 1                     30
Table 4.1.2a      Normal Sinus ECG Datasets Results - Phase 2                            31
Table 4.1.2b      Atrial Fibrillation ECG Datasets Results – Phase 2                     31
Table 4.1.3       Atrial Fibrillation ECG Datasets Results – Phase 3                     32
Table 4.2         Specificity, Sensitivity and Accuracy Results                          33
Table 4.3.1       Comparison of Specificity and Sensitivity                              35

Diagram 3.1       Template-Based Matching Algorithm Model                                 8
Diagram 3.2       „Machine-Learning‟ Flow Diagram                                        10
Diagram 3.3       Work Flow on R-Peak Detection                                          12
Diagram 3.4       Work Flow on Creating of Templates                                     15
Diagram 3.5       Work Flow on Template-Based Matching                                   19
Diagram 3.6       Classification of the Results                                          27

BME 499 Capstone BME Project                        vi                             SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


ABOUT THE MATLAB FILES

The Matlab Files that have been submitted contains several files and folders. There
are a total of 3 files that can be executed: TemplateGui.m, TrainingGui.m and
UserIntSim.m. These files will run the files associated with the creation of template
(TemplateSetA.m), the main template-based matching program (ProgSetA.m), and
the user simulation (UserIntB.m) programs respectively. The ECG datasets that were
used for testing are stored in the „Sets‟ folder, while the templates created were stored
in the „Template‟ folder.




BME 499 Capstone BME Project                        vii                        SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


CHAPTER 1: INTRODUCTION


1.1 Introduction to Atrial Fibrillation
Atrial Fibrillation, or AF in short, is a progressive disease and the most common
cardiac arrhythmia in the world, affecting millions of people worldwide. Its
prevalence increases markedly with age, affecting less than 1% for those aging 60
years old and younger, to approximately 1 in every 10 elderly who are above 80 years
of age [1]. By definition, Atrial Fibrillation is “an abnormal heart rhythm originating in
the atria”[2]. Briefly, in a normal heart contraction, the Sinoatrial node sends an
electrical impulse through the heart in a coordinated manner, whereby each part (atria
and ventricles) contract in specific order, and the subsequent electrical impulse will
only begin after it has completed one cycle. The normal heart rate is ranging from 50
– 100 beats per minute, and as shown in Figure 1 below, the normal sinus ECG have a
regular rhythm, and the P, QRS, and T-waves are displayed in order.




           Figure 1: Comparison with normal sinus rhythm and Atrial Fibrillation
           [Source: http://www.winthrop.org/departments/clinical/cardiology/Fibrillation/]



In AF, the fibrillation or “quivering”, is due to the multiple electrical impulses in the
atria happening at the same time, resulting in disorganized, rapid and irregular
heartbeat. Due to this inconsistent pattern, the atria contractions are not synchronize,
and not all the irregular impulses, which reach the Atrioventricular node in rapid
succession, made through the ventricles, hence resulting in a slower ventricle systole.


BME 499 Capstone BME Project                            1                                    SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


The rate of impulses through the atria for AF could range from 300 to 600 beats per
minute, this contributes to the factor that makes them appear to quiver or fibrillate in
the ECG.

1.2 Project Objectives
The objective of this project is to develop algorithm to detect Atrial Fibrillation
episodes. The proposed algorithm should be able to analyze the cardiac activity from
the ECG datasets obtained from the Physionet database [3] and extract the AF episodes
based on their characteristics. The results will then be compared and tested for its
accuracy and sensitivity. In this project, the analysis of the ECG signals and the
implementation of the proposed model were designed and tested using Matlab.


1.3 Overall Objectives
Clinical evaluation or diagnosis for AF cases usually involves with reviewing the
history of the patient, physical examination, ECG, echocardiogram and routine
screening. However, the clinical evaluation done may not be as effective, particularly
in detecting paroxysmal AF, whereby it usually comes on suddenly and lasted only
for few minutes, or hours (normally it self-terminates within 24 hours) before the
heart resume its normal rhythm. In addition, since AF cases can be asymptomatic,
medical professionals sometimes have to rely on incidental findings of AF on the
ECG or during physical examination. It can be quite impractical for doctors to go
through the ECG manually, especially for cases where the occurrence of AF episodes
are random and a long term ECG recording is required in order for them to monitor
and extract the irregularity or abnormal activity for further evaluation.


Possible approaches to detect AF episodes have been carried out by researchers over
the years. The common purpose in developing a detecting algorithm for AF is to
improve the clinical diagnosis and decreased the risk of patients developing stroke or
other related diseases due to undetected AF. Currently, portable devices like the loop
event recorder and Holter monitor are used for long-term monitoring and recording of
               [4]
AF episodes          . However, some of these devices do have limitation, particularly in
the recording of the episodes, whereby patient has to manually record or “freeze” the
AF episode as they encounter it. Another alternative is to use implantable loop


BME 499 Capstone BME Project                        2                             SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


recorder (or ILR for short), which is capable to automatically detect arrhythmias.
However, despite the improved development of ILR, like the one from the recent
study where they published that it has tested and reduced the detection of
                                                                   [5]
inappropriate episodes significantly by at least 85.2%                   , it is still recommended for
patient to activate the ILR manually when the episodes occur, since the ILR can only
store up to three events [6]. By doing so will reduce the unnecessary hospital visits for
doctors to review and erase the recordings that could be related to “false” signals or
simply false alarm.


By understanding and finding the capability of implementing algorithm model that
could detect AF episodes more effectively and automatically in a system would prove
to be much at its advantage, for both the patient and the medical professionals. Thus,
the overall objective of this project is to study and develop AF detecting algorithm
using ECG datasets from the Physionet library, which, in turn, could be used for the
future development of an AF recorder.


1.4 Approach
The approach taken in the development of the algorithm was based on the observation
on the similarities of ECG wave shapes presented in patients with same diseases.
Using this understanding, the methods were designed towards a template-based
matching algorithm, whereby the shape of the ECG will be analyzed, created into
templates and compared with ECG of similar case. The focus of this algorithm is to
observe if we can rely on wave-shapes or templates, created from AF ECG datasets,
to positively identify AF episodes on random ECG. A more detailed explanation will
be presented throughout this report.




BME 499 Capstone BME Project                        3                                         SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


CHAPTER 2: REVIEW OF THEORY


2.1 ECG and Signal Characteristics
Understanding the Electrocardiography and its characteristics is one of the most
important aspects during the development of this project. Electrocardiography, or
ECG in short, is the most commonly used and direct method for assessing
abnormalities of cardiac rhythm. As shown in Figure 2 below, ECG tracing of the
cardiac cycle typically consists of a P wave, a QRS complex, and a T wave [7].




                   Figure 2: The waves and intervals of Normal ECG
                   [Source: http://en.wikipedia.org/wiki/Electrocardiography]



ECG provides us with two types of information. First is the duration of electrical
wave crossing the heart, which is measured by measuring the time intervals on the
ECG. This will determined the regularity of the electrical activity, if it is normal,
slow, fast or irregular. Second is the amount of the electrical activity passing through
the heart muscle and is represented by the principal components (peaks and valleys)
of the ECG. Arrhythmia usually can be analyzed based on the change of the rhythm
or frequencies of the heartbeat. The normal values for duration of ECG waves and
intervals in adults were presented in the Table 2.1 [8].


                                                                                  Wave Frequency
 Associated Wave              Duration (msec)                Amplitude (mV)
                                                                                       (Hz)
P wave                      80-120                      ≤ 0.3                   10
QRS Complex                 85-120                      Q<0 - S>0, R=0.5-2      20-50
T wave                      200                         0.2                     5
Table 2.1: Duration values and intervals for normal arrhythmia




BME 499 Capstone BME Project                             4                               SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


2.1.1 Characteristics of Atrial Fibrillation
On the ECG, AF is characterized by the absence of the P waves before the QRS
complexes. Instead, they are replaced with rapid oscillations or fibrillatory waves that
vary in amplitude and timing [9]. The other major characteristic is that the heart
rhythm displays irregular R-R intervals. A comparison of the ECG signal
characteristics between a normal sinus rhythm (a) and an AF episode (b) is presented
in Figure 3 below.




                                              Irregular rhythm of RR
                                              intervals



                                                                       P-wave appears as
                                                                       “saw-tooth” shape


     Figure 3: (a) Top: Normal ECG        (b) Bottom: ECG demonstrating AF activity
     [Source: http://www.physionet.org/cgi-bin/ATM]




2.1.2 Types of Atrial Fibrillation
Based on the guidelines set by the American College of Cardiology, American Heart
Association and the European Society of Cardiology, depending on the simplicity and
clinical relevance, the AF has been classified into four main categories [9]. All AF
patients are initially classified in category called First detected AF as long as one
episode is diagnosed. If this first detected episodes self-terminates within 7 days and a
recurrent episodes occurs after that, the case is then classified as Paroxysmal AF.
However, if the detected episodes lasted for more than 7 days, it is classified as
Persistent AF. In this case, the episode may need to be terminated by cardioversion,
as there is a chance that it may not self-terminate naturally. However, if the
cardioversion attempt is unsuccessful, and the episode goes on for a year or more, the
patient‟s AF is known to be permanent.



BME 499 Capstone BME Project                          5                                    SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


2.2 Review of Literature
2.2.1 Digital ECG Analysis
In today‟s generation, most of the ECG machines manufactured are able to represent
recorded ECG digitally, and many models have incorporated with software that could
use for analysis and interpretation of the ECG recordings. Consumers or portable
ECG recorders are also widely available to be used anywhere at the convenience of
the patient. Example of such recorder is the Holter Monitors, which are able to record
the heart‟s rhythm continuously for 24 hours, and is useful to detect cardiac
arrhythmias abnormalities.


Most of the research and studies published that are related to detection of arrhythmia
were based on analysing digital ECG. In designing of algorithm or software, the two
important design tasks to note are the QRS detection and the Arrhythmia analysis [10].
If these two tasks were not done correctly, it may result with either high false reports
of beats that are not there (false positive), or lack of reporting of beats that are missed
(false negative). There are quite a number of approaches that have been successfully
implemented. One of such methods is the Pan and Tompkins proposed algorithm in
detecting real-time QRS, which is based on the analysis of the slope, amplitude and
the width of the QRS complex, and using the moving-window integrator to perform
the thresholding procedure [11]. There are other approaches that have been presented
with a good sensitivity and specificity results as well. K Tateno‟s proposed method
[12]
       of detecting AF based on the difference between successive RR intervals, and
estimation of similarity between standard density histogram of RR and RR intervals
have shown a results of 93.2% sensitivity and 96.7% specificity. While in another
study, Tran Thong‟s approach [13] involving with the prediction of AF by analysing
the premature atrial complex has presented with a sensitivity result of 89% and 91%
specificity.


2.2.2 ECG Shape Similarities
During diagnosis of cardiac diseases, physicians will normally look at ECG wave-
shapes or patterns, in order to identify abnormalities that may be present in the ECG.
Studies have suggested that it is a common knowledge that patients with same
diseases have similar-looking ECG shapes [14]. This observation is after factoring out

BME 499 Capstone BME Project                        6                            SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


a number of morphological variations and measurements of variability in ECG
recordings, which attributes to the heart rate variability and the amplitude levels
respectively [15]. Figure 4 shows an example of ECG from several patients suffering
from bundle branch block. Notice the similarities in the wave-shapes.




           Figure 4: ECG from several patients all diagnosed with same diseases
           Source: Observation made by authors from IBM Almaden Research Center [14]




In one of the study reviewed [14], the authors have analyzed the similarities of the
ECG by combining shape matching with dynamic time warping, whereby the shape
similarity of each recording channel was combined to develop an overall shape. They
have also demonstrated a shape-matching algorithm by matching a pair of ECG
signals, which have been extracted from the same observation lead. The results of
their findings proved to be quite remarkable, as they have a high average recall (as
high as 96.2% of correct matches) presented on various cardiovascular diseases that
have been tested.




BME 499 Capstone BME Project                        7                                  SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


CHAPTER 3: METHODOLOGY


3.1 The Template-Based Matching Algorithm
The algorithm proposed in this project is designed towards detecting of AF based on
similarities between the templates that have been created from ECG wave shape
analysis, with the unknown and random ECG datasets. The algorithm applied is
mainly based on the theory and observation made on similarities of ECG wave-shapes
that are presented in the same cardiovascular diseases. The model of this algorithm is
presented in Diagram 3.1, and illustrated in Figure 5.


                                         ECG Signal


                               Baseline Wander & Noise Removal


                                      Detection of R-peaks


                                    Cardiac Cycle Detection




            Template Extraction                             ECG Fiducial Point Extraction




                                        Similarity Search                    Classification


         Diagram 3.1: Template-Based matching Algorithm Model




                             Flow of ECG                           Direction of Template




     Figure 5: Illustration of Template-Based Matching Algorithm, during the similarity search


BME 499 Capstone BME Project                        8                                         SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


The model presented in Diagram 3.1 shows the process of the Template-Based
matching algorithm. Briefly, after the ECG has been de-noised and rectified, it will be
segmented into windows with the length containing one cardiac cycle. The detected
cycles will then either be used to create as template or extracted as a part of the testing
dataset. During the similarity search, the template will be compared with the random
ECG datasets, by going through starting from the first cardiac cycle segmented and
moving towards the end of the ECG. It will terminate once the parameter/criteria
implemented in the system has been met. A more detailed explanation on each of this
process will be presented in this chapter.


In this project, the algorithm developed was applied and tested on normal sinus
rhythm and AF ECG datasets. The ECG datasets used in this project is obtained from
the Physionet website [1]. The normal ECG records were extracted from MIT-BIH
Normal Sinus Rhythm Database, while the AF records were extracted from the AF
Termination Challenge Database, and the MIT-BIH Atrial Fibrillation Database. All
the records obtained were one-channel ECG signals in 10 seconds and 60 seconds
durations.


3.2 The Work Flow Diagram
An overall work flow diagram has been modelled as part of the „Machine-Learning‟
process, as well as to assist with the development of the algorithm. The project was
divided into four main parts. The first part involve with the filtering of the ECG,
baseline wander removal, R-Peak detection and window segmentation. The second
part is the designing of the templates, which will be used for the template matching
part of the project. The last part is the classification of the result to determine the AF
and non-AF cases. The flow diagram is shown in Diagram 3.2.


The flow diagram has helped to determine the probability of the ECG signal between
AF and non-AF episodes. Furthermore, the system initially won‟t be able to tell the
difference between conditions. Thus by implementing this model towards the
„machine learning‟ part of the software development, we were able to increase the
overall sensitivity for the detection of AF. In addition, it‟s also easier to pinpoint the



BME 499 Capstone BME Project                        9                             SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


exact „branch‟ that might be contributing to the unexpected result or problems that
occurred during the debugging phase.



               ECG [x]                               [x+1]
          (From Physionet)




        Filter & Removal of
          Baseline wander
                                                        Extract fiducial points
                                                         for each [n] window
        R Peak Detection [n]


                                                            Averaging the points
       Start & end point cardiac cycle

                                                            Template created &
                                                               stored [m]
       ECG Segment Windows [n]
                                                                                   [m+1]


       [n+1]                         Each window [n] compared                        IF no match at all with
                                       with the template [m]                              template [m]

       NO       Window [n] match with
                    template [m]?                                    IF no match at all with
       YES                                                           all templates and ECG
                                                 YES
                            Detected on
                         consecutive cycles?            End;
                                                                                 End;
                   NO


                                                 Classification




                  False             True                               False                True
                 Negative          Negative                           Positive             Positive




                                               Sensitivity & Accuracy
                                                        Result

Diagram 3.2: „Machine Learning‟ Flow Diagram



BME 499 Capstone BME Project                           10                                         SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


3.3 First Part: Signal Extraction
The first part of this project was the extracting of important feature in the ECG after it
has been filtered and rectified. The signal extraction involves with detection of the R-
peaks, followed by dividing the ECG into windows of individual cardiac cycles.


3.3.1 Baseline Wander Elimination
The main focus on this part of the project was to eliminate baseline wander, and
“noises” in the signal. Baseline wander and noise in ECG is normally caused by
changes in electrode impedance, due to perspiration or body movements. Both the
wandering baseline and noises produce artefacts that will compromise the clinical
information found in the ECG. Hence, in order to ensure that the most accurate signal,
or information is obtained, both the baseline wander and noises need to be removed.
The method implemented in this process was by using wavelet transform. The result
is displayed in Figure 6, where from the top-most sub-plot window, the signal
displayed is the original ECG signal, followed by the baseline wander elimination and
lastly a filtered ECG signal was presented.




     Figure 6: (a) Top: Original ECG data (b) Middle: Baseline wander removed (c) Bottom: Filtered ECG




BME 499 Capstone BME Project                           11                                        SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


3.3.2 Detecting the R-Peaks
In order to analyse the characteristics and wave-shape of the ECG to be used for the
template-based matching approach, the recordings were segmented into windows of
cardiac cycle; in other words, each window represents one cardiac cycle consisting of
the main components: the P-wave, QRS complex and the T-wave. To do this, the
system first needs to detect the most prominent feature in the ECG, which is the
highest peak or the R-peak. The flow of this approach is presented in Diagram 3.3
below.

                         n+1
   Digitized ECG
   Signal with [c]                                                              NO
                               Set Threshold             ECG(c) > threshold           ECG(c) = 0
   no. of Sample
      Intervals                                                    YES
                                                      Fid_index(c) = ECG(n)
                                             Loop     [e=1:length(Fid_index)]
  If Fid_index(e) > Fid_index(e+1)
  Fid_index(e+1) = 0                                                                     Loop
  else                                          [Fid_index(e+1) - Fid_index(e)] > 5
  Fid_index(e) = 0

                                              NO                     YES
                                                           Highest Peak Detected


Diagram 3.3: Work Flow on R-Peak Detection


Before the system could detect the peaks, a threshold value has been implemented to
determine which part of the ECG can be considered as the peak values. The threshold
value was calculated by using the max value and the mean value of the ECG.




The ECG obtained from Physionet was already digitized and contains about 7680
samples interval in a one-minute duration. Each of these samples was compared with
the threshold value, and if they are below the threshold, they are not counted as peaks.
However, if they are above the threshold, the system will start doing another
comparison between these detected values. The issue encountered when using this
process was that the values detected were considered as the peaks as long as they are
above the threshold. Hence, by doing another comparison, the values that were
initially classified above the threshold but does not meet the criteria will be removed.

BME 499 Capstone BME Project                        12                                   SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


The criteria implemented involved with measuring the distance between the detected
values. If the distance is too close, the lower value will be removed (initialized as „0‟
in the codes). The result of this process is presented in Figure 7, and the peaks
detected are indicated in red “dots”.




                                                                                   Max Value     Values
                                                                                                 between the
                                                                                                 lines were
                                                                                                 initially
                                                                                   Threshold     detected and
                                                                                                 later rectified




Figure 7: An example of an ECG, with the R-peak detected as indicated in red „*‟
At the top is their corresponding Matlab code.


BME 499 Capstone BME Project                            13                                     SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


3.3.3 Segmenting the Signals
Before proceeding to create the templates, the ECG signal was divided into series of
individual cardiac cycle. By using the R-peaks as the reference point, the length of the
window was determined based on approximation and thorough testing on a number of
different ECG, as well as understanding of the characteristic of a cardiac cycle.




                                          ECG signal divided into windows
                                          with length of one cardiac cycle




                                          A simulation
                                          representation
                                          of all the
                                          cardiac cycle
                                          segmented
                                          overlapping one
                                          another




                                              fid_index – [X]                 fid_index + [Y]
                               begin_pt                          fid_index                      end_pt

  Figure 8: How the ECG was segmented. (**Lines were drawn based on estimation).
  At the top is their corresponding matlab code



BME 499 Capstone BME Project                           14                                   SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


The example shown in Figure 8 was taken from an actual 10-seconds AF episode
extracted from the database. In this example, the ECG was segmented into 10 separate
windows of cardiac cycles. The first and the last cycle were ignored due to its
incomplete cycle. The window length was determined by using the R-peak as the
reference point, represented as the fid_index in the figure (also as the variable
fid_index in the codes). The start point (or begin_pt) of the window was then
measured by subtracting [X] value from the fid_index, while the end point (or end_pt)
was measured by adding [Y] value to the fid_index. Based on the general
characteristics of ECG, the PR interval is normally 0.12 to 0.2 seconds long, while the
QT interval is about 0.40 seconds or less [7]. In the system, after running through a
series of test using values from 0.2 to 0.6 on all ECG extracted from the database, the
optimal value to use, for both [X] and [Y], was 0.35 seconds from the R-peak point.
In addition, in terms of the number of sample interval, the windows segmented have
the length of 90 samples.


3.4 Second Part: Templates
As mentioned, based on observation and by factoring out morphological or other
variation that attributes to heart rate variables and the amplitude levels, patients with
similar cardiac diseases usually have similarities in their ECG in terms of shape or
waveform [14]. In this part of the project, we focus on the creation of the templates.
The purpose of these templates was to compare them with the actual ECG recordings,
and to determine if using algorithm based on template-based matching can be used to
detect AF episodes effectively.


3.4.1 Extracting & Averaging the samples
Diagram 3.4 below explains the flow of the process on creating the templates.
                                                                         j++

      ECG                   Segment into cardiac cycles each           Averaging each sample in
     [n=20]                   containing 90 samples interval           all the cardiac cycle
                           [j = 90] [i = no of cardiac cycles]


                                                                   Templates of the ECG[n]
                                                          [n++]    created based the mean values.

  Diagram 3.4: Work Flow on creating the Template


BME 499 Capstone BME Project                         15                                   SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


The templates were created following the segmentation of the selected ECG. For
example, in Figure 9 below, two cardiac cycles have been segmented and presented in
a window with length of 90 samples. Using the term fiducial points to represent the
value of each sample on each cycle, these values were stored in a variable named
avgR_i_j, whereby “i” refers to the number of cardiac cycle, and “j” represents the
number of samples/fiducial points. For instance, the first fiducial point for the first
cycle will be stored as avgR_1_1, the first point for the second cycle will be stored as
avgR_2_1 and so on. In the figure, a few fiducial points were selected, which is at the
R-peak position, the point directly after the peak, and the end-point of the cycle. They
were represented by avgR_1_45, avgR_1_46 and avgR_1_90, respectively for the
first cycle. While the second cycle, the corresponding fiducial points were represented
by avgR_2_45, avgR_2_46 and avgR_2_90.




            Example of 2 cardiac cycles
            [i], each has 90 samples [j].

            Fiducial points = [ avgR_i_j ]




Figure 9: An example of two cardiac cycles with 90 sample-intervals.
At the top is their corresponding Malab code


BME 499 Capstone BME Project                            16                       SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


3.4.2 Calculating the mean values
Each fiducial point from every cardiac cycle extracted, as previously explained was
used to create the template. The template itself was made up of the mean values from
these fiducial points. The calculation of these mean values is explained as the
following.


Calculating the mean values:
                                     avgAllR (j) = mean(avgR_i_j)


For example, consider the 45th fiducial point i.e. j = 45, which is at the R-Peak, and
the number of cardiac cycle segmented is 2 or i = 2. The values corresponding to
avgR_1_45 and avgR_2_45 are 167.9 and 155.3 respectively.


Hence we have:
                                      (avgR _ i _ 45)        (avgR _1_ 45  avgR _ 2 _ 45)
                   avgAllR(45)      i 2
                                                          
                                         i                                 2
                                 167.9 +155.3
                   avgAllR(45)                161.6
                                       2
Therefore, the 45th fiducial point on the template corresponds with the amplitude of
161.6. This calculation was done for all the points (j = 1:90) on every cardiac cycle.
     
Figure 10 shows an example of a template created from a 10-second AF episode.




            avgAllR (j) = mean(avgR_i_j)




Figure 10: A template created, with each fiducial points marked in red circle.
Their corresponding Matlab code were placed in the previous page


BME 499 Capstone BME Project                              17                                  SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


The following figures show a GUI representation for this part of the project. The ECG
displayed was in duration of 10 seconds, and the template created was represented as
the red-coloured plot. Figure 11a displays an example of an AF template, while an
example of a normal rhythm template was shown in Figure 11b. The rest of the
templates are presented in Appendix A2. Twenty different ECG records consisting of
10 normal sinus rhythm and 10 AF episodes, with duration of 10-seconds length each,
were used to create 20 unique templates. Each of these templates was stored in
individual matrix (.mat) files and was used for the next part of the project.




Figure 11a: A GUI displaying a template created from a 10-seconds AF recording.




Figure 11b: A GUI displaying a template created from a 10-seconds Normal Sinus rhythm recording.




BME 499 Capstone BME Project                           18                                          SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


3.5 Third Part: Template Recognition
In this part of the project, we focus on analyzing the similarities between the actual
ECG with the templates created, and execute the Template-Based Matching algorithm
through series of tests to observe if AF episodes can be detected just by using
template-based matching. The results from these tests will be discussed in the next
chapter of this report.


3.5.1 Flow of process
Before the ECG was analyzed and compared with the templates, the ECG, as always,
first went through the filtering and segmentation process. The templates created, from
the previous part of the project, were loaded and executed one at a time, and this loop
will terminate once the criteria have met and a match is found. The following diagram
shows an overview on how the process is being executed.


                                                                            Templates                n++
                                                                        [n=20] [avgAllR(j)]



                     Segmentation. However only 44                 One cycle [r3(j)] at a time is          j++
    ECG                fiducial points is compared                 compared with Template [n(j)].
                      [j = 44] [r3 = cardiac cycles]


                           r3++                                  Threshold range:
                                                                 Is r3(j) within the threshold limit?

                                                                 NO                            YES
                       Calculate the number of
                           [1‟s] initialized                    comp(j) = 0            comp(j) = 1
                         [ find(comp==1) ]
                                                            Variable initialized
                NO                                  YES
resl(i) = 0           Percentage of [1‟s] > 70%               resl(i) = 1


                                             YES                                    NO
                                                         Identified in multiple
       break;             accuracyP(n) = 1                 consecutive cycle             accuracyP(n) = 0




Diagram 3.5: Work Flow on Template-Based matching




BME 499 Capstone BME Project                        19                                         SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


3.5.2 Similarities Search
Based on theory and the characteristics of AF, we understand that one of the key
features presented in AF cases is that they either have an absence of the P-wave, or
the P-wave appears like a “saw-tooth” shape. Using this information, we mainly focus
only on the PR-interval section of a cardiac cycle. Hence, fiducial points from few
points of the start of the cycle to the point before the R-Peak were used throughout the
“template-matching” process (shown in Figure 12a below).




                                   Length = 44


                Figure 12a: A length of 44 fiducial points was used




A length of 44 fiducial points was extracted from every cardiac cycle windows
segmented. Upon executing the codes, each of the cycle will be matched one window
at a time with the first template loaded from the source folder. If no match is found, a
second template will be executed and the matching process starts over. This continues
until the program terminates when a match is found or when all the twenty templates
have been executed without displaying any result.


The criteria to determined if the ECG matches with the templates were dependent on
several factors, such as the threshold range, the percentage of the total fiducial points
that matched, and the number of consecutive windows that were considered to be
positive. The first consideration was the threshold range. The threshold values were
determined during the second part of the project, i.e. during the process of creating the
template, which will be explained further in the section 3.5.3. In this process, each of
the fiducial point, upon being matched, needs to be within a certain threshold range.
Refer to Figure 12b.

BME 499 Capstone BME Project                            20                      SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder




       Figure 12b: Magnified view of the thresholds (in red) and ecg (in blue)
       At the top is their corresponding Matlab code




Figure 12b is an example to illustrate on how the threshold values play a part in the
process. Each of the templates has their own threshold ranges on every fiducial point.
With the reference from the Figure 12b above, the red graph represent the template, or
its threshold range (maxP and minP), while the blue graph represents the cardiac
cycle/window that is being matched. As you can see at point 15 (r3(15)), the ECG lies
within the maximum and the minimum threshold. Hence, for this particular point, we
flag it as “1”. However, further down at point 30 (r3(30)), the ECG is slightly below
the minimum threshold, hence we flag it as “0”. This continues until the last fiducial
point (r3(44)), and creating a matrix of 1s and 0s stored in variable called comp(i).
The program will then proceed to the next criteria, which is calculating the percentage
of the number of fiducial points in a cardiac cycle/window that matched.




BME 499 Capstone BME Project                             21                      SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


The percentages was calculated by counting the total number of fiducial points that
falls within the threshold range against the total number of fiducial points extracted
(which is 44) and multiply them by 100.


          Percentage = [(Total number of „1‟s) / Number of Fiducial points] * 100


Upon getting the percentage, the system will then determine if the cardiac cycle can
be considered to be similar to the template. The similarities percentage for the
template matching was manually set to 70%, hence if the percentage matched is
above 70%, it will be flagged as a positive match. However, if it is below 70%, this
cycle will be ignored, the next immediate cycle will be executed immediately, and the
process starts over with this new cardiac cycle. The Matlab code for this part is as
follow:




Once the cycle was flagged as a possible match, it moved to the last criteria, which
involved with determining the number of consecutive cycles that matches with the
same template. In this project, since the ECG records obtained have quite a short
duration that is either 10 or 60 seconds long, we can only detect a short period of AF
episodes. Hence, the parameter that I have set in this program is to be able to detect at
least in 5 or 7 consecutive cycles, depending on the duration of the ECG. It will check
for 5 consecutive cycle if the ECG length is 10 seconds long, and 7 cycles if it is 60
seconds long. Thus, anything less than the desired parameter, again these cycles will
not be considered and the process will start over with the next immediate cardiac
cycle. It continues until all criteria are met, or till all the templates have been used up.


BME 499 Capstone BME Project                        22                            SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


However, once the consecutive cardiac cycles displayed a positive match with the
template, the process will end, and the result will be analyzed further so that it can be
classified accordingly. Figure 12c shows an example of a series of cardiac cycles that
display a positive match, together with the corresponding template matched (in red).




                                            60-seconds ECG recording
                                                (with AF episodes)




          The matching template                 ECG series that matches

       Figure 12c: GUI of the template-based matching process
       At the top is part of their corresponding Matlab code




BME 499 Capstone BME Project                           23                       SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


3.5.3 Adaptive Thresholding
The threshold range or values, that were used in this part of the project was obtained
during the process of creating the templates. As mentioned, the template was created
based on the mean values of every fiducial point in an ECG record. Taking these
values into account, we then compare them with its original ECG. By using this
method, we were measuring the difference between the templates from their original
source, and thus taking these measurements as part of the threshold range. The flow
of process is very similar to the template-matching algorithm (Diagram 3.5), except
that in this case, it is certain that all the templates must match with its original source.
Hence, instead of finding a match, we will calculate the difference between the
template and the cardiac cycles that have been segmented from its original ECG
source, and the maximum value from this result will be used to determine threshold
value implemented in the template-matching algorithm (section 3.5.2).




  Figure 13: Magnified view of the cardiac cycles (in red) and its corresponding template (in blue)
  At the top is their Matlab code




BME 499 Capstone BME Project                             24                                           SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


With reference to the example shown in Figure 13, the red graphs represent three
cardiac cycles segmented from the same ECG, and the blue graph represents the
template that was created from the same ECG as well. Using the variables from the
Matlab codes, „k1‟ is the number of cardiac cycles segmented and „k2‟ is the total
number of fiducial points in a cardiac cycle. In the figure, sumR(1,25) refers to the
25th fiducial point in the first segmented cardiac cycle, sumR(3,37) refers to the 37th
fiducial point in the third segmented cycle, avgAllR(25) is the 25th fiducial point in
the template, and so on. Please note, however, that this is just an illustration, since the
real values and the number of cardiac cycles used in this project were much larger.


The gap, or the distance between the template and the cardiac cycles were calculated
by getting the absolute difference between each point from the template. For example,
as an easy reference assuming that avgAllR(25) = 21, sumR(1,25) = 18, sumR(2,25)
= 9, sumR(3,25) = -12, sumR(1,37) = -16, sumR(2,37) = -25, and sumR(3,25) = -30,
hence we have:
                 gap(k1,k2)  avgAllR(k2)  sumR(k1,k2)
                 gap(1,25)  avgAllR(25)  sumR(1,25)  2118  3
                 gap(2,25)  avgAllR(25)  sumR(2,25)  21 9  12
                 gap(3,25)  avgAllR(25)  sumR(3,25)  21 (12)  33
                max_ thres(25)  33


                 gap(1,37)  avgAllR(37)  sumR(1,37)  21 (16)  37
                 gap(2,37)  avgAllR(37)  sumR(2,37)  21 (25)  46
                 gap(3,37)  avgAllR(37)  sumR(3,37)  21 (30)  51
                max_ thres(37)  51


Based on this calculation, we were able to get the maxima of the absolute difference
     
at fiducial point 25 and 37. These are the example of the values used to obtain the
maximum and minimum threshold for the template-based matching, which are shown
in the codes below as the variable maxP and minP.




BME 499 Capstone BME Project                        25                           SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


3.6 Final Part: ECG Analysis and Classification
The last part of this chapter covers the analysis and classification of the ECG. The
classification process occurs right after the end of the previous part of the project.
Depending on the result from template-matching phase, the system will categorized
them into one of the four classifications.


3.6.1 Classification & its Definition
There are a total of four classifications implemented into the system. They are True
Positive, False Positive, True Negative, and False Negative. In the next chapter, we
will discuss thoroughly on the sensitivity, specificity and accuracy of the algorithm
applied, based on the analysis of these classifications.


In a statistical hypothesis test [16], there are two types of statistical error that could be
drawn, a Type I error and a Type II error. Type I error, also known as False Positive,
refers to a result that has inaccurately detect something as positive, when in fact it is
not. This type of result is normally interpreted as „false alarm‟. Whereas for a Type II
error, also known as False Negative, it refers to a result that has failed to detect
something that is known to be present, this could be interpreted as „oversight‟ by the
system. In contrast to these two errors are the classifications of results for True
Positive and True Negative. In True Positive, the result accurately gives a positive and
correct reading, while in True Negative; the result makes a correct rejection, hence
giving the result a negative reading.


3.6.2 The Classification of Results
In this project, the classification of the results was based on several factors, mostly
from the outcome of the ECG-Template matching. The factors include:


    1) The type of ECG being tested (either from a normal or AF datasets)
    2) The type of template that matches, or
    3) If there‟s a positive match




BME 499 Capstone BME Project                        26                              SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


True positive classification
The result is classified as “True Positive” if the ECG was extracted from AF datasets,
and the template that it matched with was an AF template. The criteria for this match
are it must have above 70% similarities and should appear in few consecutive cycles.

False Positive Classification
The result is classified as “False Positive” if the ECG was extracted from Normal
Sinus Rhythm datasets, and the template that it matched with was an AF template.
The criteria for this match are it must have above 70% similarities and appears in few
consecutive cycles.


True Negative Classification
The result is classified as “True Negative” if the ECG was extracted from Normal
Sinus Rhythm datasets, and the template that it matched with was a Normal Rhythm
template. However, this classification can also occur if the normal case ECG used
does not match with any template.


False Negative Classification
The result is classified as “False Negative” if the ECG used was extracted from AF
datasets, and the template that it matched with was a Normal Rhythm template. This
classification can also occur if the AF ECG used does not have any match at all.



                  ECG Dataset                                Template


       NORMAL                        AF           AF               NORMAL    NO MATCH




TRUE POSITIVE                  FALSE POSITIVE            TRUE NEGATIVE      FALSE NEGATIVE



Diagram 3.6: Classifications of the results




BME 499 Capstone BME Project                        27                          SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


3.7 Graphic User Interface
To facilitate in the testing and analysing of the ECG datasets, a GUI was implemented
in the program. In this GUI, the following control options were available for the user.


    a) AF/Normal ECG button: Depending on which button is selected, this will load
        „drop-down‟ list of available ECG datasets for analysis.
    b) Close Graph button: This will close all the figures launched by the system.
    c) Clear var button: A clear all, and clear screen (clc) button.
    d) Create Template button (only in TemplateGui.m): Once a particular dataset is
        selected, this button will load and execute the TemplateSetA.m file.
    e) Analyse ECG button (only in TrainingGui.m): Similarly, once the user selects
        a particular datasets from the „drop-down‟ menu list, this button will load the
        data and execute the ProgSetA.m file.




       Figure 14: GUI to create template (top) and run template-matching process (bottom)



BME 499 Capstone BME Project                        28                                      SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


CHAPTER 4: RESULTS AND DISCUSSION


4.1 Results obtained
The results gathered in this project were from the different phases of both the training
and testing stage. In phase one, the results gathered were based from template
comparison made with its original ECG datasets. This phase is considered as the
„training‟ phase, because most of the modifications of the codes or algorithm were
information obtained from the results and the errors encountered. The second phase is
the testing phase. In this phase, similar ECG datasets, as used in Phase one, were
extracted, but at a different timing. In the last phase, which is the re-evaluation phase,
the datasets tested was extracted from a completely different source/database.


At the end of each phase, all the results were tabulated and presented in terms of its
filename, timing, duration of ECG, the percentage matched with the template, and the
classification with the acronyms of TN, TP, FN and FP, which refers to true negative,
true positive, false negative, and false positive, respectively. All the datasets for the
10-seconds and 60-seconds duration can be found at the directory and folder named
“/Sets/CompareSets1/” and “/Sets/CompareSets2” respectively.


4.1.1 Phase one - Training
In this phase, the datasets tested, consisting of ten normal sinus rhythm recordings and
ten Atrial Fibrillation episodes, were extracted from the same source and at the same
timing, as the ECG used to make the templates. The duration of these ECG datasets
taken were 10 seconds long. In addition to this, another group of datasets, containing
another ten normal rhythm recordings and ten Atrial Fibrillation episodes, were
tested. These datasets, with 60-seconds duration, were from similar source as the one
mentioned previously, however, some of them were extracted at a different timing,
which is about few seconds after the 10-seconds duration. Hence this makes a total of
datasets tested in this phase to twenty normal sinus rhythm and twenty AF episodes.
The results for this phase were presented in Table 4.1.1a and Table 4.1.1b.




BME 499 Capstone BME Project                        29                            SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder




Table 4.1.1a: Normal Rhythm ECG Datasets Results – Phase 1
 Filename         Timing         Duration      Percentage           Classification
                                 (seconds)    Matched (%)
C1a              09:55:00 – 09:55:10         10                96   TN
C2a              10:45:00 – 10:45:10         10                93   TN
C3a              09:20:00 – 09:20:10         10                91   TN
C4a              08:04:00 – 08:04:10         10                97   TN
C5a              09:54:00 – 09:54:10         10                80   TN
C6a              08:40:00 – 08:40:10         10                80   TN
C7a              09:50:00 – 09:50:10         10                98   TN
C8a              11:48:00 – 11:48:10         10                85   TN
C9a              11:15:00 – 11:15:10         10                80   TN
C10a             11:06:00 – 11:06:10         10                93   TN

C1_60a           10:02:00 – 10:03:00         60                81   TN
C2_60a           10:56:00 – 10:57:00         60                85   TN
C3_60a           09:31:00 – 09:32:00         60                82   TN
C4_60a           08:18:00 – 08:19:00         60                82   TN
C5_60a           11:45:00 – 11:46:00         60                -    FP
C6_60a           10:21:00 – 10:22:00         60                -    FP
C7_60a           11:32:00 – 11:33:00         60                89   TN
C8_60a           13:30:00 – 13:31:00         60                89   TN
C9_60a           12:57:00 – 12:58:00         60                87   TN
C10_60a          12:52:00 – 12:53:00         60                -    FP

Table 4.1.1b: Atrial Fibrillation ECG Datasets Results – Phase 1
 Filename            Timing          Duration      Percentage       Classification
                                     (seconds)    Matched (%)
C11a             01:28:24 – 01:28:34         10                -    FN
C12a             02:02:07 – 02:02:17         10                90   TP
C13a             01:44:04 – 01:44:14         10                92   TP
C14a             16:39:12 – 16:39:22         10                -    FN
C15a             18:30:00 – 18:30:10         10                86   TP
C16a             03:59:45 – 03:59:55         10                93   TP
C17a             12:28:41 – 12:28:51         10                89   TP
C18a             14:55:51 – 14:56:01         10                87   TP
C19a             21:41:45 – 21:41:55         10                -    FN
C20a             22:05:52 – 22:06:02         10                -    FN

C11_60a          01:29:24 – 01:30:24         60                -    FN
C12_60a          02:03:07 – 02:04:07         60                82   TP
C13_60a          01:44:04 – 01:45:04         60                93   TP
C14_60a          16:39:12 – 16:40:12         60                -    FN
C15_60a          18:31:10 – 18:32:10         60                83   TP
C16_60a          03:59:45 – 04:00:45         60                86   TP
C17_60a          12:28:51 – 12:29:51         60                82   TP
C18_60a          14:55:51 – 14:56:51         60                82   TP
C19_60a          21:41:45 – 21:42:45         60                -    FN
C20_60a          22:06:52 – 22:07:52         60                88   TP


BME 499 Capstone BME Project                        30                   SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


4.1.2 Phase two - Testing
In the second phase, the algorithm was tested by using the datasets that were similar
to the ECG used to make the templates, but at a different timing. Most of the cases
were obtained few seconds or minutes after the timing used in the first phase. The
total number of datasets used in this phase was eighteen normal rhythm and twenty
AF episodes, each containing the duration of 10 and 60 seconds long. The results
from this phase were presented in Table 4.1.2a and Table 4.1.2b.



Table 4.1.2a: Normal Rhythm ECG Datasets Results – Phase 2
Filename          Timing        Duration       Percentage               Classification
                                (seconds)    Matched (%)
C1b            09:56:20 – 09:56:30          10                 85      TN
C2b            10:46:00 – 10:46:10          10                 -       FP
C3b            09:21:00 – 09:21:10          10                 -       FP
C4b            08:05:00 – 08:05:10          10                 95      TN
C5b            09:55:00 – 09:55:10          10                 -       FP
C6b            08:41:00 – 08:41:10          10                 84      TN
C7b            09:51:00 – 09:51:10          10                 87      TN
C8b            11:49:00 – 11:49:10          10                 -       FP
C9b            11:16:00 – 11:16:10          10                 -       FP
C10b           11:07:00 – 11:07:10          10                 -       FP

C1_60b         13:16:00 – 13:17:00          60                 -       FP
C2_60b         12:50:00 – 12:51:00          60                 84      TN
C3_60b         15:42:00 – 15:43:00          60                 88      TN
C4_60b         12:34:00 – 12:35:00          60                 88      TN
C5_60b         13:31:00 – 13:32:00          60                 80      TN
C6_60b         11:58:00 – 11:59:00          60                 -       FP
C7_60b         09:09:00 – 09:10:00          60                 81      TN
C8_60b         10:43:00 – 10:44:00          60                 82      TN


Table 4.1.2b: Atrial Fibrillation ECG Datasets Results – Phase 2
Filename           Timing            Duration      Percentage           Classification
                                     (seconds)    Matched (%)
C11b           01:29:04 – 01:29:14          10                 -       FN
C12b           02:02:57 – 02:03:07          10                 89      TP
C13b           01:44:54 – 01:45:04          10                 78      TP
C14b           16:40:02 – 16:40:12          10                 -       FN
C15b           18:31:00 – 18:31:10          10                 87      TP
C16b           04:00:35 – 04:00:45          10                 88      TP
C17b           12:29:11 – 12:29:21          10                 88      TP
C18b           14:56:31 – 14:56:41          10                 91      TP
C19b           21:42:25 – 21:42:35          10                 88      TP
C20b           22:06:42 – 22:06:52          10                 96      TP



BME 499 Capstone BME Project                        31                       SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


C11_60b        08:52:10 – 08:53:10          60                 85        TP
C12_60b        20:30:27 – 20:30:27          60                 84        TP
C13_60b        02:01:49 – 02:02:49          60                 81        TP
C14_60b        02:03:24 – 02:04:24          60                 90        TP
C15_60b        04:54:00 – 04:55:00          60                 86        TP
C16_60b        19:04:21 – 19:05:21          60                 82        TP
C17_60b        06:46:01 – 06:47:01          60                 87        TP
C18_60b        03:34:58 – 03:35:58          60                 83        TP
C19_60b        01:15:08 – 01:16:08          60                 83        TP
C20_60b        12:29:42 – 12:30:42          60                 81        TP




4.1.3 Phase three – Re-evaluation
In the last phase, the datasets used were obtained from a different source, and none of
them were involved in the creation of the template. The purpose of this phase is to
evaluate the limitation and flexibility of the templates, whether they are capable to
detect episodes found in unrelated ECG. The ECG tested here consists of twenty AF
cases, divided into ten ECG with 10-seconds duration and another ten with 60-
seconds duration. The results were presented in Table 4.1.3.



Table 4.1.3: Atrial Fibrillation ECG datasets Results – Phase 3
Filename            Timing           Duration       Percentage           Classification
                                     (seconds)    Matched (%)
C11c           08:52:20 – 08:52:30          10                 93        TP
C12c           20:30:57 – 20:31:07          10                 84        TP
C13c           02:02:29 – 02:02:39          10                 89        TP
C14c           02:03:54 – 02:04:04          10                 86        TP
C15c           04:54:30 – 04:54:40          10                 95        TP
C16c           19:04:31 – 19:04:41          10                 91        TP
C17c           06:46:21 – 06:46:31          10                 92        TP
C18c           03:35:28 – 03:35:38          10                 94        TP
C19c           01:15:38 – 01:15:48          10                 83        TP
C20c           12:30:22 – 12:30:32          10                 82        TP

C11_60c        19:33:14 – 19:34:14          60                 91        TP
C12_60c        20:31:28 – 20:32:28          60                 84        TP
C13_60c        02:02:50 – 02:03:50          60                 79        TP
C14_60c        02:04:25 – 02:05:25          60                 87        TP
C15_60c        04:55:01 – 04:56:01          60                 -         FN
C16_60c        19:05:22 – 19:06:22          60                 86        TP
C17_60c        06:47:02 – 06:48:02          60                 83        TP
C18_60c        03:35:59 – 03:36:59          60                 83        TP
C19_60c        01:16:09 – 01:17:09          60                 85        TP
C20_60c        19:32:13 – 19:33:13          60                 86        TP



BME 499 Capstone BME Project                        32                         SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


4.2 Specificity and Sensitivity
Specificity refers to the measurement of the proportion of negatives, which have been
detected. Sensitivity, on the other hand, measures the proportion of actual positives
that have been correctly identified [16]. Both the specificity and sensitivity are related
to the Type I and Type II errors, as explained in Chapter 3.


The percentage of the specificity and sensitivity of the results were based on the
following calculation:
                                               TN
                           Specificity(%)           100
                                             TN  FP
                                               TP
                           Sensitivity(%)           100
                                             TP  FN
                                                 TP  TN
                           Accuracy(%)                       100
                                            TP  TN  FP  FN


where TN, TP, FP, and FN stand for true negative, true positive, false positive, and
            
false negative, respectively.


                         No. of
                       Datasets         Specificity (%)        Sensitivity (%)   Accuracy (%)
                      N       AF
    Phase 1           20      20                85                   65               75
    Phase 2           18      20               55.6                  90              73.7
    Phase 3            0      20                 -                   95               95

    Overall           38        60             71.1                 83.3             78.6
  Table 4.2: Specificity, Sensitivity and Accuracy results
  *N – Normal. AF – Atrial Fibrillation



As can be seen in Table 4.2, the sensitivity is reasonably high, particularly in Phase 3,
where the ECG datasets tested were random and unrelated to the ECG used to create
the templates. This proves to be quite encouraging; as it shows that using template-
based matching algorithm could produce a good result, and can be considered as one
of the possible approach to detect cardiac arrhythmias. However, further analysis is
still required to improve the specificity and the accuracy of the algorithm. This could
be improved by expanding the template database, and increase the range/duration of
the ECG.

BME 499 Capstone BME Project                        33                               SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


4.3 Discussions
In this part of the chapter, we will review the approach, methods applied and the
results in more detailed. Certain issues that have yet to be presented in the
methodology part of the report will be presented here as well.


4.3.1 Review of Theory & Approach
The approach taken in this project is based on the observation of similarities in ECG
shapes on patients with the same disease. To recap, the algorithm applied involved
with the extraction of individual cardiac cycles by segmenting the ECG, and creating
the template using the mean of every fiducial point on the cycle segmented. Both
Normal Sinus Rhythm, and Atrial Fibrillation ECG were tested against the templates
created, and a match is determined based on the parameters implemented, such as the
thresholds, and the percentage of fiducial points that were “flagged” as a possible
match. The testing phase were divided into three phases, training, testing and re-
evaluation. A total of 98 one-channel ECG datasets, consisting of 38 Normal Sinus
Rhythm, and 60 Atrial Fibrillation episodes, each comprising of equal numbers of 10-
seconds and 60-seconds duration recordings, were tested.


In addition to further visualize the theory applied in this algorithm, as you can see in
Figure 15, all the ECG presented was AF episodes extracted from six different
patients. Note the similarity within the beginning of the cardiac cycle to the R-peaks.
The p-waves on each ECG presented appears to be absent.

                               N01                        N02             N03




                               N04                        N05             N06




         Figure 15: Similarities of shape between AF cases



BME 499 Capstone BME Project                        34                          SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


4.3.2 Interpretation of Results
In each of the phases, based on the observation of the percentage matched between
the templates and ECG datasets, the results appeared to be better than expected. For
most of the result presented, the percentages are above 80% matched, which is
slightly higher than the minimum percentage set in the algorithm (i.e. >70%). It also
has been observed that the algorithm is more efficient in detecting AF than Normal
ECG, particularly during phase 2 (refer to Table 4.1.2). The specificity, sensitivity
and accuracy, however, still display reasonably good results. Even though the
specificity and accuracy is lower, especially when compared to results from other
relevant studies/journals (refer to Table 4.3.1), the algorithm is still capable to detect
AF in random ECG obtained from the Physionet database, which has been further
proven during Phase 3 (Table 4.1.3). By achieving this result, the target of this project
has been achieved.

                                                  Specificity (%)       Sensitivity (%)
              Proposed Algorithm                       71.1                  83.3
                                 [12]
              Tateno and Glass                           96.7                93.2
              Thong and Mcnames [13]                      91                  89
                              [17]
              Mood and Mark                              85.9                93.6
                                    [18]
              Couceiro and Carvalho                      96.1                93.8
           Table 4.3.1: Comparison of the Specificity and Sensitivity

In Table 4.3.1, a brief comparison on the percentage of the specificity and sensitivity
was made between this proposed algorithm and results from other literature/studies,
which uses different algorithm to detect AF.


4.3.3 Review of Methods
Most of these parameters, arguments or criteria implemented in the programming
codes, were based on thorough test, trial and error, using different sets of ECG. In the
following part, we will review some of the approaches taken, which have been
discussed in the methodology chapter, and a more detailed explanation on the reason
why certain parameters were used, will also be presented.




BME 499 Capstone BME Project                        35                                    SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


Windows Length
In section 3.3.3 of Chapter 3, it was indicated that the ECG was segmented into
windows containing series of cardiac cycles. The start-point of the cardiac cycle was
determined by subtracting the value 0.35 seconds from the R-peak, and adding the
same value from the same R-peak to get the end-point. This value appeared to be the
optimal value to be used after running several tests using different values ranging
from 0.2 to 0.6 seconds long. The main reason to do this is to avoid extracting cardiac
cycles that are too short or too long, as shown in Figure 16a.




  Figure 16a: Example of Cardiac Cycle Segmented – 0.2 from peak (left) and 0.6 from peak (right)
  Both display either too short or too long respectively.

The examples shown in Figure 16a and 16b were from the same cardiac cycles
extracted by different parameter. As you can see from Figure 16a, the window length
was resulted by taking the value 0.2 and 0.6 seconds from the peak respectively. It is
either too short, hence missing the T-wave, or too long, resulting in extraction of
addition wave-shape at the beginning of the cycle. However, in Figure 16b, the result
displays all the components of the ECG clearly. This was achieved by using the
optimal value of 0.35 seconds (towards the start and end point) from the peak.




                  Figure 16b: Example of Cardiac Cycle Segmented – 0.35 from peak


BME 499 Capstone BME Project                        36                                  SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


Number of Consecutive Cardiac Cycle matched
One of the criteria in the template-matching process is that in order to consider the
ECG event as a match, 5 or 7 consecutive cardiac cycles must be detected. The
method was discussed in section 3.5.2. Most of AF cases normally appears in every
consecutive cardiac cycles until it terminates itself naturally, which is usually few
seconds, minutes, hours or even days. Since the duration of datasets used in this
project is quite short, either 10-seconds or 60-seconds long, we can only detect a short
period of AF events (if any) and we cannot assume that the whole ECG recording is
the duration of AF event, for example 10-second ECG does not mean 10-second AF
episode recorded. Hence, by setting a fixed number of cycles to be detected, we can
avoid situation where the algorithm might be too sensitive if only 1 or 2 cycles are
detected, as this will cause the system to identify a lot of cases as positive, or to
“overlook” AF event, if the value set is too wide, hence unable to detect the event
even though it may be within that section of the ECG. The implemented value was 5
consecutive cycles in 10-second duration, and 7 consecutive cycles in 60-seconds
duration, which is relatively a fair value considering that we are not sure how long has
the AF been occurring at the time the ECG was recorded (whether it appears at the
beginning, the end or anywhere in the ECG).


Fiducial Points Extracted
Again, in section 3.5.2, it‟s been mentioned that the fiducial points extracted for
template matching has the length consisting of 44 fiducial points (refer to Figure 12a).
The reason for this is that we only wanted to focus on the important features of the
cardiac cycle, which includes the points before the P-wave and the PR-interval, since
this is where the AF event is normally presented (absence of P-wave). Hence, due to
the similar reason as with the number of cardiac cycles implemented, this approach
was used in order to lower the chances of getting a „Type I‟ or „Type II‟ errors, as
there are more fiducial points extracted if the whole cardiac cycle is used. This
includes the unnecessary features to be compared, like the T-wave, whereby most of
the ECG datasets used (both AF and normal sinus rhythm) display prominent ST-
intervals. This is also to avoid the system from getting “error” due to mismatched
found in the ST-interval, especially if random abnormalities, like long QT syndrome
or the left bundle branch block, occur. However, this can be an exception if other


BME 499 Capstone BME Project                        37                            SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


abnormalities or arrhythmias were intentionally included in the test, or if we want to
do a more in-depth test/comparison involving with these cases. We could then
differentiate between them much better by using the full cardiac cycle length, as there
are some abnormalities that are presented within the ST-interval, like the ones already
mentioned – the long QT syndrome or the left bundle branch block (inverted T wave).




                                                          Unnecessary part to be
                                                          compared with since most
                                                          cardiac cycles display ST-
                                                          interval




  Figure 17: Unnecessary part of the Cardiac Cycles that can be seen in both AF and Normal ECG



4.3.4 Problems Encountered
There are a few concerns relating to the template-based matching algorithm. One of
the main concerns is its capability to detect AF in the presence of other arrhythmia,
abnormalities or stresses, within the same ECG. In this project, the main focus is to be
able to detect AF, and the datasets used were mainly either Normal cases or ECG
annotated with AF episodes. Due to lack of time, and database/resources accessibility,
no test was done for cases other than the two mentioned. Thus it is unknown if the
algorithm would be able to detect correctly or able to differentiate between different
arrhythmia, such as premature atrial contraction or multifocal atrial tachycardia.


Another issue encountered was related to the detection of the R-peaks. Most of the
ECG datasets used did not present any problems, except for a few cases. In these
cases, based on observation, their R-peaks were generally quite low (see Figure 18).
The only way to get them detected is to manually change the threshold values.
However, upon testing, it is quite impossible to modify the values without
compromising the results for the majority of the ECG datasets. Hence, this shows that


BME 499 Capstone BME Project                        38                                 SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


the thresholds implemented for the R-peak detection were not adaptive or dynamic
enough to accommodate to this scenario.

                                                                   Undetected




           Figure 18: Example of undetected R-Peaks



These issues are one of the few things that could be included for future improvements.


4.4 User Interface Simulation
This is an additional part of the project. In order to visualize how this algorithm can
be used as part of the future development of an AF recorder, a simple Matlab GUI
“simulation” was created to represent the possible user interface for patients. The
difference between the program executed during the testing phase and this simulation
is that, in this simulation, the system does not terminate when a match is found,
instead, it “saves” the series of cardiac cycle that were detected, and continues to
locate any other possible match in the remaining section of the ECG. Upon detection,
the user will be able to view all the detected events by browsing through the
simulation. In the GUI, the following control functions are available for user:


    a) Run SIM button: This will execute the UserIntB.m file, and an ECG
        recordings will be loaded, and displayed in its corresponding axes.
    b) Clear button: This will delete the current stored files, consists of events that
        were detected by the system. Recommended to clear them before running the
        program.
    c) >>/<< or Next/Previous button: This is part of the User Interface Simulation
        view for users/patients. The purpose is for users to browse through all the
        events that have been detected.



BME 499 Capstone BME Project                        39                          SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder




       Figure 19a: GUI/Controls to execute the simulation



Figure 19b shows the interface for users/patients. They will be able to browse through
all the events detected, as well as checking their ECG status (If no event was detected
it will be displayed as „OK‟, otherwise a „Detected‟ will be displayed), their heart rate
in beats per minute, and the episodes counter, which displays the number of events
detected. This is just a personal impression on how the AF recorder may look like in
the future, whereby the recorder placed on the chest will be able to transfer the
recorded signal wirelessly to a portable/personal signal reader, or personal mobile
devices.
                               Example of an AF                       Previous &
                               episode Detected                       Next Button         Status, Heart Rate
                                                                                          (bpm) & episode
                                                                                         counter information




     Figure 19b: My personal impression of what the future AF may look like and what
     users/patient will be able to see upon positive detection


BME 499 Capstone BME Project                        40                                 SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


CHAPTER 5: CONCLUSION AND FUTURE WORK


5.1 Conclusion
In this report, I have presented an algorithm for template-based matching of ECG
extracted from digitized ECG database consisting of Atrial Fibrillation and Normal
Sinus Rhythm recordings. The idea of this algorithm was based on the theory studied
that patients with same cardiac arrhythmias/abnormalities tend to have similarities in
their ECG. This observation, however, was made by factoring out a number of
morphological variations such as variability that could affect the ECG amplitude
level.


The results gathered was better than expected, especially with the algorithm‟s
sensitivity, whereby more than 80% of the overall results were correctly identified as
positive. Further improvement could be made, however, as mentioned in the previous
chapter, there were issues that are yet to be resolved. The concerning issues are
involved with the algorithm‟s incapability of detecting R-peaks that are lower than the
ones tested and found in a typical ECG, as well as the uncertainty of the outcome or
result if other types of arrhythmia were present in the datasets.


However, despite the problems encountered, I would conclude that the project is still
quite a success, since the objective of developing an algorithm to detect Atrial
Fibrillation episodes has been achieved.


5.2 Recommendation for Future Work
There are few things I would like to recommend for future work. One of the things
will be improving the algorithm to detect Atrial Fibrillation on real-time. The method
applied in this project is mainly focused on pre-recorded ECG data, which has already
been analyzed and annotated by the website or database library. To be able to do this
on real-time could also lead to the possibility that the algorithm can run and detect
faster, and on a longer duration. Currently, the system runtime can reach up to a
maximum time of 225.015 seconds, just to detect an AF episode on a 60-second
duration ECG. Another improvement that could be made is to have a larger database
for both the templates and the number of ECG datasets, since only 20 templates and


BME 499 Capstone BME Project                        41                         SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


98 ECG datasets were tested in this project. With larger database used, the results
may differ and more comparisons can be done.




CHAPTER 6: CRITICAL REVIEW AND REFLECTION


The first thing I was worried about when I started this project was that I am not
experienced enough to truly understand how to analyse ECG, since I am not a
professional, neither do I have the relevant training. Throughout this project, in order
to improve my understanding on this topic, I have used the guides from the Physionet
website, did thorough research on the Internet, as well as going through textbooks and
seeking assistant from my project supervisor. Eventually it does pay off, and that
leads me to be able to focus and differentiate between issues that need to be done and
things that could be set-aside.


Another skills that are required are time and project management skills. During the
early phase of the project, I have spent too much time on researching and comparing
the best approach to develop the algorithm. Hence, there‟s a slight delay when it
comes to the programming phase. However, things slowly went back as planned once
I started doing the coding, testing and debugging at the same time, and eventually I
managed to complete the project on time.


I have learned a lot of things from this project, especially in the knowledge of cardiac
arrhythmias, analysis of ECG, and problem solving in general. My skills in Matlab
programming has also improved tremendously, as compared to the time when the
project just begun and I was still quite new to this programming language. Overall, I
am grateful that I have chosen this project, as the experience I‟ve gained, from time
management skills to problem solving skills, has been beneficial.




BME 499 Capstone BME Project                        42                         SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


REFERENCES


[1] AF Answers, “What is Atrial Fibrillation”,
http://www.afanswers.com/whatIsAf.html
[2] Winthrop University Hospital, “Atrial Fibrillation Treatment Center”,
http://www.winthrop.org/departments/clinical/cardiology/Fibrillation/
[3] http://www.physionet.org/physiobank/database/
[4] Electrocardiogram(ECG) Recording, http://www.txai.org/edu/arrdiag/ecg.htm
[5] Michele Brignole, Carissa L. Bellardine, Poul E. Bloch Thomsen, “Improved
Arrythmia Detetion in Implantable Loop Recorders”, Journal of Cardiovascular
Electrophysiology 2008, www.medscape.com
[6] Brighton and Sussex University Hospital, “Implantable Reveal Loop Recorder”,
http://www.sussex-cardiac-centre.co.uk/2i-loopimplant.htm
[7] Wikipedia, “Echocardiography”, http://en.wikipedia.org/wiki/Electrocardiography
[8] Mohamed Ben Messaoud. “Neuronal Classification of Atria Fibrillation”
[9] “ACC/AHA/ESC 2006 Guidelines for management of patients with Atrial
Fibrillation”, Circulation 114 (7): e257-354
[10] Vidur Arora, Rahul Chugh, Abhishek Gagneja, K A Pujari “Digital ECG and its
Analysis”, IEEE Colloquium and International Conference
[11] Jiapu Pan and Willis J Tompkins, "A Real-Time QRS Detection Algorithm",
IEEE Transactions on Biomedical Engineering, Vol. BME-32, No. 3. 1985
[12] K Tateno, L Glass, “A Method for Detection of Atrial Fibrillation Using RR
Intervals”, Computers in Cardiology 2000; 27:391-394
[13] Tran Thong, James McNames, Mateo Aboy, Brahm Goldstein, “Prediction of
Paroxysmal Atrial Fibrillation by Analysis of Atrial Premature Complexes”, IEEE
Transactions on Biomedical Engineering 2004; 51:561-569
[14] Tanveer Syeda-Mahmood, David Beymer, “Shape-Based Matching of ECG
Recordings”, Healthcare Informatics Group
[15] F wang, T Syeda-Mahmood, D Beymer, “Finding Disease Similarity by
Combining ECG with Heart Auscultation Sound”, Computers in Cardiology
2007;34:261-264
[16] Wikipedia, “Sensitivity and Specificity”,
http://en.wikipedia.org/wiki/Sensitivity_and_specificity


BME 499 Capstone BME Project                        43                      SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


[17] Moody B G, Mark R G, "A new Method for Detecting Atrial Fibrillation using
R-R Intervals", IEEE Computers in Cardiology 1983; 10:227-230
[18] R Couceiro, P Carvalho, J Henriques, "Detection of Atrial Fibrillation Using
Model-Based ECG Analysis", 2008
[19] Behzad Mozaffary, Mohammad A Tinati, “ECG Baseline Wander Elimination
using Wavelet packets”, World Academy of Science, Engineering and Technology
2005
[20] E Petrucci, V Balian, G Filippini, LT Mainardi, “Atrial Fibrillation Detection
Algorithms for Very Long Term ECG Monitoring” Computers in Cardiology 2005;
32:623-626
[21] Rangavaj M. Rangayyan, “Biomedical Signal Analysis: A case study approach”,
Wiley-IEEE press, 2001
[22] Tracy Chou, Yuriko Tamura, Ian Wong, “Detection of Atrial Fibrillation in
ECGs”




BME 499 Capstone BME Project                        44                       SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


APPENDICES


Appendix A1: Matlab Codes
TemplateSetA.m




BME 499 Capstone BME Project                        45             SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder




BME 499 Capstone BME Project                        46             SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder




BME 499 Capstone BME Project                        47             SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


ProgSetA.m




BME 499 Capstone BME Project                        48             SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder




BME 499 Capstone BME Project                        49             SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder




BME 499 Capstone BME Project                        50             SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder




BME 499 Capstone BME Project                        51             SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder




TemplateGui.m




BME 499 Capstone BME Project                        52             SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder




BME 499 Capstone BME Project                        53             SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


TrainingGui.m




BME 499 Capstone BME Project                        54             SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder




BME 499 Capstone BME Project                        55             SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder




BME 499 Capstone BME Project                        56             SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


Appendix A2: Templates

Atrial Fibrillation Templates.


Source: /Template/TemplateSource/Afib/T11.mat
Stored: /Template/ST11.mat




Source: /Template/TemplateSource/Afib/T12.mat
Stored: /Template/ST12.mat




BME 499 Capstone BME Project                        57             SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


Source: /Template/TemplateSource/Afib/T13.mat
Stored: /Template/ST13.mat




Source: /Template/TemplateSource/Afib/T14.mat
Stored: /Template/ST14.mat




BME 499 Capstone BME Project                        58             SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


Source: /Template/TemplateSource/Afib/T15.mat
Stored: /Template/ST15.mat




Source: /Template/TemplateSource/Afib/T16.mat
Stored: /Template/ST16.mat




BME 499 Capstone BME Project                        59             SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


Source: /Template/TemplateSource/Afib/T17.mat
Stored: /Template/ST17.mat




Source: /Template/TemplateSource/Afib/T18.mat
Stored: /Template/ST18.mat




BME 499 Capstone BME Project                        60             SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


Source: /Template/TemplateSource/Afib/T19.mat
Stored: /Template/ST19.mat




Source: /Template/TemplateSource/Afib/T20.mat
Stored: /Template/ST20.mat




BME 499 Capstone BME Project                        61             SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


Normal Sinus Rhythm Templates.


Source: /Template/TemplateSource/Normal/T1.mat
Stored: /Template/ST1.mat




Source: /Template/TemplateSource/Normal/T2.mat
Stored: /Template/ST2.mat




BME 499 Capstone BME Project                        62             SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


Source: /Template/TemplateSource/Normal/T3.mat
Stored: /Template/ST3.mat




Source: /Template/TemplateSource/Normal/T4.mat
Stored: /Template/ST4.mat




BME 499 Capstone BME Project                        63             SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


Source: /Template/TemplateSource/Normal/T5.mat
Stored: /Template/ST5.mat




Source: /Template/TemplateSource/Normal/T6.mat
Stored: /Template/ST6.mat




BME 499 Capstone BME Project                        64             SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


Source: /Template/TemplateSource/Normal/T7.mat
Stored: /Template/ST7.mat




Source: /Template/TemplateSource/Normal/T8.mat
Stored: /Template/ST8.mat




BME 499 Capstone BME Project                        65             SIM University
Final Report
Student: Ita Suzana Bte Mat Jais (H0605409)
Project: Atrial Fibrillation Detection Algorithm for AF Recorder


Source: /Template/TemplateSource/Normal/T9.mat
Stored: /Template/ST9.mat




Source: /Template/TemplateSource/Normal/T10.mat
Stored: /Template/ST10.mat




BME 499 Capstone BME Project                        66             SIM University
Final Report

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:26
posted:11/2/2011
language:English
pages:73