Supervised ECG Interval Segmentation Using LSTM Neural Network
Supervised ECG Interval Segmentation Using LSTM Neural Network
For our current study, every recording is divided into 500 yt = Why ht + by (2)
data points sampled at 250Hz. Within every segment, one
where, W denotes weight matrices, b denotes bias vectors,
or more cardiac complexes can be found, which makes the
and H denotes hidden layer function.
segmenting task more challenging. The 500 ECG data points The novelty of this work is to use recurrent neural networks
and their extracted features are the inputs to ECG-SegNet to classify each data point of an ECG signal into one of the
model, and correspondingly, the related annotations are the four categories, namely, the P-wave, the QRS-wave, the T-
output targets for the ECG-SegNet model. In total, there are wave, and the neutral. Thus, as a result of ECG segmentation,
64, 040 sets of 500 data points of ECG that have been extracted classification of every data point can be achieved. One of
from the QTDB to be used as inputs. the main shortcomings of the conventional recurrent neural
In our experiments, three different sets - training, validation,
networks in dealing with long term dependencies is that these
and test sets - have been created using all the extracted ECG
networks encounter a problem called vanishing-exploding gra-
parts. These sets are mutually exclusive, indicating there are
dients [26], i.e., the derivative of error with respect to weights
no identical segments from one recording to another. Table I
gets close to zero or infinity after a short period of the time.
illustrates the training, validation and test data we used in this
This problem makes the networks hard to train for long term
paper.
dependencies. Hochreiter and Schmidhuber [27] were able to
overcome this problem in their well-known work on Long
TABLE I
DATASET Short-Term Memory recurrent neural networks (LSTM RNN).
LSTM RNN uses trainable memory cells called LSTM cells
Dataset Number of samples Percentage instead of simple neurons. These memory cells have three
Training set 51,419 55%
Validation set 9,350 10% trainable gates including input, output, and forget gates. These
Testing set 32,721 35% gates have the ability to add or remove information, thus,
avoid long term dependencies. A large number of applications
have performed better than their competitors using such LSTM
C. Extracted Features
networks [28]. Figure 2 shows a LSTM cell, the gates and their
In this work, in addition to raw ECG data points, three output computations are given in the following equations:
other features are extracted using different filtering kernels,
such as the local average of a data point and the first and it = σ(Wxi xt + Whi ht−1 + Wci ct−1 + bi ) (3)
second derivatives of a data point. Hence, for every data point, ft = σ(Wxf xt + Whf ht − 1 + Wcf ct−1 + bf ) (4)
a feature vector of size four is created to feed to the network, as
explained in Subsection III-E. As a result of applying feature ct = ft ct−1 + it tanh(Wxc xt + Whc ht−1 + bc ) (5)
extraction to 500 ECG data points, the complete input to the ot = σ(Wxo xt + Who ht−1 + Wco ct−1 + bo ) (6)
ECG-SegNet becomes a matrix of 500 × 4 dimension. Table II
ht = ot tanh(ct ) (7)
illustrates the kernels that are used to convolve with the raw
ECG signal. where, σ is the logistic sigmoid function, and i, f , o, a and c
are the input gate, forget gate, output gate, cell input activation,
TABLE II and cell state vectors, respectively, and all of them are the
K ERNELS TO EXTRACT FEATURES same size as the hidden vector h. Wci , Wcf , Wco are weight
No. Type Kernel Length matrices for peephole connections [25].
1 Raw ECG value None Not applicable Another aspect of RNN is that only the prior data is used.
2 Smoothing [1,1,1,1,1,1,1,1,1,1] 10 However, in many cases, the future data is available and can
3 First Derivative [1, 1, 1, 0, -1, -1, -1] 7
4 Second Derivative [1, 1, 1, -6, 1, 1, 1] 7
be used as an informational source. Schuster et al. introduced
a Bidirectional RNN (BRNN) [29], which uses both directions
of the data, prior and future data points, in two separate hidden
D. Bidirectional Long Short-Term Memory Recurrent Neural layers. Graves et al. use LSTM in a BRNN and introduce
Network Review Bidirectional LSTM (BLSTM) [24]. Therefore, BLSTM is a
As mentioned earlier, a shortcoming of traditional neural recurrent neural network that uses LSTM cells and computes
networks is that it fails to classify an event based on prior both forward and backward hidden sequences. By stacking up
observations [25]; however, recurrent neural networks are these types of layers, a new deep network, called the Deep
intrinsically fit for segmenting ECG signals. In a conventional Bidirectional LSTM (DBLSTM), is obtained.
recurrent neural network, the input x = (x1 , x2 , ..., xT ) feeds Utilizing DBLSTM in ECG segmentation helps to classify
to the network, and RNN computes the hidden vector se- a signal sample based on prior and future sample points, i.e.,
quence, h = (h1 , h2 , ..., hT ), and the output vector sequence, finding QRS-wave using prior sample points such as P-wave
y = (y1 , y2 , ..., yT ), from t = 1, ..., T while T is the number samples and future data points such as S-wave samples. Thus,
of timestamps as, DBLSTM becomes a very viable approach to be explored
for ECG segmentation task. We will use this to define new
ht = H(Wxh xt + Whh ht−1 + bh ) (1) network architecture in the next section.
TABLE III
D EEP BIDIRECTIONAL LSTM FOR ECG SEGMENTATION
TABLE IV
ECG SEGMENTATION RESULTS
TABLE V
S EGMENTATION ACCURACY COMPARISON
ACKNOWLEDGMENT
We thank Ohio Supercomputer Center [31] for providing
high performance computation power for this research.
R EFERENCES
[1] Ecg wave. http://lifeinthefastlane.com/ecglibrary/ basics/t-wave/. Ac-
cessed: 2017-09-30.
[2] M. J. Campbell, X. Zhou, C. Han, H. Abrishami, G. Webster, C. Y. M.,
C. T. Sower, J. B. Anderson, T. K. Knilans, and R. J. Czosek. Pilot study
analyzing automated ecg screening of hypertrophic cardiomyopathy.
Heart Rhythm, 14(6):848–852, 6 2017.
[3] R. Tafreshi, A. Jaleel, J. Lim, and L. Tafreshi. Automated analysis of
ECG waveforms with atypical QRS complex morphologies. Biomedical
Signal Processing and Control, 10:41–49, 2014.
[4] A. Karimipour and M. R. Homaeinezhad. Real-time electrocardiogram
P-QRS-T detection-delineation algorithm based on quality-supported
analysis of characteristic templates. Computers in Biology and Medicine,
52:153–165, 2014.
[5] N. P. Hughes, L. Tarassenko, and S. J. Roberts. Markov models for
automated ecg interval analysis. In Proceedings of the 16th International
Conference on Neural Information Processing Systems, NIPS’03, pages
611–618, Cambridge, MA, USA, 2003. MIT Press.
[6] B. Frénay, G. de Lannoy, and M. Verleysen. Emission Modelling for
Supervised ECG Segmentation using Finite Differences, pages 1212–
1216. Springer Berlin Heidelberg, Berlin, Heidelberg, 2009.
[7] I. S. N. Murthy and U. C. Niranjan. Component wave delineation of ecg
by filtering in the fourier domain. Medical and Biological Engineering
and Computing, 30(2):169–176, Mar 1992.
[8] S. K. Mukhopadhyay, M. Mitra, and S. Mitra. Time plane ecg feature
extraction using hilbert transform, variable threshold and slope reversal
approach. pages 1–4, December 2011.
[9] P. Laguna, N. V. Thakor, P. Caminal, R. Jané, Hyung-Ro Yoon,
A. Bayés de Luna, V. Marti, and Josep Guindo. New algorithm for
qt interval analysis in 24-hour holter ecg: performance and applications.
Medical and Biological Engineering and Computing, 28(1):67–73, Jan
1990.
[10] J. Pan and W. J. Tompkins. A real-time qrs detection algorithm. IEEE
Transactions on Biomedical Engineering, BME-32(3):230–236, March
1985.
[11] C. Li, C. Zheng, and C. Tai. Detection of ecg characteristic points using
wavelet transforms. IEEE Transactions on Biomedical Engineering,
42(1):21–28, Jan 1995.
[12] W. Kaiser, T. S. Faber, and M. Findeis. Automatic learning of rules. A
practical example of using artificial intelligence to improve computer-
based detection of myocardial infarction and left ventricular hypertrophy
in the 12-lead ECG. Journal of electrocardiology, 29 Suppl:17–20, 1996.
[13] N. Ouyang, K. Yamauchi, and M. Ikeda. Training a NN with ECG to
diagnose the hypertrophic portions of HCM. 1:306–309 vol.1, 1998.
[14] R. V. Andreao, B. Dorizzi, and J. Boudy. Ecg signal analysis through
hidden markov models. IEEE Transactions on Biomedical Engineering,
Fig. 6. Two sample results 53(8):1541–1549, Aug 2006.
[15] O. Sayadi and M. B. Shamsollahi. A model-based bayesian framework
for ecg beat segmentation. Physiological Measurement, 30(3):335, 2009.