arrhythmia classification using support vector machine -alexis pena

Upload: chetansrinidhi

Post on 03-Jun-2018

224 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    1/36

    CALIFORNIA STATE UNIVERSITY, NORTHRIDGE

    ARRHYTHMIA CLASSIFICATION USING SUPPORT VECTOR MACHINE

    A graduate project submitted in partial fulfillment of the requirements

    For the degree of Master of Science

    in Electrical Engineering

    By

    Alexis Pena

    August 2013

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    2/36

    ii

    The graduate project of Alexis Pena is approved:

    __________________________________ _________________________

    Benjamin F Mallard Date

    __________________________________ _________________________

    Dr. Ali Amini Date

    __________________________________ _________________________

    Dr. Xiyi Hang, Chair Date

    California State University, Northridge

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    3/36

    iii

    TABLE OF CONTENTS

    Signature page.ii

    Abstract...iv

    Introduction..1

    Support Vector Machine .8

    Feature extraction ..........12

    Numerical Experiment.......14

    Discussion......22

    Bibliography .....23

    Appendix....24

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    4/36

    iv

    ABSTRACT

    ARRHYTHMIA CLASSIFICATION USING SUPPORT VECTOR MACHINE

    By

    Alexis Pena

    Master of Science in Electrical Engineering

    The number one cause of death in the United States is heart disease (1). 67% of heart

    disease death is brought on by sudden cardiac death. Most of these cases are due to an

    abnormal electrical triggering of the heart which disrupts blood circulation that lead to

    immediate death if electrical shock therapy is not applied. Automatic arrhythmia analysis

    helps speed up the defibrillation therapy to correct the disruption in the electrical system.

    Implantable defibrillators analyze every heart beat and proper classification is the key to

    saving thousands of lives every year. In my project, I approached automatic arrhythmia

    analysis through support vector machine classification (SVMs). I analyze time series

    ECG heartbeat files from multiple subjects with various arrhythmias, as well as normal

    heartbeats with no arrhythmias. The heartbeat signals are extracted into individual beats

    and classified using SVM. The performance of the SVM is evaluate through multiple

    kernel modification, including higher order dimension analysis and compared to achieve

    the best classification accuracy rate. Finally, the wavelet transform is taken of the

    individual signals to maintain enough features while compressing and reducing the

    sample size to classify each signal with a high accuracy rate. Through my numerical

    experiments I conclude that SVM provides fast and accurate arrhythmia classification

    allowing automatic analysis without human oversight.

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    5/36

    1

    INTRODUCTION

    A healthy human heart pumps about 2,000 gallons of blood through all of our veins and

    arteries every single day. It carries oxygen and nutrients to every cell in our body. With

    an average of 100,000 heart beats per day, (2) it is one of the hardest working organs in a

    human body. The heart beats because of the small electrical current generated by the

    cardiac conduction system. An electrocardiogram, ECG is a noninvasive procedure that

    records the electrical activity of the heart over a period of time. The morphology of a

    heartbeat can provide many detail of a patient. We can determine the cause of symptoms

    of heart disease, such as dizziness, fainting or shortness of breath. We can check the

    health of the heart when other conditions are present, such as diabetes, high cholesterol,

    high blood pressure, or cigarette smoking. And we can check the maintenance of

    mechanical devices, such as a pacemaker working in combination with other organs

    throughout the rest of the body. An ideal heart beat has five deflections.

    Figure 1. QRS complex wave with P and T wave.

    The ECG will record the electrical activity that comes from depolarization and

    repolarization of the heart muscle cells when the atria and ventricles contract. The P wave

    results from atrial depolarization which spreads from the SA node throughout the atria

    and pumps blood through the open valves from the atria into both ventricles. The time

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    6/36

    2

    between the P and Q wave is when the signal arrives at the atrioventricular (AV) node

    and allows the hearts left and right ventricles to fill with blood. The Q wave results from

    when the signal arrives at the bundle of His and is divided into left and right bundle

    branches. The signal leaves the bundle branches through the Purkinje fibers and spreads

    across the hearts ventricles causing them to contract which pushes the blood though the

    pulmonary value into the lungs and through the aortic valve to the rest of the body . The

    left ventricles contracts first immediately followed by the right, this is marked by the R

    wave and S wave respectively. After the signal passes, the ventricles relax and await the

    next signal. The T wave marks the point when the ventricles are relaxing.

    Any changes from a normal heart beat may indicate a problem with the patient. A patient

    with atrial premature complexes, APC will have a reduced p wave. In this paper, the

    following arrhythmia groups have been considered: Normal Sinus Rhythm (NOR), Atrial

    Premature Contractions (APC), Ventricular premature complexes (VPC), Left Bundle

    Branch Block (LBBB) and Right Bundle Branch Block (RBBB). An atrial premature

    contraction (APC) is a heart rhythm disorder that involves a premature firing of the

    atrium (3), its feels like an extra heartbeat. On an ECG, APC will have a reduce P wave.

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    7/36

    3

    Figure 2. ECG of a heart beat with APC

    A ventricular premature complex (VPC) is perceived as a skipped beat, with a sensation

    feeling of palpitations in the chest. On an ECG, VPC is identifiable when the P wave is

    closer to the QRS complex. You will also see a longer duration from the T wave to the

    next QRS complex (4).

    Figure 3. ECG of a heart beat with VPC

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    8/36

    4

    In Left bundle branch block, (LBBB) the left ventricle contracts later than the right

    ventricle. On an ECG, the T wave is deflected opposite compared to a normal sinus

    rhythm.

    Figure 4. ECG of a heart beat with LBBB

    Right bundle branch block, (RBBB) is the result when the right ventricle is not activated

    by the current charge traveling through the right bundle branch. During this time, the left

    ventricle is operating normal. On an ECG graph we can see a slurred S wave as well as a

    widen QRS complex (5).

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    9/36

    5

    Figure 5. ECG graph showing a heartbeat with RBBB

    In a normal heart beat we can see the P wave, QRS complex and the S wave.

    Figure 6. ECG of a normal heart beat.

    Comparing the 4 arrhythmias to the normal heart beat, we can clearly distinguish the

    features that give the ECG its unique characteristics for each arrhythmia. A trained

    cardiologist can diagnose various arrhythmias just by looking at the ECG of a patient.

    This method is not very practical since the cardiologist cannot monitor the patient at all

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    10/36

    6

    times. A holter monitor is used to record the hearts activities for at least 24 hours and

    later analyzed. In 24 hours, the holter monitor will record about 100,000 heartbeats

    making it a tedious task to do without computer help. The computational analysis of the

    ECG signals gives an output with a tally of the unique recorded heart beats. The field of

    arrhythmia classification is continuously evolving. There are several techniques for

    providing classification. Shape based matching algorithms using Fourier transform are

    used for classification from ECG printouts (6). In pattern recognition, k-nearest neighbor

    and neural networks provide similar approaches to that of SVM. Morphological pattern

    recognition is the leading method for accurate classification among ECG signals. I

    propose using the integrated software for support vector classification, libsvm to do

    multiclass classification with a multi-order polynomial kernel to provide a high accuracy

    rate of 99.6% in arrhythmia classification. I take advantage of SVMs simplicity.

    Through minimal code and lack of computational expenses, I incorporated arrhythmia

    analysis that could be used in implantable devices to save thousands of lives each year. In

    this paper I explain the mathematical background and methods of support vector machine

    and feature extractions to bring an understanding of classification. I explain the method

    of gaining the ECG signals and how training and testing of the datasets was completed

    using matlab. In chapter 5, procedure i go into detail of how each heartbeat was

    separated, grouped and label into a single matrix file. A 10-fold cross validation was

    performed to achieve the best kernel function for a high accuracy rate within

    classification. A feature extraction process was performed with wavelet transform in

    matlab to reduce the signal data while maintaining enough features to perform

    classification without a drop in accuracy. In the proceeding chapter, I clarify the results of

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    11/36

    7

    classification and conclude with an overview of the projects expectation and how the

    results were met.

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    12/36

    8

    SUPPORT VECTOR MACHINE

    Binary classification starts with some input data used for training:

    , , , , 1,1 2.1

    with the goal of finding the function,, , that can best approximate thefunction . The training data is considered linearly separable if the data can beseparated with a linear hyperplane,

    , 2.2

    There could be many different hyperplanes that could linearly separate the training data

    but there is one hyperplane that has the biggest gap between the two data called the

    maximum margin hyperplane. The maximum margin hyperplane must satisfy the

    following condition:

    1 2.3

    while having the minimal norm:

    2.4

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    13/36

    9

    Figure7.Maxmarginhyperplane

    In figure 7 we see the separation of the two data points, H1 and H2 by the hyperplane, H.The distance from H to H1 is:

    | |||||

    1||||

    2.5

    And from H1 to H2 is:

    2||||2.6

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    14/36

    10

    If the training data cannot be linearly separated, we can use a soft margin hyperplane,

    which allow misclassification through the slack variable,while still maximizing themargin. We need to minimize:

    2.7

    under constraints:

    1 0 2.8

    The optimal separating hyperplane for the separable and non-separable case is through

    finding the saddle point of the lagrangian:

    , , , 1 2.9

    0, 0

    Since, and is the maximum point of:

    , , 2.10

    0, 0

    The separating hyperplane is:

    2.11

    In SVM, we sometimes need to map input vectors non-linearly into a high dimensional

    feature space. Having multiple inputs increases complexity of classification thus mapping

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    15/36

    11

    into high feature space allows for a better decision surface. Using polynomial kernel

    allows for better classification:

    , 1 ,

    1, 2.12

    where d is the degree of the polynomial.

    We can perform the kernel trick of replacing every dot product by the nonlinear

    polynomial kernel function to create our nonlinear classifier. A kernel trick allows us to

    map observations from a general set D into an inner product space S which only requires

    dot products between the vectors in S. The kernel trick permits high-dimensional dot

    products to be computed within the original space.

    In order to do a multi-class classifier, we perform multiple binary classifications to

    reduce the single multiclass problem (7). There are two general approaches in multiclass

    classification, one-versus-all and one-versus-one classification. In a one-versus-all

    strategy, a single classifier is trained per class that separates it from all the other classes.

    The prediction with the highest confidence is chosen after predicting each binary

    classifier. In a one-versus-one strategy, classification is done where every classifier

    assigns the instance to one of the two classes, the assigned class gets one vote and

    increases over time, in the end the class with the most votes determines that moments

    classification.

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    16/36

    12

    FEATURE EXTRATION

    In discrete wavelet transform, the signal, is passed through a low pass filter withimpulse response

    resulting in the convolution (8):

    3.1

    The signal is also decomposed simultaneously using a high pass filter. The outputs are

    the approximation and detail coefficients from the low and high pass filter respectively

    (9):

    2 Low-pass filter output 3.2

    2 High-pass filter output 3.3

    The result is one half the time resolution due to the decomposition.

    Figure 8. Filter analysis

    The decomposition is repeated and cascaded to create a filter bank.

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    17/36

    13

    Figure 9. 3 level filter bank of decomposition

    Creating the decomposition in reverse is called reconstruction. The detail and

    approximation coefficients are upsampled by two at every level and passed through a

    low-pass and high-pass filter.

    Figure 10. 3 level filter bank of reconstruction

    The process of decomposition and reconstruction allows for de-noising and compression

    of the signal while maintaining the unique features without affecting the accuracy rate of

    classification (10).

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    18/36

    14

    NUMERICAL EXPERIMENTS

    The ECG files were acquired from PhysioNet.org. PhysioNet offers free web access to

    large collections of recorded physiologic signals (PhysioBank) and related open-source

    software (PhysioToolkit) (11). From the website, twenty records were downloaded from

    twenty different patients. The records that were captured were one hour in length from

    patients as young as 24 years old to 87 years old. The files were in .mat format and came

    with an annotation file for each ECG. The annotation files marked each heart beat and

    assigned a label on the R peak of the QRS complex wave and based on the category of

    the arrhythmia, it was given a letter. The letter identified each arrhythmia within the ECG

    signal. Matlabwas the software of choice for its numerical computing environment (12).

    The files were uploaded into matlab with a software extension package called libsvm.

    Libsvm is integrated software for support vector classification that supports multi-class

    classification (13). Feature extraction was done through matlab via the wavelet

    decomposition.

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    19/36

    15

    The annotation files were manually imported one by one into matlab and the datasets

    entered into matrixes. Based on the arrhythmia needed, which was searched by a single

    letter indicating the arrhythmias, (A = APC, V=PVC, L=LBBB, R=RBBB, N=Normal)

    all the categories were grouped and saved as a separate .mat file. The procedure was

    repeated for each patient file. Next the hour long ECG file was loaded into matlab and

    with a sampling rate on 360 and the annotation time stamp, each labeled heart beat was

    extracted. The result was a 301 sample heart beat that included the P wave, QRS complex

    and T wave from start to finish. The second matlab script file combined all the groups

    into one giant training file containing 5400 heart beats in a 5400 by 301 matrix. The

    appropriate training labels were assigned and SVM classification was produce with the

    libsvm package. The test file was created in similar fashion as the training dataset but

    with only 2036 samples. Libsvm offers multiple types of kernel functions. In this paper

    we only look at Linear, polynomial 2nd

    order, 3rd

    order and 4th order. The cost of the

    kernel varies from 10-3

    to 10+3

    and the best value was calculated using a 10-fold cross

    validation. The gamma in the kernel function was also manipulated with the 10-fold cross

    validation. After the first classification on the original signal files, feature extraction was

    performed to reduce the number of samples in the ECG. Having fewer samples gives us

    the ability to run faster analysis, while maintaining a small memory size. The samples in

    the ECG signal were reduced from 301 to 154, 80, 43, 25, 16, 11, and 9 in a seven level

    reconstruction.

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    20/36

    16

    Figure 11. ECG graph of original 301 sample vs. level 5 feature extraction with 25

    samples

    Using the small sample size, SVM classification was redone for each step and my

    algorithm maintained a high accuracy.

    To evaluate the performance of the classifier, we first setup the kernel function for linear

    classification by setting the kernel flag options with -t 0 and the cost parameter at 10-3

    .

    After training and testing, our accuracy was 99.26%. Next we try changing the cost to C

    = 10-2

    and C = 10-1

    up until C = 103and the accuracy remained the same at 99.26%

    To properly visualize the classification performance and compare the accuracy, a

    confusion matrix was computed. The results conclude that not only is the high accuracy

    valid, its performance to properly classify the test data is efficient with regards to

    providing true positive classification.

    The next step in classification was to change the kernel function to polynomial in second

    order. This is done by setting the option flag with -t 1 d 2. The d is for setting the

    degree or order of the classifier. We did the testing by changing the cost uniformly from

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    21/36

    17

    C = 10-3

    to C = 103. After training and testing the dataset, our results were similar to

    linear classification, 99.26%. Changing the order of classification from 2nd

    order to 3rd

    and 4th

    order had no effect on accuracy, which remained at 99.26%. Computing a

    confusion matrix yield the same results for the linear kernel, therefore table 2 and 3 could

    be associated with a polynomial kernel.

    Table 1. Accuracy on testing results

    C 10-3

    10-2

    10-1

    100

    101

    102

    103

    Linear 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    2ndOrder 99.26%

    99.26% 99.26% 99.26% 99.26% 99.26%

    99.26%

    3rd

    Order 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    4th

    Order 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    Table 2. Confusion Matrix

    Actual/Predicted APC PVC LBBB RBBB Normal

    APC 74 1 0 0 1

    PVC 0 106 0 0 1

    LBBB 0 10 481 0 0

    RBBB 0 0 0 625 0

    Normal 1 1 0 0 735

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    22/36

    18

    Table 3. Table of confusion

    True Positive False Negative False Positive True Negative

    APC 74 2 1 1959

    PVC 106 1 12 1917

    LBBB 481 10 0 1545

    RBBB 625 0 0 1411

    Normal 735 2 2 1297

    Our next focus was to evaluate how well feature extraction reduced a signal file while

    maintaining the important characteristics. In a 7 level feature extraction, 301 samples are

    reduce and trained and tested for each level and the accuracy recorded. First Linear

    classification was performed. For the first 3 levels, the features were reduced from 301

    samples to 157, 80 and 43, and the accuracy remained unchanged at 99.26%. The results

    are listed in Table 2. Varying the cost also had no change. On the fourth level, where the

    features were reduced to 25 samples, the accuracy went down to 99.17%. Adjusting the

    Cost from C = 10-3

    to 103also had no effect on accuracy. But changing the cost to C = 10

    -

    4gave us an accuracy of 99.12%, and C = 10

    -5increase it to 99.26%, the same accuracy

    rate as our first evaluation with 301 samples. The accuracy rate of level 6 with only 11

    features was 97.84% and 95.04% on level 7 with only 9 samples! Changing the cost does

    have some slight effect on accuracy. The rest of the feature extraction results can be

    viewed on tables 3 through 5.

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    23/36

    19

    Table 4. Feature extraction on linear kernel

    Linear kernel

    10-3

    10-2

    10-1

    100 10

    1 10

    2 10

    3

    Level 1 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    Level 2 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    Level 3 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    Level 4 99.17% 99.17% 99.17% 99.17% 99.17% 99.17% 99.17%

    Level 5 98.62% 98.67% 98.58% 98.72% 98.67% 98.67% 98.53%

    Level 6 97.94% 98.08% 97.69% 97.84% 97.59% 97.79% 97.69%

    Level 7 96.02% 95.78% 95.87% 95.04% 95.24% 95.73% 95.14%

    Table 5. Feature extraction on 2nd order kernel

    2

    nd

    order polynomial kernel

    10-3

    10-2

    10-1

    100 10

    1 10

    2 10

    3

    Level 1 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    Level 2 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    Level 3 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    Level 4 99.07% 99.07% 99.07% 99.07% 99.07% 99.07% 99.07%

    Level 5 98.82% 98.82% 98.82% 98.82% 98.82% 98.82% 98.82%

    Level 6 98.43% 98.33% 98.33% 98.38% 97.54% 98.28% 97.54%

    Level 7 97.3% 97.05% 93.27% 96.76% 95.92% 95.92% 96.41%

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    24/36

    20

    Table 6. Feature extraction on 3rd order kernel

    3rd

    order polynomial kernel

    10-3

    10-2

    10-1

    100 10

    1 10

    2 10

    3

    Level 1 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    Level 2 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    Level 3 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    Level 4 99.07% 99.07% 99.07% 99.07% 99.07% 99.07% 99.07%

    Level 5 98.77% 98.77% 98.77% 98.77% 98.77% 98.77% 98.77%

    Level 6 98.08% 98.08% 98.08% 98.08% 98.08% 98.08% 98.08%

    Level 7 97.05% 96.66% 97.45% 97% 96.56% 97.25% 96.76%

    Table 7. Feature extraction on 4th order kernel

    4th

    order polynomial kernel

    10-3

    10-2

    10-1

    100 10

    1 10

    2 10

    3

    Level 1 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    Level 2 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    Level 3 99.31% 99.31% 99.31% 99.31% 99.31% 99.31% 99.31%

    Level 4 99.07% 99.07% 99.07% 99.07% 99.07% 99.07% 99.07%

    Level 5 98.92% 98.92% 98.92% 98.92% 98.92% 98.92% 98.92%

    Level 6 97.99% 97.99% 97.99% 97.99% 97.99% 97.99% 97.99%

    Level 7 96.91% 96.66% 96.86% 96.71% 96.94% 96.66% 96.51%

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    25/36

    21

    The results from all 4 tables show a small variance in accuracy when changing the Cost

    or the kernel type. The best result was from the 4th

    order polynomial after level 3 feature

    extraction for a rate of 99.31% and the worst was the 2nd

    order polynomial at level 7 for a

    rate of 93.27%

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    26/36

    22

    DISCUSSION

    In my paper I describe the effects of support vector machine classification on ECG signal

    for arrhythmia classification and seven level feature extractions. Classification was done

    with matlab and libsvm software package to import twenty hour long ECG signal files

    and analyze and collect each heart beat into its appropriate category. Once categorize and

    labeled, the heart beats were trained and classification testing was done on a second set of

    arrhythmias and the accuracy rate recorded. Several kernel functions were used,

    including linear and high order polynomials to provide better classification. The results

    show the high accuracy effectiveness of SVM on ECG signals. Through proper feature

    extraction, we were able to reduce the sample set on each heart beat from 301 samples to

    9 samples while maintaining a high accuracy rate. A reduction of samples will reduce the

    memory size and processing time of classification without the cost of accuracy.

    ECG signals are very important because of their noninvasive approach to diagnose

    various heart conditions. We can help treat heart disease and prevent problems from

    forming through early detection. My paper brought forth the ease of arrhythmia detection

    through SVM classification. The feature reduction ability will allow low memory usage

    to incorporate such SVM algorithms into mobile devices to be readily available to more

    patients who can self-monitor their own heartbeat.

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    27/36

    23

    BIBLIOGRAPHY

    1.Deaths:PreliminaryDatafor2011.Hoyert,yDonnaL.6,2012,Vol.61.

    2.AmericanHeartAssociation.[Online][Cited:April1,2013.]www.americanheart.org/.

    3.ECGPedia.org.[Online][Cited:March15,2012.]

    http://en.ecgpedia.org/wiki/Atrial_Premature_Complexes.

    4.JatinDave,MD,MPH.VentricularPrematureComplexes.http://emedicine.medscape.com/.

    [Online]Nov.12,2012.

    5.FrankG.Yanowitz,M.D.RBBB.ECGlearningcenter.[Online]2006.http://ecg.utah.edu/.

    6.T.,SyedaMahmood.ShapebasedMatching.EngineeringinMedicineandBiologySociety.

    2007.

    7.Duan,KaiBoandandKeerthi,S.Sathiya.WhichIstheBestMulticlassSVMMethod?An

    EmpiricalStudy.ProceedingsoftheSixthInternationalWorkshoponMultipleClassifierSystems.

    2005.

    8.Akansu,AliN.andHaddad,RichardA.Multiresolutionsignaldecomposition:transforms,

    subbands,andwavelets.Boston,MA:AcademicPress,1992.

    9.Mallat,S.AWaveletTourofSignalProcessing,2nded.1999.

    10.HoTattWeiandJeoti,V.AwaveletfootprintsbasedcompressionschemeforECGsignals.

    2004.

    11.PhysioNet.[Online][Cited:September5,2012.]www.physionet.org.

    12.Matlab.[Online][Cited:October2,2011.]http://www.mathworks.com/products/matlab/.

    13.ChihChungChangandChihJenLin.Libsvm.[Online][Cited:September2012,2012.]

    http://www.csie.ntu.edu.tw/~cjlin/libsvm/.

    14.LIBSVM:ALibraryforSupportVectorMachines.Lin,ChihChungChangandChihJen.Taipei,

    Taiwan:s.n.,2001.

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    28/36

    24

    APPENDIX

    Matlab code

    %%clcclose

    clear

    load('sapc1.mat');

    a1 = poi2;load('sapc2.mat');

    a2 = poi2;

    load('spvc1.mat');p1 = poi2;

    load('spvc2.mat');

    p2 = poi2;load('spvc3.mat');

    p3 = poi2;

    load('slbbb1.mat');

    l = poi2;load('srbbb1.mat');

    r = poi2;

    load('snor1.mat');n1 = poi2;

    load('snor2.mat');

    n2 = poi2;

    load('snor3.mat');n3 = poi2;

    load('snor4.mat');n4 = poi2;

    %%

    train = [a2(1:300,:); p2(1:400,:); l(1:2000,:); r(1:1200,:); n2(1:1500,:)];

    labels = [ones(300,1); 2*ones(400,1); 3*ones(2000,1); 4*ones(1200,1); 5*ones(1500,1)];

    model = svmtrain(labels, train, '-t 1 -d 4 -c .001 ');

    test = [a2(301:376,:); p2(401:507,:); l(2001:2491,:); r(1201:1825,:); n2(1501:2237,:)];tlabels = [ones(76,1); 2*ones(107,1); 3*ones(491,1); 4*ones(625,1); 5*ones(737,1)];

    %test = [a1(1:76,:); p2(401:428,:); p1; p3; l(2001:2491,:); r(1201:1825,:); n1(1:737,:)];

    [predicted_label, accuracy, dec] = svmpredict(tlabels, test , model);

    %% Coefficients of approximations at level 1

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    29/36

    25

    ca1 = mdwtdec('r',train,7,'sym4');

    ca1t = mdwtdec('r',test,7,'sym4');train2 = mdwtrec(ca1,'ca',1);

    test2 = mdwtrec(ca1t,'ca',1);

    model2 = svmtrain(labels, train2, '-t 1 -d 4 -c .001');[predicted_label, accuracy, dec] = svmpredict(tlabels, test2 , model2);

    %% Coefficients of approximations at level 2train3 = mdwtrec(ca1,'ca',2);

    test3 = mdwtrec(ca1t,'ca',2);

    model3 = svmtrain(labels, train3, '-t 1 -d 4 -c 1000 ');[predicted_label, accuracy, dec] = svmpredict(tlabels, test3 , model3);

    %% Coefficients of approximations at level 3

    train4 = mdwtrec(ca1,'ca',3);

    test4 = mdwtrec(ca1t,'ca',3);model4 = svmtrain(labels, train4, '-t 1 -d 4 -c .001 ');

    [predicted_label, accuracy, dec] = svmpredict(tlabels, test4 , model4);

    %% Coefficients of approximations at level 4

    train5 = mdwtrec(ca1,'ca',4);test5 = mdwtrec(ca1t,'ca',4);

    model5 = svmtrain(labels, train5, '-t 1 -d 4 -c 1000 ');

    [predicted_label, accuracy, dec] = svmpredict(tlabels, test5 , model5);

    %% Coefficients of approximations at level 5train6 = mdwtrec(ca1,'ca',5);

    test6 = mdwtrec(ca1t,'ca',5);

    model6 = svmtrain(labels, train6, '-t 1 -d 4 -c 1 ');

    [predicted_label, accuracy, dec] = svmpredict(tlabels, test6 , model6);

    %% Coefficients of approximations at level 6

    train7 = mdwtrec(ca1,'ca',6);test7 = mdwtrec(ca1t,'ca',6);

    model7 = svmtrain(labels, train7, '-t 1 -d 4 -c 1000 ');

    [predicted_label, accuracy, dec] = svmpredict(tlabels, test7 , model7);

    %% Coefficients of approximations at level 7

    train8 = mdwtrec(ca1,'ca',7);test8 = mdwtrec(ca1t,'ca',7);

    model8 = svmtrain(labels, train8, '-t 1 -d 4 -c .01 ');

    [predicted_label, accuracy, dec] = svmpredict(tlabels, test8 , model8);

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    30/36

    26

    Figure 12. QRS complex wave with P and T wave.

    Figure 13. ECG of a heart beat with APC

    Figure 14. ECG of a heart beat with VPC

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    31/36

    27

    Figure 15. ECG of a heart beat with LBBB

    Figure 16. ECG graph showing a heartbeat with RBBB

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    32/36

    28

    Figure 17. ECG of a normal heart beat.

    Figure 18. Filter analysis

    Figure 19. 3 level filter bank of decomposition

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    33/36

    29

    Figure 20. 3 level filter bank of reconstruction

    Figure 21. ECG graph of original 301 sample vs. level 5 feature extraction with 25

    samples

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    34/36

    30

    Table 8. Accuracy on testing results

    C 10-3

    10-2

    10-1

    100

    101

    102

    103

    Linear 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    2ndOrder 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    3rd

    Order 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    4th

    Order 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    Table 9. Confusion Matrix

    Actual/Predicted APC PVC LBBB RBBB Normal

    APC 74 1 0 0 1

    PVC 0 106 0 0 1

    LBBB 0 10 481 0 0

    RBBB 0 0 0 625 0

    Normal 1 1 0 0 735

    Table 10. Table of confusion

    True Positive False Negative False Positive True Negative

    APC 74 2 1 1959

    PVC 106 1 12 1917

    LBBB 481 10 0 1545

    RBBB 625 0 0 1411

    Normal 735 2 2 1297

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    35/36

    31

    Table 4. Feature extraction on linear kernel

    Linear kernel

    10-3

    10-2

    10-1

    100 10

    1 10

    2 10

    3

    Level 1 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    Level 2 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    Level 3 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    Level 4 99.17% 99.17% 99.17% 99.17% 99.17% 99.17% 99.17%

    Level 5 98.62% 98.67% 98.58% 98.72% 98.67% 98.67% 98.53%

    Level 6 97.94% 98.08% 97.69% 97.84% 97.59% 97.79% 97.69%

    Level 7 96.02% 95.78% 95.87% 95.04% 95.24% 95.73% 95.14%

    Table 5. Feature extraction on 2nd order kernel

    2nd

    order polynomial kernel

    10-3

    10-2

    10-1

    100 10

    1 10

    2 10

    3

    Level 1 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    Level 2 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    Level 3 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    Level 4 99.07% 99.07% 99.07% 99.07% 99.07% 99.07% 99.07%

    Level 5 98.82% 98.82% 98.82% 98.82% 98.82% 98.82% 98.82%

    Level 6 98.43% 98.33% 98.33% 98.38% 97.54% 98.28% 97.54%

    Level 7 97.3% 97.05% 93.27% 96.76% 95.92% 95.92% 96.41%

  • 8/12/2019 Arrhythmia Classification Using Support Vector Machine -Alexis Pena

    36/36

    Table 6. Feature extraction on 3rd order kernel

    3rd

    order polynomial kernel

    10-3

    10-2

    10-1

    100 10

    1 10

    2 10

    3

    Level 1 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    Level 2 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    Level 3 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    Level 4 99.07% 99.07% 99.07% 99.07% 99.07% 99.07% 99.07%

    Level 5 98.77% 98.77% 98.77% 98.77% 98.77% 98.77% 98.77%

    Level 6 98.08% 98.08% 98.08% 98.08% 98.08% 98.08% 98.08%

    Level 7 97.05% 96.66% 97.45% 97% 96.56% 97.25% 96.76%

    Table 7. Feature extraction on 4th order kernel

    4th

    order polynomial kernel

    10-3

    10-2

    10-1

    100 10

    1 10

    2 10

    3

    Level 1 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    Level 2 99.26% 99.26% 99.26% 99.26% 99.26% 99.26% 99.26%

    Level 3 99.31% 99.31% 99.31% 99.31% 99.31% 99.31% 99.31%

    Level 4 99.07% 99.07% 99.07% 99.07% 99.07% 99.07% 99.07%

    Level 5 98.92% 98.92% 98.92% 98.92% 98.92% 98.92% 98.92%

    Level 6 97.99% 97.99% 97.99% 97.99% 97.99% 97.99% 97.99%

    Level 7 96.91% 96.66% 96.86% 96.71% 96.94% 96.66% 96.51%