6
International Journal of Science, Engineering and Technology Research (IJSETR), Volume 3, Issue 7, July 2014 ISSN: 2278 7798 All Rights Reserved © 2014 IJSETR 1946 MATLAB Based ECG Signal Classification Jaylaxmi C Mannurmath #1, Prof. Raveendra M #2 #1Department of Electronics and Communication Engineering, #2Department of Electronics and Communication Engineering, KLS’s VDRIT, Haliyal-581329, India AbstractAn electrocardiogram (ECG) is a bioelectrical signal which records the heart's electrical activity versus time. It is an important diagnostic tool for assessing heart functions. The early detection of arrhythmia is very important for the cardiac patients. ECG arrhythmia can be defined as any of a group of conditions in which the electrical activity of the heart is irregular and can cause heartbeat to be slow or fast. It can take place in a healthy heart and be of minimal consequence, but they may also indicate a serious problem that leads to stroke or sudden cardiac death. As ECG signal being non stationary signal, the arrhythmia may occur at random in the time-scale, which means, the arrhythmia symptoms may not show up all the time but would manifest at certain irregular intervals during the day. Thus, automatic classification of arrhythmia is critical in clinical cardiology, especially for the treatment of patients in the intensive care unit. This project implements a simulation tool on MATLAB platform to detect abnormalities in the ECG signal. The ECG signal is downloaded from MIT-BIH Arrhythmia database, since this signal contains some noise and artifacts hence pre-processing of ECG signal are performed first. The pre- processing of ECG signal is performed with help of Wavelet toolbox wherein baseline wandering, denoising and removal of high frequency and low frequency is performed to improve SNR ratio of ECG signal. The Wavelet toolbox is also used for feature extraction of ECG signal. Classification of arrhythmia is based on basic classification rules. The complete project is implemented on MATLAB platform. The performance of the algorithm is evaluated on MITBIH Database. The different types of arrhythmia classes including normal beat, Tachycardia, Bradycardia and Myocardial Infract (MI) are classified. Keywords- Db6 , feature extraction, arrhythmia. I. INTRODUCTION An electrocardiogram (ECG) is a bioelectrical signal which records the heart's electrical activity versus time. It is an important diagnostic tool for assessing heart functions. The early detection of arrhythmia is very important for the cardiac patients. ECG is a test that measures the electrical activity of the heart. The signals that make the heart's muscle fibers contract come from the senatorial node, which is the natural pacemaker of the heart. In an ECG test, the electrical impulses made while the heart is beating are recorded and usually shown on paper, and records any problems with the heart's rhythm. ECG arrhythmia can be defined as any of a group of conditions in which the electrical activity of the heart is irregular and can cause heartbeat to be slow or fast. It can take place in a healthy heart and be of minimal consequence, but they may also indicate a serious problem that leads to stroke or sudden cardiac death. As ECG signal being non stationary signal, the arrhythmia may occur at random in the time-scale, which means, the arrhythmia symptoms may not show up all the time but would manifest at certain irregular intervals during the day. Therefore, for effective diagnostics, the variability of ECG signal may have to be observed over several hours. For this reason, together with the fact that the volume of the ECG data is enormous, the study is tedious and time consuming. Thus, automatic classification of arrhythmia is critical in clinical cardiology, especially for the treatment of patients in the intensive care unit. The figure 1 shows a standard ECG signal. Fig 1 Standard ECG signal The electrocardiogram is an important tool for providing information about functional status of the heart. Analysis of ECG is of great importance in the detection of cardiac diseases which are the main cause of mortality in many countries. The Q, R and S wave of ECG signal occur in rapid succession, do not all appear in all leads and reflect a single event so are thus normally considered as a whole complex. A Q wave is any downward deflection after the P-wave.

MATLAB Based ECG Signal Classification

  • Upload
    vonhi

  • View
    269

  • Download
    11

Embed Size (px)

Citation preview

Page 1: MATLAB Based ECG Signal Classification

International Journal of Science, Engineering and Technology Research (IJSETR), Volume 3, Issue 7, July 2014

ISSN: 2278 – 7798 All Rights Reserved © 2014 IJSETR 1946

MATLAB Based ECG Signal Classification

Jaylaxmi C Mannurmath #1, Prof. Raveendra M #2

#1Department of Electronics and Communication Engineering,

#2Department of Electronics and Communication Engineering,

KLS’s VDRIT, Haliyal-581329, India

Abstract— An electrocardiogram (ECG) is a bioelectrical signal

which records the heart's electrical activity versus time. It is an

important diagnostic tool for assessing heart functions. The early

detection of arrhythmia is very important for the cardiac

patients. ECG arrhythmia can be defined as any of a group of

conditions in which the electrical activity of the heart is irregular

and can cause heartbeat to be slow or fast. It can take place in a

healthy heart and be of minimal consequence, but they may also

indicate a serious problem that leads to stroke or sudden cardiac

death. As ECG signal being non stationary signal, the

arrhythmia may occur at random in the time-scale, which means,

the arrhythmia symptoms may not show up all the time but

would manifest at certain irregular intervals during the day.

Thus, automatic classification of arrhythmia is critical in clinical

cardiology, especially for the treatment of patients in the

intensive care unit. This project implements a simulation tool on

MATLAB platform to detect abnormalities in the ECG signal.

The ECG signal is downloaded from MIT-BIH Arrhythmia

database, since this signal contains some noise and artifacts

hence pre-processing of ECG signal are performed first. The pre-

processing of ECG signal is performed with help of Wavelet

toolbox wherein baseline wandering, denoising and removal of

high frequency and low frequency is performed to improve SNR

ratio of ECG signal. The Wavelet toolbox is also used for feature

extraction of ECG signal. Classification of arrhythmia is based

on basic classification rules. The complete project is implemented

on MATLAB platform. The performance of the algorithm is

evaluated on MIT–BIH Database. The different types of

arrhythmia classes including normal beat, Tachycardia,

Bradycardia and Myocardial Infract (MI) are classified.

Keywords- Db6 , feature extraction, arrhythmia.

I. INTRODUCTION

An electrocardiogram (ECG) is a bioelectrical signal which

records the heart's electrical activity versus time. It is an

important diagnostic tool for assessing heart functions. The

early detection of arrhythmia is very important for the cardiac patients. ECG is a test that measures the electrical activity of

the heart. The signals that make the heart's muscle fibers

contract come from the senatorial node, which is the natural

pacemaker of the heart. In an ECG test, the electrical impulses

made while the heart is beating are recorded and usually

shown on paper, and records any problems with the heart's

rhythm.

ECG arrhythmia can be defined as any of a group of

conditions in which the electrical activity of the heart is

irregular and can cause heartbeat to be slow or fast. It can take

place in a healthy heart and be of minimal consequence, but

they may also indicate a serious problem that leads to stroke

or sudden cardiac death. As ECG signal being non stationary

signal, the arrhythmia may occur at random in the time-scale, which means, the arrhythmia symptoms may not show up all

the time but would manifest at certain irregular intervals

during the day. Therefore, for effective diagnostics, the

variability of ECG signal may have to be observed over

several hours. For this reason, together with the fact that the

volume of the ECG data is enormous, the study is tedious and

time consuming. Thus, automatic classification of arrhythmia

is critical in clinical cardiology, especially for the treatment of

patients in the intensive care unit. The figure 1 shows a

standard ECG signal.

Fig 1 Standard ECG signal

The electrocardiogram is an important tool for providing

information about functional status of the heart. Analysis of

ECG is of great importance in the detection of cardiac

diseases which are the main cause of mortality in many

countries. The Q, R and S wave of ECG signal occur in rapid

succession, do not all appear in all leads and reflect a single

event so are thus normally considered as a whole complex. A

Q wave is any downward deflection after the P-wave.

Page 2: MATLAB Based ECG Signal Classification

International Journal of Science, Engineering and Technology Research (IJSETR), Volume 3, Issue 7, July 2014

ISSN: 2278 – 7798 All Rights Reserved © 2014 IJSETR 1947

An R-wave is an upward deflection and the S wave is any

downward deflection after the R-wave. The QRS complex of

the electrocardiographic signal has the normal duration from

0.06s to 0.1s and provides information about the heart rate, the

conduction velocity, the condition of tissues within the heart

and various abnormalities. Its shape, duration and time of occurrence provide valuable information about the current

state of the heart. Because of its specific shape, the QRS

complex serves as an entry point for almost all automated

ECG analysis algorithms and detection of the QRS complex is

the most important task in automatic ECG signal analysis.

II. DISCRETE WAVELET TRANSFORM (DWT)

The wavelet transform is a convolution of the wavelet

function y (t) with the signal x(t). Orthonormal discrete

wavelets are associated with scaling functions∅(𝑡). The scaling function can be convolved with the signal to pro-duce

approximation coefficients S. The discrete wavelet transform

(DWT) can be written as

𝑇𝑚 ,𝑛 = 𝑥 𝑡 +∞

−∞

𝑦𝑚 ,𝑛 (𝑡)𝑑𝑡

By choosing an Orthonormal wavelet basis 𝑦𝑚 ,𝑛 (𝑡) we can

reconstruct the original signal. The approximation coefficient

of the signal at the scale m and location n can be written as

𝑆𝑚 .𝑛 = 𝑥 𝑡 ∅𝑚 ,𝑛 (𝑡)𝑑𝑡+∞

−∞

But the discrete input signal is of finite length N . So the range

of scales that can be investigated is 0 < m < M. Hence a

discrete approximation of the signal can be written as

𝑥0 𝑡 = 𝑥𝑀 𝑡 + 𝑑𝑚 (𝑡)

𝑀

𝑚=1

where the mean signal approximation at scale M is 𝑥𝑀 𝑡 =𝑆𝑀 ,𝑛∅𝑚 ,𝑛 (𝑡) and detail signal approximation corresponding to

scale m, for finite length signal is given by

𝑑𝑚 𝑡 = 𝑇𝑚 ,𝑛𝑦𝑚 .𝑛 (𝑡)

𝑀−𝑚

𝑛=0

The signal approximation at a specific scale is a combination

of the approximation and detail at the next lower scale.

𝑥𝑚 𝑡 = 𝑥𝑚−1 𝑡 − 𝑑𝑚 (𝑡)

Here we are using Daubechis wavelet algorithm as it is more

efficient as compared to some other algorithms like Haar

algorithm.

III. ECG DATABASE

The database collection is the one of the most important part

of signal processing. We have selected MIT-BIH Arrhythmia

Database directory of ECG signals from physionet. The

source of the ECGs of MIT-BIH Arrhythmia was obtained by the Beth Israel Hospital Arrhythmia Laboratory. The database

contains 48 records divided into two parts first one is of 23

records (numbered from 100 to 124 with some numbers

missing), and another one is contains 25 records (numbered

from 200 to 234, again with some numbers missing).

The database contains approximately 109,000 beat labels.

ECG signals MIT-BIH Database are described by- a text

header file (.hea), a binary file (.dat), a binary annotation file

(.atr) and (.mat) a mat lab file. Header file describe the

detailed information such as number of samples, sampling

frequency, format of ECG signal, type of ECG leads and number of ECG leads, patients history and the detailed clinical

information. In binary data signal file, the signal is stored in

212 formats which mean each sample requires number of

leads times 12 bits to be stored. In the binary annotation file

consists of beat annotations and in the mat lab file data is

available in terms of a row matrix suitable to be loaded in

MATLAB software for further signal analysis

IV. PROBLEM STATEMENT

ECG signal is a continuous monitor of the functioning of heart. Continuous monitoring of ECG signal is very useful in

detecting any functional deviation of the heart. Morphological

changes in ECG wave shape are mapped into commonly

prevailing heart ailments. In this project an attempt is made to

detect the morphological change in ECG wave shape and the

signal is classified into various arrhythmia cases.

V. OBJECTIVE

Objective of the project is to classify the ECG signal into

cases of various arrhythmias. Digital Wavelet Transform

approach is used to derive key parameters of the sampled ECG signal. A MATLAB based GUI is also designed to

present the relevant results in graphical form.

VI. METHODOLOGY

The ECG signal is downloaded from MIT-BIH database since

this signal is having some noise and artifacts having which it

is not advisable to proceed for next stage hence pre-processing

of this ECG signal is of great importance where in the base

line wandering, denoising and removal of high and low

frequency components is performed in this stage. Further the processed ECG signal is given as input to the

feature extraction algorithm where in the features related to

time such as the occurrence and duration of P, Q, R, S and T

waves are determined.

Page 3: MATLAB Based ECG Signal Classification

International Journal of Science, Engineering and Technology Research (IJSETR), Volume 3, Issue 7, July 2014

ISSN: 2278 – 7798 All Rights Reserved © 2014 IJSETR 1948

The extracted parameters are compared with the standard

morphological values of ECG signal based on which decision

taking algorithms are developed and abnormality is classified.

VII. WAVELET SELECTION

The large number of known wavelet families and functions

provides a rich space in which to search for a wavelet which

will very efficiently represent a signal of interest in a large

variety of applications. Wavelet families include

Biorthogonal, Coiflet, Harr, Symmlet, Daubechis wavelets,

etc. There is no absolute way to choose a certain wavelet. The

choice of the wavelet function depends on the application. In

this project Biorthogonal wavelet is used for denoising and Db

6 is used for parameter extraction.

VIII. PEAKS DETECTION

For peak detection we are using online implementation of

state machine logic to determine Peaks and location of various

ECG signal parameters such as peaks and locations of P Q R S

T wave further RR interval, ST segment, PR interval and TT

interval etc are calculated using the basic logic to find distance

between occurrence of the required parameter.

IX. RESULTS

The following figure shows plots for original signal,

Decomposed signal, Denoised signal and Base line wandering removed signal.

Fig 2 Original and Denoised signals

The following figure shows the four levels of decomposed

signal.

Fig 3 Decomposed signals

The following figure shows four reconstruction levels namely

D1, D2, D3, and D4.

Fig 4 First four Reconstruction signals

The following figure shows four reconstruction levels namely

D5, D6, D7, and D8.

Fig 5 Next four Reconstructed signals

Page 4: MATLAB Based ECG Signal Classification

International Journal of Science, Engineering and Technology Research (IJSETR), Volume 3, Issue 7, July 2014

ISSN: 2278 – 7798 All Rights Reserved © 2014 IJSETR 1949

The following figure shows two reconstruction levels namely

A1 and A8.

Fig 6 last two Reconstructed signals

The following figure shows the waveforms for e1, e2 and E3.

Fig 7 Logic signals to find peaks

The following figure shows R, S and T peak detection on processed ECG signal using online Technique.

Fig 8 R, S and T Peak Detected using online Technique

The following figure shows P and Q peak detection on

processed ECG signal using offline Technique.

Fig 9 P and Q Peak Detected using offline Technique

The following figure shows message box which indicates the

heart beat of the ECG signal.

Fig 10 Message box indicating heart rate

The following figure shows GUI of the project which gives

complete analysis on ECG signal.

Fig 11 GUI of the project

Page 5: MATLAB Based ECG Signal Classification

International Journal of Science, Engineering and Technology Research (IJSETR), Volume 3, Issue 7, July 2014

ISSN: 2278 – 7798 All Rights Reserved © 2014 IJSETR 1950

The following table gives information regarding the feature

extraction stage.

Table 1 Results of Feature extraction stage

Data

base

numb

er

RR

Inte

rval

sec

TT

Inter

val

sec

ST

Inter

val

sec

PR

Inter

val

sec

QT

Inter

val

sec

PP

Inter

val

sec

QRS

Inter

val

sec

Std

value

0.6

to

1.2

0.6

to

1.2

0.08

to

0.12

0.12

to

0.2

0.42

to

0.65

0.6

to

1.2

0.08

to

0.12

104 0.81 0.81 0.19 0.88 1.25 0.77 1.07

105 0.71 0.71 0.18 3.82 4.06 0.71 3.88

106 0.82 0.81 0.22 0.79 1.05 0.88 0.84

107 0.92 0.92 0.21 4.71 4.46 0.92 4.26

109 0.72 0.72 0.27 4.52 4.96 0.76 4.70

111 0.81 0.81 0.19 3.31 3.66 0.81 3.47

112 0.72 0.72 0.12 0.13 0.22 0.72 0.10

115 0.80 0.78 0.27 0.18 0.37 0.79 0.10

116 0.72 0.71 0.20 0.11 0.26 0.72 0.07

117 1.07 1.06 0.23 1.15 1.38 0.94 1.14

118 0.73 0.73 0.08 0.1 0.16 0.73 0.08

119 0.89 0.89 0.18 1.39 1.65 0.89 1.47

300 0.66 0.66 0.19 0.14 0.25 0.66 0.06

301 1.07 1.04 0.27 0.21 0.33 1.07 0.08

302 1.00 1.00 0.24 0.11 0.29 1.00 0.05

303 0.71 0.71 0.32 0.25 0.37 0.71 0.05

304 1.13 1.13 0.14 0.21 0.33 1.13 0.19

306 0.92 0.91 0.30 2.47 2.87 0.92 2.58

307 1.10 1.10 0.28 0.15 0.33 1.10 0.05

308 0.66 0.66 0.19 0.14 0.25 0.66 0.06

309 0.74 0.73 0.17 0.22 0.26 0.74 0.10

310 0.67 0.67 0.20 0.18 0.24 0.67 0.05

16265 0.05 0.53 0.25 1.20 1.41 0.21 1.16

18184 0.55 0.53 0.25 1.20 1.41 0.21 1.16

The following table gives information regarding the ECG

signal classification stage.

Table 2 Results of ECG signal classification stage

Data

base

numb

er

RR

Inte

rval

sec

TT

Inter

val

sec

ST

Inter

val

sec

PR

Inter

val

sec

QT

Inter

val

sec

PP

Inter

val

sec

QRS

Inter

val

sec

Std

value

0.6

to

1.2

0.6

to

1.2

0.08

to

0.12

0.12

to

0.2

0.42

to

0.65

0.6

to

1.2

0.08

to

0.12

104 0.81 0.81 0.19 0.88 1.25 0.77 1.07

105 0.71 0.71 0.18 3.82 4.06 0.71 3.88

106 0.82 0.81 0.22 0.79 1.05 0.88 0.84

107 0.92 0.92 0.21 4.71 4.46 0.92 4.26

109 0.72 0.72 0.27 4.52 4.96 0.76 4.70

111 0.81 0.81 0.19 3.31 3.66 0.81 3.47

112 0.72 0.72 0.12 0.13 0.22 0.72 0.10

115 0.80 0.78 0.27 0.18 0.37 0.79 0.10

116 0.72 0.71 0.20 0.11 0.26 0.72 0.07

117 1.07 1.06 0.23 1.15 1.38 0.94 1.14

118 0.73 0.73 0.08 0.1 0.16 0.73 0.08

119 0.89 0.89 0.18 1.39 1.65 0.89 1.47

300 0.66 0.66 0.19 0.14 0.25 0.66 0.06

301 1.07 1.04 0.27 0.21 0.33 1.07 0.08

302 1.00 1.00 0.24 0.11 0.29 1.00 0.05

303 0.71 0.71 0.32 0.25 0.37 0.71 0.05

304 1.13 1.13 0.14 0.21 0.33 1.13 0.19

306 0.92 0.91 0.30 2.47 2.87 0.92 2.58

307 1.10 1.10 0.28 0.15 0.33 1.10 0.05

308 0.66 0.66 0.19 0.14 0.25 0.66 0.06

309 0.74 0.73 0.17 0.22 0.26 0.74 0.10

310 0.67 0.67 0.20 0.18 0.24 0.67 0.05

16265 0.05 0.53 0.25 1.20 1.41 0.21 1.16

18184 0.55 0.53 0.25 1.20 1.41 0.21 1.16

Page 6: MATLAB Based ECG Signal Classification

International Journal of Science, Engineering and Technology Research (IJSETR), Volume 3, Issue 7, July 2014

ISSN: 2278 – 7798 All Rights Reserved © 2014 IJSETR 1951

X. CONCLUSION

In this paper, an algorithm based on Wavelet Transform is

presented for the detection of QRS complex of ECG signal.

Wavelet Decomposition of ECG wave up to level 8 using

Daubechis 6 wavelet generates 8 scales of detail coefficients.

Smaller scales correspond to high frequency components and

higher scales correspond to low frequency components of the

signals.

The multi-resolution wavelet transform based system with

different wavelet scales used to find the QRS complex, and

finally the composition of selective confident and thresholding

method shows robust ability of finding QRS compared to

other methods.

Since wavelets are used for pre-processing of ECG signal it is

found that good SNR ratio is obtained using bio-orthogonal

wavelet. An state machine based online detection algorithm is

addressed to detect the peaks of the ECG signal and it is found

that the efficiency of detection is nearly around 98% as the data is compared with MIT-BIH database. Finally the

abnormality that ECG signal is facing is identified using basic

morphological classification technique.

REFERENCES

[1] C. Li, C. Zheng, C. Tai, Detection of ECG characteristic points by

wavelet transforms, IEEE Transactions on Biomedical

Engineering 42(1), (1995) 21–28.

[2] Saurabh Pal, Madhuchhanda Mitra, Detection of ECG

characteristic points using Multiresolution WaveletAnalysis based

Selective Coefficient Method, Elsevier, Measurement 43 (2010),

255–261.

[3] S. Karpagachelvi, Dr. M.Arthanari, Prof. & Head, M. Sivakumar,

QRS Wave Detection Using Multiresolution Analysis, Vol. 10

Issue 5 Ver. 1.0, (2010), 39-42.

[4] Cuiwei Li, Chongxun Zheng, and Changfeng Tai, “Detection of

ECG Characteristic points using Wavelet Transforms”, IEEE

Trans. Biomed.Eng, Vol. 42, No. 1, (1995).

[5] V. Vijaya, K. Kishan Rao, V. Rama, “Arrhythmia Detection

through ECG Feature Extraction using Wavelet Analysis”,

European Journal of Scientific Research, Vol. 66, pp. 441-448,

2011.

[6] M. Kania, M. Fereniec, R. Maniewski, “Wavelet Denoising for

Multi-lead High Resolution ECG Signals”, Measurement Science

Review, Vol. 7, Section 2, No. 4, 2007

[7] “ECG Learning Center”, Dr. Frank G. Yanowitz, M.D., University

of Utah School of Medicine http://medlib.med.utah.edu/