Myocardial 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.
Heart Disease Prediction using machine learning.pptx
ECG Signal Analysis for Early Detection of Myocardial Infarction (MI
1. Signals & Systems EE232, Spring 2015 1
Abstract—Myocardial 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 newertechnology 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.
Index Terms—Mycardial 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 systemthat 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
briefly 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
II. IMPLIMENTATION
There are three aspects of our project:
A. ECG Signal Pre-processing (Ryshum Ali, Mahnoor
Haneef)
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 𝑁)
Where 𝜎 is the standard deviation and 𝑁 is the number of
points.In case of white noise 𝜎 =
𝑀.𝐴.𝐷
0.6745
where 𝑀𝐴𝐷 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:
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
T
2. Signals & Systems EE232, Spring 2015 2
𝛿𝑗
𝜇
= 𝜎 𝑗√(2 log 𝑁 𝑗
)
Where 𝜇𝑗
= max(| 𝑑( 𝑗, 𝑘)|)where 𝑑 are the detail
coefficients at the 𝑗𝑡ℎ 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
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 first 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 can’t
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 𝑋[𝑛] be a discrete random signal with independent
identically distributed samples, with a probability density
function (PDF) 𝑝𝑋
( 𝑋[ 𝑛] = 𝑥[ 𝑛]; 𝜃), where 𝑥[𝑛] is the value
of 𝑋[ 𝑛] 𝑎𝑡 𝑛 and 𝜃 is a parameter of the signal𝑋[𝑛]. The signal
may undergo an abrupt change at time 𝑛0 , at which the
parameter 𝜃 changes from 𝜃0 ⇒ 𝜃1 . As the PDF of 𝑋[𝑛] is a
function of 𝜃, the change in 𝜃 results in a change in the PDF
of 𝑋[ 𝑛].
We define two hypotheses:
The null hypothesis, 𝐻0; 𝜃 = 𝜃0 and The alternate
hypothesis, 𝐻1; 𝜃 = 𝜃1 .
The PDF 𝑝 𝑋|𝐻0
( 𝑥[0], ⋯ , 𝑥[ 𝑛]; 𝜃0
) = ∏ 𝑝𝑋 (𝑥[ 𝑘]; 𝜃0 )𝑛
𝑘=0
from independence of random variables and the PDF
𝑝 𝑋|𝐻1
( 𝑥[0],⋯ , 𝑥[ 𝑛]; 𝜃1
) =
∏ 𝑝𝑋 (𝑥[ 𝑘]; 𝜃0 )
𝑛0−1
𝑘=0
∏ 𝑝𝑋 (𝑥[ 𝑘]; 𝜃1 )𝑛
𝑘=𝑛0
.
The algorithm requires prior knowledge of the both the
PDFs as well as the values of 𝜃0 and 𝜃1 . The 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 𝐻0 and 𝐻1 from 𝑋[𝑛] is a binary
hypothesis testing problem. A binary hypothesis problemcan
be adequately decided between the two conflicting hypothesis
by the likelihood ratio test 𝑃( 𝐿( 𝑋) > 𝜉; 𝐻0
) = 𝛼 where
𝐿( 𝑋) =
𝑝 𝑋(𝑥;𝐻1 )
𝑝 𝑋(𝑥;𝐻0 )
(the likelihood function), 𝜉 =
𝑝Θ(𝜃0 )
𝑝Θ(𝜃1 )
(the
critical value) and 𝛼, the significance level [3]. For the SPRT,
we use the log likelihood function ln(𝐿( 𝑋)) = ln
𝑝 𝑋(𝑥;𝐻1 )
𝑝 𝑋(𝑥;𝐻0 )
as
the log likelihood function shows a negative drift before the
change and a positive drift after [2].
𝐿( 𝑋[𝑛]) =
∏ 𝑝𝑋 (𝑥[ 𝑘]; 𝜃0 )
𝑛0−1
𝑘=0
∏ 𝑝𝑋 (𝑥[ 𝑘]; 𝜃1 )𝑛
𝑘=𝑛0
∏ 𝑝𝑋 (𝑥[ 𝑘]; 𝜃0 )𝑛
𝑘=0
= ∏
𝑝𝑋 (𝑥[ 𝑘]; 𝜃1)
𝑝𝑋 (𝑥[ 𝑘]; 𝜃0 )
𝑛
𝑘=𝑛0
ln( 𝐿( 𝑋[ 𝑛])) = ∑ ln
𝑝𝑋 (𝑥[ 𝑘]; 𝜃1)
𝑝𝑋 (𝑥[ 𝑘]; 𝜃0 )
𝑛
𝑘=𝑛0
If 𝐿(𝑋[ 𝑛]) > ℎ then 𝐻1 is accepted.
3. Signals & Systems EE232, Spring 2015 3
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 (MLEs). This
is known as the generalized likelihood ratio test (GLRT) [4].
GLRT is defined as follows:
𝐺(𝑋[ 𝑛]) = max(𝐿( 𝑋[ 𝑛]))
Let us define 𝑠[ 𝑛] = 𝐿( 𝑥[ 𝑛]) = ln
𝑝 𝑋(𝑥[ 𝑛];𝜃1)
𝑝 𝑋(𝑥[ 𝑛];𝜃0)
as the log
likelihood ratio of the nth sample and 𝑆[ 𝑛] =
∑ ln
𝑝 𝑋(𝑥[ 𝑘] ;𝜃1 )
𝑝 𝑋(𝑥[ 𝑘] ;𝜃0 )
𝑛
𝑘=0 as the cumulative sum of the log likelihood
ratio of n samples. Hence the log likelihood ratio, 𝐿(𝑋[ 𝑛]) can
be expressed as 𝐿( 𝑋[ 𝑛]) = 𝑆[ 𝑛] − 𝑆[𝑛0 − 1] which gives us:
𝐺( 𝑋[ 𝑛]) = max( 𝐿( 𝑋[ 𝑛])) = 𝑆[ 𝑛] − min( 𝑆[ 𝑛0 − 1])
If 𝐺( 𝑋[ 𝑛]) ≥ ℎ, 𝐻0 is rejected.
Both 𝑆[ 𝑛] and 𝐺( 𝑋[ 𝑛]) can also be expressed recursively
as 𝑆[ 𝑛] = 𝑆[ 𝑛 − 1] + 𝑠[𝑛] and 𝐺( 𝑋[ 𝑛]) = sup(𝐺( 𝑋[ 𝑛 −
1] + 𝑠[ 𝑛], 0) [2].
Lets define 𝑋[ 𝑛] = 𝑋0 , ⋯ , 𝑋𝑛 where 𝑋0 , ⋯, 𝑋𝑛 are
independent identically distributed random variables with a
common mean 𝜇 and variance 𝜎2
, and define
𝑍 =
𝑋0 + ⋯ + 𝑋𝑛 − 𝑛𝜇
𝜎√𝑛
Then the CDF of Z converges to the normal CDF Φ(𝑧) as
𝑛 → ∞ [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 𝑋0 , ⋯ , 𝑋𝑛.
Now as we have two hypothesis 𝐻0 (normal ECG), with
mean 𝜇0, and 𝐻1 (MI), with mean 𝜇1, if we let 𝜇1 = 𝜇0 + 𝛿
then the 𝑉𝑎𝑟(Θ0
) = 𝑉𝑎𝑟(Θ1
) = 𝜎2
as 𝜇1 is a linear function
of 𝜇0. Now as 𝑋[𝑛] has a normal distribution 𝑝𝑋
( 𝑥[ 𝑘]; 𝜃) =
1
𝜎√2𝜋
𝑒−(𝑥[ 𝑛]− 𝜇) 2𝜎2⁄
.
Hence log likelihood function ln( 𝐿( 𝑋[ 𝑛])) =
ln
𝑒−(𝑥[𝑛]− 𝜇1)2 2𝜎2⁄
𝑒−(𝑥[𝑛]− 𝜇1)2 2𝜎2⁄
=
𝜇1− 𝜇0
𝜎2
(𝑥[ 𝑛] −
𝜇1+ 𝜇0
2
)
Hence 𝐺( 𝑋[ 𝑛]) = sup(𝐺 ( 𝑋[ 𝑛 − 1] +
𝜇1− 𝜇0
𝜎2 (𝑥[ 𝑛] −
𝜇1+ 𝜇0
2
), 0).
As the value of 𝜇1is not known beforehand, we define 𝜇1 =
𝜇0 + 𝛿 which is a linear function of 𝜇0 hence the variance of
the overall sample remains unaffected.
Now 𝐺( 𝑋[ 𝑛]) = sup ( 𝐺(𝑋[ 𝑛 − 1]) +
𝛿
𝜎2
(𝑥[ 𝑛] − 𝜇0 −
𝛿
2
, 0) where 𝛿 must be set a priori.
We now adjust the algorithm for our specific problem,
detecting if a patients ECG shows any signs of MI. We have a
sequence 𝑆𝑇 = 𝑆𝑇[0],⋯ , 𝑆𝑇[ 𝑛], which are the values of 𝑆𝑇
segments. We assume that the 𝑆𝑇 samples are normally
distributed with a mean 𝜇 and a variance of 𝜎2
. Our NULL
hypothesis, 𝐻0, is that the patient is healthy, and the alternate
hypothesis, 𝐻1, is that the patient is having a MI event. We
define the changing parameter, 𝜃𝑖 , in our binary hypothesis as
the mean, 𝜇 𝑖, with the mean for 𝐻0 as 𝜇0 and the mean for 𝐻1
as 𝜇1 = 𝜇0 + 𝛿. We use the recursive form of the CUSUM
algorithm to detect when and if we change from 𝐻0 to 𝐻1.
Hence we define 𝑠𝑖 as the log likelihood ratio for the 𝑖𝑡ℎ term
and 𝑆𝑖 as the cumulative sum of 𝑠𝑖. We also define the GLRT
at the 𝑖𝑡ℎ term, whose value, if greater than a parameter, h
(which is set a priori), is used to detect changes as: 𝐺𝑖
( 𝑆𝑇) =
𝑆𝑖 − min
0<𝑗<𝑖
𝑆𝑗. If 𝐺𝑖
( 𝑆𝑇) > ℎ for any 𝑖 we record it as a change
in from 𝐻0 𝑡𝑜 𝐻1. 𝐺𝑖
( 𝑆𝑇) as previously defined recursively
will be calculated by 𝐺𝑖
( 𝑆𝑇) = sup ( 𝐺𝑖 −1(𝑆𝑇) +
𝛿
𝜎2
(𝑆𝑇[ 𝑖] −
𝜇0 −
𝛿
2
), 0) where 𝛿 must be set a priori. We set a parameter
w for window size in which 𝑆𝑇 samples will be considered
and a parameter 𝑘 for the minimum number of detections to be
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. Signals & Systems EE232, Spring 2015 4
III. EXPERIMENTAL RESULTS
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 filtering & 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 modified 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
technique is first used to denoise and filter the original ECG
signal and extract the values of ST segments, then the
CUSUM algorithm is applied on these extracted values to
detect significant 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
fixed 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. 215–
220, 2000.
[7] ECG Feature Extraction with Wavelet Transform and ST
Segment Detection using Matlab 2012,Grasshopper.iics,
Code Project
[8] Denoising of ElectrocardiogramData with Methods of
Wavelet Transform, CompSysTech’13.
[9] Early Detection of Myocardial Infarction Using WBAN
2013,IEEE, E-Health Networking.
130 140 150 160 170 180
-1.5
-1
-0.5
0
0.5
1
1.5
Base Line Wandering
130 140 150 160 170 180
-1
-0.5
0
0.5
1
1.5
Baseline Corrected Signal
100 150 200 250 300
-1
-0.5
0
0.5
1
1.5
Wavelet decomposed and baseline corrected ecg
0 500 1000 1500 2000 2500 3000 3500 4000
0
0.2
0.4
0.6
0.8
1
1.2
1.4
CUSUM Alarms
0 500 1000 1500 2000 2500 3000 3500 4000
0
0.2
0.4
0.6
0.8
1
1.2
1.4
ST Elevation Spectrum
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
0.7
0.8
0.9
1
1.1
1.2
1.3
1.4
Raw ECG Signal of MI Patient
t (sec)
V(mV)
0 100 200 300 400 500 600 700
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
1st Level App Coefficients
0 50 100 150 200 250 300 350
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
2nd Level App Coefficients
0 20 40 60 80 100 120 140 160 180
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
3rd Level App Coefficients
0 10 20 30 40 50 60 70 80 90
-0.5
0
0.5
1
1.5
4th Level App Coefficients
FIGURE - IIFIGURE - I FIGURE - III
FIGURE - IV FIGURE - V FIGURE - VI