You are on page 1of 6

Signals & Systems EE232, Spring 2015

1
II. IMPLIMENTATION

ECG Signal Analysis for Myocardial Infarction


Detection (May 2015)
Asfandyar Hassan Shah (7642), Mahnoor Haneef (5064),
Ryshum Ali (7640) and Uzair Akbar (4584)
NUST School of Electrical Engineering & Computer Science (SEECS), Pakistan
AbstractMyocardial Infarction is one of the fatal heart
diseases. It is essential that a patient is monitored for the early
detection of MI. Owing to the newer technology such as wearable
sensors which are capable of transmitting wirelessly, this can be
done easily. However, there is a need for real-time applications
that are able to accurately detect MI non-invasively. This project
studies a prospective method by which we can detect MI. Our
approach analyses the ECG (electrocardiogram) of a patient in
real-time and extracts the ST elevation from each cycle. The ST
elevation plays an important part in MI detection. We then use
the sequential change point detection algorithm; CUmulative
SUM (CUSUM), to detect any deviation in the ST elevation
spectrum and to raise an alarm if we find any.

There are three aspects of our project:


A. ECG Signal Pre-processing (Ryshum Ali,
Mahnoor Haneef)

Index TermsMycardial Infarction, ECG, ST elevation,


CUSUM

I.

INTRODUCTION

he Electrocardiogram (ECG) is a waveform that


represents the propagation of electric potentials
through the heart muscle with respect to time. The
propagation of these potentials results in the quasi-periodic
contraction of the heart muscle. Each part of the cardiogram
refers to a depolarization or a re-polarization of some region in
the heart. The cardiogram consists of five major waves, also
known as deflections in the cardiology literature, the P, Q, R,
S, and T waves.
Myocardial Infarction is an acute ischemic heart disease
characterized by a necrosis (death) of a portion of the heart
muscle because of deprivation from oxygen. MI causes a
serious disturbance of the cardiovascular system that leads to a
direct threat for life.
MI is typically characterized by an elevation in the ST
segment of ECG which is normally iso-electric for healthy
subjects. ST segment elevation is generally one of the first
symptom of MI and is usually accompanied by chest pain. But
in order to be more specific to MI (or suspicious of MI), the
ST elevation must be significant in amplitude (up to 0.2 mV)
and prolonged in time (several minutes) as indicated in.
The rest of this report is organized as follows. Section II
briey reviews related techniques and presents our approach
for early detection of MI. Section III presents our
experimental results. Finally, Section IV concludes the report.
(a) One-cycle ECG tracing (b) ST Elevation ECG
Normal ECG and ST elevation ECG

We are going to utilize adaptive thresholding method [8] for


denoising the EKG signal using wavelet transforms. Wavelets
transforms prove effective as it has good localization
properties s in time and frequency domain. We improvise
existing thresholding methods to improve noise reduction
while insuring a good signal to noise ratio. Thresholding
basically removes some of the detailed coefficients exceeding
a certain threshold hence smoothing the signal out. The signal
is then reconstructed in the time domain using the modified
coefficients. Determining a good threshold is important as a
wrong threshold value can remove important ECG features or
let in too much noise. Thresholding generally consists of
taking the discrete wavelet transform of the signal using the
appropriate wavelet. A thresholding parameter is set to reduce
the detail coefficients in the wavelet transform and the
denoised version of the signal is obtained by taking the inverse
discrete wavelet transform of the signal using the modified
coefficients. Donoho and Johnston proposed the universal
threshold, called by them Wave Shrink given by:

= (2 log N )
Where is the standard deviation and N is the
M .A.D
number of points. In case of white noise =
0.6745
where MAD is the median absolute deviation of the
detail coefficients. We alter this algorithm to provide a
different threshold for each level of detail. Our altered formula
is:

j = j (2 log N j )
Where j =max (|d ( j , k )|) where d are the detail
coefficients at the
jth level. The estimated denoised
constructed by taking the inverse discrete wavelet transform
using the modified detail coefficients.
ECG signal analysis relies heavily on identifying a feature

Signals & Systems EE232, Spring 2015


and extracting subsequent features from it. Segments in the
signal can also be computed from these points of interest and
related to one another. Signal drift can introduce error in the
extraction of features and comparison between them. Hence, it
is necessary to obtain a normalized signal for an accurate
analysis.
The process for baseline wander correction is as described
in [5]. The raw ECG signal is first filtered with an FIR low
pass filter. Second, the filtered signal is passed through a 200
ms median filter to eliminate the QRS complex and then again
through a 600 ms median filter to remove the T wave. Then,
this signal is subtracted from the low passed filtered signal.
The difference between the two signals will constitute the
ECG signal corrected of baseline wander.
B. Extracting ST Elevation Spectrum (Asfandyar
Hassan Shah, Uzair Akbar)
Finally, we extract the main ECG features by rst detecting
the R peaks and their positions in the signal, then we can
extract the other peaks (P, Q, S, T) respectively and their
onsets and offsets based on the R peaks as described in [7]. R
peaks are detected by first taking the detail coefficients of the
original signal via 2nd level wavelet decomposition. This is the
squared and the positions of the maxima in a sliding window
of size almost equal to one pulse of the ecg signal is recorded.
The other peaks are located by finding the maximas and
minimas in the locality of the R peaks in the approximation
coefficeint signal.
ST segment amplitude can be calculated from S-offset and
T-Onset. These are extracted from the signal and concatenated.
The result is a time series of ST segment amplitudes per cycle
of ECG. We consider only positive amplitudes of ST in our
system, because ST elevations are more specific to MI than a
ST depression. However, we cant consider a single ST
elevation as a sign of MI, this is why we use a change
detection algorithm in order to detect new and significant ST
elevation changes in ECG. Moreover, we define a window
size and a minimum number of deviations, k that need to be
detected within this window before raising an alarm, the aim is
to ensure that the detected deviations are sufficiently
prolonged to avoid false alarms. This method is described in
[9].
C. Detecting MI via CUSUM Algorithm(Asfandyar
Hassan Shah, Uzair Akbar)
After the positive amplitude ST segments have been
extracted from the ECG signal, we need to detect a
Myocardial infarction by analysing the ST elevations, in the
ST segments as a significant elevation in the ST amplitudes
suggests the onset of MI [9]. To detect a change in ST
amplitudes we employ the cumulative sum (CUSUM)
algorithm [1] which is based upon the repeated use of the
sequential probability ratio test (SPRT) [2]. What follows is
the (mathematical) description of the algorithm:
Let X [n] be a discrete random signal with independent
identically distributed samples, with a probability density

2
function (PDF)

p X ( X [ n ]=x [ n ] ; ) , where x [n] is


X [ n ] at n and is a parameter of the

the value of
signal X [ n] . The signal may undergo an abrupt change at

n0 , at which the parameter

time

changes from

0 1 . As the PDF of X [ n] is a function of ,


the change in results in a change in the PDF of
X [ n] .
We define two hypotheses:
H 0 ; =0
The null hypothesis,
hypothesis,
The

and The alternate

H 1 ; =1 .
PDF
n

p X H ( x [ 0 ] , , x [ n ] ; 0 )= p X (x [ k ] ; 0)
0

independence

from

k=0

of

random

variables

and

n01

the

PDF

p X H ( x [ 0 ] , , x [ n ] ; 1) = p X (x [ k ] ; 0 ) p X (x [ k ] ; 1 )
1

k=0

k=n0

.
The algorithm requires prior knowledge of the both the
0 and 1 . The
PDFs as well as the values of
algorithm functions as follows:
k = 0
while algorithm running
measure x[k]
decide between H0 and H1
if H1
n1 = k
estimate n0
stop
end if
end while
To decide between H 0 and H 1 from X [ n] is a
binary hypothesis testing problem. A binary hypothesis
problem can be adequately decided between the two
conflicting hypothesis by the likelihood ratio test

P ( L ( X )> ; H 0 ) =
(the likelihood function),

where

L ( X )=

p (0 )
p (1 )

p X ( x ; H 1)
p X ( x ; H 0)

(the critical value)

and , the significance level [3]. For the SPRT, we use the
log likelihood function

ln ( L ( X ))=ln

p X (x ; H 1)
p X (x ; H 0)

as

the log likelihood function shows a negative drift before the


change and a positive drift after [2].

Signals & Systems EE232, Spring 2015


n01

L ( X [n])=

p X ( x [ k ] ; 0 ) p X ( x [ k ] ; 1 )

k=0
k=n
0

k=n0

p X (x [ k ] ; 0)

k=0

Var ( 0 )=Var ( 1 )= 2
p X ( xas[ k ] ;11 ) is a linear function of 0 . Now as X [n]
a
normal
distribution
p X ( xhas
[ k ] ; 0 )
1
pX ( x [k ] ; )=
e( x [ n] )/ 2 .
2
we let

p X (x [ k ] ; 1)
p X (x [ k ] ; 0 )
k=n
If L( X [ n ] )> h then H 1 is accepted.

ln ( L ( X [ n ] ) ) = ln

Hence

G(X [ n ] )=max ( L ( X [ n ] ))

log

S [ n ] = ln
k=0

ratio

p X (x [ k ] ; 1)
p X (x [ k ] ; 0)

of

the

p X ( x [ n ] ; 1 )
p X ( x [ n ] ; 0)
nth

sample

as
and

as the cumulative sum of

the log likelihood ratio of n samples. Hence the log likelihood


ratio,
can
be
expressed
as
L(X [ n ] )

L ( X [ n ] ) =S [ n ] S[n0 1] which gives us:

G ( X [ n ] )=max ( L ( X [ n ] ) ) =S [ n ] min ( S [ n01 ] )


If G ( X [ n ] ) h , H 0 is rejected.
Both
S [ n ] and G ( X [ n ] ) can also be expressed
recursively
as
and
S [ n ] =S [ n1 ] +s [ n]
G ( X [ n1 ] +s [ n ] , 0 )
CITATION MBa93 \l 2057

G ( X [ n ] ) =
[2]

Lets define X [ n ] =X 0 , , X n where X 0 , , X n


are independent identically distributed random variables with
a common mean and variance 2 , and define

Z=

X 0+ + X nn
n

Then the CDF of Z converges to the normal CDF


CITATION Dim08 \l 2057
[3]
.
Hence if n is relatively large, X[n] (as it is in our case of ST
segments of ECG waves for a period of 2 hours) can be
modelled by the normal distribution irrespective of the
distributions of X 0 , , X n .
Now as we have two hypothesis

0 ,

and

H1

(x [ n ] 1) / 2

G X [ n1 ] +

10
2

function

10

( x [n ]

G ( X [ n ] ) =

( x [ n ]

1 + 0
), 0
2

1 + 0
)
2

1 is not known beforehand, we define


1=0 + which is a linear function of 0 hence the
As the value of

x [ n ] 0 ,0
2

Now
G(X [ n1 ] )+ 2 () where must be set a

G ( X [ n ] ) =
priori.
We now adjust the algorithm for our specific problem,
detecting if a patients ECG shows any signs of MI. We have a
sequence ST =ST [ 0 ] , , ST [ n ] , which are the values
of ST segments. We assume that the ST samples are
normally distributed with a mean and a variance of
2
. Our NULL hypothesis, H 0 , is that the patient is
healthy, and the alternate hypothesis, H 1 ,
is that the
patient is having a MI event. We define the changing
parameter, i , in our binary hypothesis as the mean,

i , with the mean for H 0 as 0 and the mean for


H 1 as 1=0 + . We use the recursive form of the
CUSUM algorithm to detect when and if we change from
H 0 to H 1 . Hence we define s i as the log
likelihood ratio for the

ith

term and

Si

as the

cumulative sum of s i . We also define the GLRT at the


ith term, whose value, if greater than a parameter, h
(which is set a priori), is used to detect changes as:

(z ) as n

with mean

Hence

likelihood

(x [ n ] 1) / 2

variance of the overall sample remains unaffected.

s [ n ] =L ( x [ n ] )=ln

likelihood
n

log

ln ( L ( X [ n ] ) ) =ln

The above mentioned value cannot be calculated as the


value of n0 is not known prior to the experiment. The solution
to this problem is to replace the unknown quantities in
by their maximum likelihood estimates
L ( X [ n])
(MLEs). This is known as the generalized likelihood ratio test
(GLRT) [4].
GLRT is defined as follows:

the

then the

Let us define

1=0 +

H0

(normal ECG),

(MI), with mean

1 , if

G i ( ST )=S imin S j .
0 < j <i

If

Gi ( ST )> h

for any

we record it as a change in from H 0 H 1 . G i ( ST ) as


previously defined recursively will be calculated by

Gi ( ST )= Gi1 (ST )+

( ST [ i ] 0 ), 0
2
2

where

must be set a priori. We set a parameter w for window


size in which ST
samples will be considered and a
parameter k for the minimum number of detections to be

Signals & Systems EE232, Spring 2015


detected in a window of size w before raising the alarm.
Our algorithm is as follows:
ST Elevation Detection Algorithm

set
value
set threshold value h>0
S = S_prev = 0
G = G_prev = 0
set initial values of and
initialize A[n] = 0
set i = 0
while algorithm running
measure ST[i]
calculate s_i
S_prev = S
calculate S
G_prev = G
calculate G
if G>h
A[i] = 1
if (sum(A) > k)
sound alarm
G = 0
else
G = G_prev
end if
else if (G <= 0)
G = 0
end if
calculate new from ST_i for i
such that A[i] = 0
shift window to right by one value
i = i + 1
end while

4
III. EXPERIMENTAL RESULTS

Signals & Systems EE232, Spring 2015


Raw ECG Signal of MI Patient

1.4

1st Level App Coefficients

1.3

1.2

1.1

0.8

0.6

0.6

0.4

0.4

0.2

0.2

-0.2

Base Line Wandering

2nd Level App Coefficients

0.8

-0.4
V(mV)

1.5
1
0.5
0
-0.5
-1

-0.2
0

100

200

300

400

500

600

-0.4

700

-1.5
0

50

100

150

200

250

300

130

350

140

150

160

170

180

1
3rd Level App Coefficients

0.9

Baseline Corrected Signal

4th Level App Coefficients

1.5

1.5

0.8
1

0.6

0.8

0.4

0.7

1
0.5

0.5

0.2

-0.5

-0.2
0

0.5

1.5

2.5
t (sec)

3.5

4.5

-0.4

20

40

60

80

FIGURE - I

100

120

140

160

-0.5

180

-1
0

10

20

30

40

50

60

70

80

130

90

FIGURE - II

Wavelet decomposed and baseline corrected ecg

150

160

170

180

FIGURE - III

ST Elevation Spectrum

1.4

140

CUSUM Alarms

1.4

1.5

0.5

1.2

1.2

0.8

0.8

0.6

0.6

0.4

0.4

0.2

0.2

-0.5

-1

100

150

200

250

300

500

1000

1500

2000

2500

3000

FIGURE - V

FIGURE - IV

In order to evaluate our proposed approach for the early


detection of MI, we use the EDB medical database from the
Physionet [6]. This database consists of 90 annotated ECG
recordings from 79 subjects. These subjects have various heart
anomalies (vessel disease, hypertension, coronary artery
disease, ventricular dyskinesia, and myocardial infarction).
Each data trace is two hours in duration and contains two
signals (2-lead ECG), each sampled at 250 samples per second
with 12-bit resolution over a nominal 20 millivolt input range.
The sample values were rescaled after digitization with
reference to calibration signals in the original analog
recordings, in order to obtain a uniform scale of 200 ADC
units per millivolt for all signals. Figures - I shows the original
ECG signal of a patient with MI for a period of 5 seconds
before ltering & denoising to illustrate ST elevation, Figure II shows the result of wavelet decomposition. The frequency
bands of the original signa l were separated in four levels. The
second level decomposition of the signal was considered as
the ideal ECG signal for the features extraction because it is
the least noisy. Figure - III shows base line correction. Figure IV shows the detection of various features of the ECG. Figure
V shows the variation of ST elevation amplitudes extracted
for one half of an ECG record (1 hours) of a patient with MI.
Figure - VI shows the raised alarms by the modied version of
CUSUM algorithm, when the threshold h 2, the windows
size w = 100 samples and the minimum deviations k = 3.
IV. CONCLUSION
In this report, we proposed an approach for early detection
of Myocardial Infarction (MI) in real time manner. The
proposed approach is based on the detection of deviations in
ST segment elevation in the ECG. We combined adaptive
thresholding and Cumulative Sum Method (CUSUM) for a
low power detection system. The adaptive thresholding

3500

4000

500

1000

1500

2000

2500

3000

3500

4000

FIGURE - VI
technique is rst used to denoise and lter the original ECG
signal and extract the values of ST segments, then the
CUSUM algorithm is applied on these extracted values to
detect signicant deviations of ST elevation in order to raise
alarms. To reduce the probability of false alarms, we adapted
the CUSUM algorithm by introducing a sliding window with
xed size, to hold the number of deviations that must be
detected before raising an alarm. Finally, we applied our
proposed approach on a real medical database (the Physionet
EDB database) using MI and other cardiac problems ECG.
REFERENCES
[1] E. S. Page, "Continuous Inspection Schemes,"
Biometrika, vol. 41, pp. 100-115, 1954.
[2] M. Basseville, Detection of abrupt changes:
Theory and application, Prentice Hall, 1993.
[3] J. N. T. Dimitri P. Bertsekas, Introduction to
Probability, Athena Scientific, 2008.
[4] S. Kay, Fundamentals of statistical signal
processing, volume 2: Detection theory, Prentice
Hall PTR, 1998.
[5] Method for Correcting Baseline Wander in
Raw ECG Signals, ECG Signal Analysis for
Myocardial Infarction Detection, ELEC 301
Projects Fall 2013.
[6] PhysioBank, PhysioToolkit, and PhysioNet:
Components of a New Research Resource for
Complex Physiologic Signals, Circulation, vol.
101, no. 23, pp. 215220, 2000.
[7] ECG Feature Extraction with Wavelet
Transform and ST Segment Detection using
Matlab 2012, Grasshopper.iics, Code Project
[8] Denoising of Electrocardiogram Data with
Methods of Wavelet Transform, CompSysTech13.

Signals & Systems EE232, Spring 2015


[9] Early Detection of Myocardial Infarction Using
WBAN 2013, IEEE, E-Health Networking.

You might also like