Recurrent Neural Network Based Classification of ECG Signal Features For Obstruction of Sleep Apnea Detection
Recurrent Neural Network Based Classification of ECG Signal Features For Obstruction of Sleep Apnea Detection
Abstract—This paper introduces an OSA detection method [10], [11] proposed an OSA detection based on snoring sound
based on Recurrent Neural network. At the first step, RR interval directly taken from people. As snoring sound is generated
(time interval from one R wave to the next R wave) is employed to because of narrowing in the upper airway and the resulting
extract the signals from Apnea- Electrocardiogram (ECG) where
all extracted features are then used as an input for the designed vibration of the upper airway tissue, this method employed
deep model. Then an architecture having four recurrent layers snoring for OSA detection. After extracting the snoring signal
and batch normalization layers are designed and trained with features using RR-interval, they employed the traditional neu-
the extracted features for OSA detection. Apnea-ECG datasets ral network called artificial neural network for classification.
from physionet.org are used for training and testing our model. [12] proposed Neural network (NN) based features selection
Experimental results reveal that our automatic OSA detection
model provides better classification accuracy. and identification of OSA and gains up to 70% classification
Index Terms—Feature extraction; Sleep Apnea; ECG; Apnea accuracy. Here the NN used for two purposes; one is to
Detection; RNN; choose the optimal frequency bands that can be used for
identification at the time of features extraction and the other
I. I NTRODUCTION is used for detection during the features matching stage. Also,
Obstructive sleep apnea (OSA) is a prolonged respiratory [13], adopted a support vector machine (SVM) for OSA
ailment that happens in 10% of population [1]. The reason patient classification, and feature extraction using RR intervals
of OSA is the repetitive collapse of the upper airway at the and wavelet decomposition. In their work, about 90% of the
time of sleeping. Also, former studies have shown that OSA subjects in the testing set are properly detected
is linked with the higher risk of stroke, heart failure [2] and Most of the aforementioned methods used the simple NN to
vehicle accident [3]. OSA can be treated by undertaking a classify OSA and non optimal features extraction methods
full night polysomnography (PSG) at a laboratory of sleep. It which lead to poor classification results. In this paper, we
records the breath air flow, movement of respiratory, oxygen propose a recurrent neural networks [14], [15] model that
saturation, position of the body, electromyography (EMG), automatically detects an OSA signal from apnea- ECG signals.
electroencephalography (EEG) and electrocardiogram (ECG) Our method first extracts features from apnea-ECG recording
[4] where the recorded signals are used for multipurpose such and then the extracted features are used as an input for the
as OSA detection [5]. However, as a result of high cost of recurrent neural networks (RNN) composed of recurrent layers
in-lab sleep investigation and the time it cost to study, more and batch normalization where Sigmoid function is used as an
than 90% of patients at risk of obstructive sleep apneas are activation function. The recurrent neural network we consider
not treated. as our base is the long short term memory as illustrated in
Two common difficulties in a number of the OSA detection figure 2 and discussed in detail in section II. Once the training
studies lie in the high-dimension feature domain and the black process is accomplished, this recurrent model can be used
box conclusion making process. Nowadays, most of the OSA for OSA detection. The detail of our model’s framework is
detection system focus on extracting frequency domain, the illustrated in figure 3.
time domain, and other nonlinear features from several ECG- The rest of this paper is organized as follows. Section II
based signals and then building classifiers with these features provides some highlighted description about RNN as primary
to decide OSA existence. concepts. The detail of proposed model is explained in section
In the literature, numerous feature selection means, including III. Section IV presents the experimental results. Finally,
statistical estimation [6], wrapper approaches [7] and principal Section V concludes the paper.
component analysis [8] have been exploited to minimize the
dimension of the feature space. For the decision making II. R ECURRENT N EURAL N ETWORK
process, [9] proposed a guideline used to extract features and
detect OSA by associating the value of extracted features There are several variations of RNN, such as Long short
with preset parameters, thus, causing in strong description of term memory(LSTM), Gate recurrent unit(GRU) and associa-
the detection outcome. Using Neural networks as classifiers, tive long short term memory(ALSTM). Since we focus on
LSTM to detect OSA, so we give the detail descriptions of Fig. 2. An illustration of LSTM
LSTM only.
A. Long Short Term Memory
Hochreiter and Schmidhuber initially proposed the term
Long Short Term Memory (LSTM) unit in 1997. However,
currently there are different versions of LST proposed by
researchers. We give the detail of LSTM proposed by Zaremba
[14], [16]. Assume that yt , ct and ht denote the input, cell and
hidden states, respectively, at iteration t. For current input yt ,
the previous cell state ct−1 , and its corresponding previous
hidden state ht−1 , the cell state ct and hidden state yt are
obtained as
Fig. 3. The over all farme work of our RNN based OSA detection model
f, i, o = σ((Hyt + U ht−1 ) + b) (1)
j = tanh((Hyt + U ht−1 ) + b) (2) breathing disorders based on a single channel ECG recording.
ct = f ∗ ct−1 + i ∗ j (3) According to this database, all polysomnographic recordings
were scored by one expert in a diverse way.
ht = o ∗ tanh(ct ) (4)
III. P ROPOSED MODEL
Where * denotes an element wise multiplication, b is a vector
of bias, and an activation function σ is a sigmoid function, In this section, we provide the detail description of proposed
Obstructive sleep apnea detection model, taking the current
σ(x) = 1/(1 + exp(−x)) (5) success of deep learning as an advantage.
H and U are two convolution linear transformation applied to
A. Proposed Architecture
yt and ht−1 respectively and finally, the output of an LSTM
layer at iteration t is ht . Figure 2 represents a graphical In various application of pattern recognition and detection
illustration of LSTM. tasks, deep learning has been widely used. Based on the size
and the structure of an input data, the number of layers and
B. ECG Data’s in Sleep Apnea nodes in the network always differs. Our proposed model
Heart rate, and other features of the ECG, vary in char- is based on RNN specifically LSTM proposed by zaremba,
acteristic techniques in similar with sleep related breathing which learns a predefined set of input-output example pairs.
ailments [17]. Earlier work made use of cyclical variations of As demonstrated in figure 3, our end-to-end model has four
heart rate but did not found effective algorithms to quantify basic sections; features extraction, recurrent layers, batch
sleep allied breathing disorders based on heart rate only normalization and an output layer explained one by one below.
[18]–[20]. It is clear that an estimation of heart rate cannot
produce an apnea index or an, hypopnea index. Both values 1) Features extraction: It is common to extract a set of
are obtained by the evaluation of airflow, respiratory effort and features from speech signals where detection is carried out on
oxygen saturation. Considering this limitation, it is proved that a set of these features instead of the original signal itself. In
evaluation of ECG can provide an approximate of disturbed our features extraction part, apnea ECG recordings used for
breathing during the night which should correspond to the training the model passed through feature extraction process
results obtained by standardized apnea scoring [21]. The ECG using RR intervals. Formally, RR- interval is a time interval
of sleep apnea database is collected to detect sleep associated
200
Authorized licensed use limited to: Seoul National University. Downloaded on December 05,2023 at 00:01:23 UTC from IEEE Xplore. Restrictions apply.
between two successive R peaks [17], which can be written γk and βk are learned along with other model parameters.
in a simple mathematical form as, In such manner or formulation, recurrent neural network is
benefited from data normalization [19]. Data normalization
RR(i) = R(i + 1) − R(i), i = 1, 2, , n − 1 (6) help the network train faster and provide higher accuracy.
The extracted feature is then used as an input for the next
layer called recurrent layer. 4) Softmax: After recurrent layers are applied to the
extracted features, the activation at the end of recurrent layer
2) Recurrent Layer: This part takes the extracted features may be flattened and fed into a classifier. In our experiments
as an input and produces a final output used for detection. It we employed numerous fully-connected layers followed by
has four recurrent layers where the first two sweeps horizon- a softmax classifier. The parameters of the model can be
tally and vertically and the other two recurrent layers sweeps approximated by the stochastic gradient descent algorithm
right and left over all extracted features. with the gradient computed by backpropagation algorithm to
More formally, Let Y = {yi,j } be an extracted feature from maximize the log-likelihood.
ECG signal using RR interval where Y ∈ Rw×h×c with w, h
5) Output Layer: When an ECG signal is propagated
and c the width, height and feature dimension respectively.
through the output layer, the final outcome is compared with
Given a patch with size wp × hp , we divide Y into a set
the desired value and an error value using MSE is computed
I × J patches, P = {pi,j } where I = wwp , J = hhp
for all output units. These errors are then back propagated
and pi,j ∈ Rwp ×hp ×c is the (i, j)th patches of an input to each node of the in-between layers. After every node in
features. The first index i represents the horizontal indices the network established an error value that defines its relative
and j represents the vertical indices. Primarily, we sweep the involvement to the overall error, parameters are updated. Once
features with two RNN where one is in the bottom up and the the parameters are optimized, our model is ready to solve the
other is in the reverse direction. Next, we sweep the features detection problems i.e. with optimized parameters, the features
with other two RNN where one is in the right direction and of the dataset prepared for testing are used as an input for the
the other is in the left direction. For each recurrent layer, the trained model and finally our trained model gives a decision.
hidden state is updated as,
IV. E XPERIMENTAL RESULTS
i,j = fv↑ (Zi,j−1 , pi,j )f orj = 1, 2, ..., J
uF F
(7) In this section, we are mentioning the details about the
dataset used for training and testing, the discussion of exper-
i,j = fv↓ (Zi,j+1 , pi,j )f orj = J, ..., 2, 1
uR R
(8)
imental results and the performance results of the model.
These two equations are for the first two RNN, where the A. Training and testing Data
second two RNNs also formulated accordingly. After the first
To train and test our model, we used the data from
two RNN and the second two RNN, we concatenate the
Apnea-ECG database which is freely available at https://
intermediate hidden states uF R
i,j and ui,j of the first two RNN physionet.org/physiobank/database/#ecg/ for download. Figure
and hi,j and hi,j of the second two RNN at each location (i, j)
F R
1 shows one of the apnea ECG recordings, that are visualized
to get a composite features map U, H ∈ R2d respectively. Now by the toolbox provided by https://physionet.org. The database
each of these vectors represent the feature of the original batch [23] has been developed for the Physio Net/Computers in
{pi,j } in the context of the whole extracted features. Cardiology Challenge 2000. It consists of 70 ECG recordings,
3) Data Normalization: After recurrent layer is followed by each normally 8 hours long, where 35 of them are only
sigmoid activation function, each feature map is normalized annotated.
for better performance. Assume that x = {x1 , ..., xd } is an For our model training, we divide the annotated 35 ECG
input to a layer with dimension d. Each dimension of x is recorded apnea signals into two categories. The first category
normalized by, is training set consisting of 20 ECG apnea recording signals
(xk − E(xk ))
x̂k = (9) that are normal and non-normal and the second category is
(var[xk ]) the testing ECG apnea signals. Also, the testing set consists
where E(xk ) is an expectation of xk and var[xk ] is the 10 ECG apnea signals which are normal and non-normal and
variance of xk and they are computed over the training data. both are not part of training set.
This type of normalization speeds up convergence [22] even After feature extraction is carried out for each dataset as in
when the features are not decorrelated. Normalizing each input equation (1), all ECG recordings are adjusted to 240x240
in the layer may sometimes change what really the layer values for training. As deep learning models are benefitted
should represent. To address this problem, the transformation from large training dataset, we perform data augmentation as
inserted in the network is chosen to be an identity transform. in [24], [25] which is then an input for the next model layer for
For this matter, a pair of parameters γk and βk for each xk the overall training process and optimized by [26]. The batch
scales and shifts the normalized value as: size is set to 64. We have trained the model for 50 epochs. The
learning rate is decayed exponentially from 0.01 to 0.0001 for
yk = γk x̂k + βk (10) the 50 epochs.
201
Authorized licensed use limited to: Seoul National University. Downloaded on December 05,2023 at 00:01:23 UTC from IEEE Xplore. Restrictions apply.
B. Performance Evaluation [7] M. O. Mendez, A. M. Bianchi, M. Matteucci, S. Cerutti and T. Penzel,
Sleep Apnea Screening by Autoregressive Models From a Single ECG
The effectiveness of our model is evaluated on different Lead, in IEEE Transactions on Biomedical Engineering, Vol. 56, No. 12,
records of ECG database. As a detection measure of our pp. 2838-2850, 2009.
[8] S. M. Isa, M. I. Fanany, W. Jatmiko and A. M. Arymurthy, Sleep Apnea
model, we compute the three commonly known performance Detection from ECG Signal: Analysis on Optimal Features, Principal
measures i.e. sensitivity (se), specificity (sp) and accuracy Components, and Nonlinearity, 5th International Conference on Bioin-
(ac) [27] , where they have the following definitions. formatics and Biomedical Engineering, pp. 1-4, 2011.
[9] C. Song, K. Liu, X. Zhang, L. Chen, and X. Xian, An Obstructive Sleep
OSAs Apnea Detection Approach Using a Discriminative Hidden Markov Model
se = × 100% (11) From ECG Signals, IEEE Transactions on Biomedical Engineering, 63(7),
(OSA)t
Vol. 63, No. 7, pp. 1532-1542, 2016.
N ORs [10] F. Jiang, B. Chen, S. Rho, et al. Optimal filter based on scale-invariance
sp = × 100% (12) generation of natural images. The Journal of Supercomputing, 2016,
(N OR)t 72(1): 5-23.
[11] M. Shokrollahi, S. Saha, P. Hadi, F. Rudzicz and A. Yadollahi,Snoring
OSAs + N ORs
ac = × 100% (13) Sound Classification from Respiratory Signal, 38th Annual International
(OSA)t + (N OR)t Conference of the IEEE Engineering in Medicine and Biology Society
(EMBC), pp. 3215-3218, 2016
Where ’OSAs ’ is the number of properly detected OSA [12] A. Hossen, A Neural Network Technique for Feature Selection and Iden-
signals, ’NORs ’ is the number of properly detected normal tification of Obstructive Sleep Apnea, Int.Con. on Biomedical Engineering
(NOR) signals, (OSA)t is a total OSA signal and (NOR)t and Informatics, pp. 182-186. IEEE, 2013.
[13] A. H. Khandoker, M. Palaniswami, S. Member, C. K. Karmakar,
is a total NOR signal tested [28]. Our experimental results and S. Member, Support Vector Machines for Automated Recognition
show that, the RNN based model detects OSA effectively and of Obstructive Sleep Apnea Syndrome From ECG Recordings, IEEE
provides up to 97.80% accuracy with the 50th training epoch. transactions on information technology in biomedicine, Vol. 13, No. 1,
pp. 37-48, 2009.
Our detection accuracy increases as we increase training [14] W. Zaremba and Ilya S., O. Vinyals Recurrent Neural Network Regu-
epochs from 20 to 50 in 10 increments. However, the model is larizationarXiv:1409.2329v5, 2015
not providing better accuracy values for more than 50 training [15] J. Feng, J. Xiaodong, H. Chunjing, L. Shaohui and Z. Debin, Com-
pressed Vision Information Restoration Based on Cloud Prior and Local
epochs. Prior Access, IEEE, 2014, 2: 1117-1127.
[16] A. Krizhevsky, I. Sutskever, and G. E. Hinton, ImageNet Classification
V. C ONCLUSION AND F UTURE WORK with Deep Convolutional Neural Networks, Adv. Neural Inf. Process.
Syst., pp. 1-9, 2012.
Effective and efficient obstructive sleep apnea detection [17] L. Almazaydeh, K. Elleithy, and M. Faezipour, Obstructive Sleep Apnea
model is proposed in this paper. The model used the advantage Detection Using SVM-Based Classification of ECG Signal Features,
of current success in deep neural networks on image and audio Annual International Conference of the IEEE, pp. 4938-4941, 2012.
[18] J. Feng, L. Bo, Y. Hongxun and L. Shaohui, Manifold learning and
recognition problems. An efficient RNN learning model based manifold alignment based on coupled linear projections, Chinese Journal
architecture having four layers is designed for OSA detection of CAAL Transactions on Intelligent Systems, vol. 5, no. 10, pp: 476-481
purpose. The ECG dataset is used for training and testing. (2011).
[19] C. Guilleminault, et.al., Cyclical variation of the heart rate in sleep
Experimental results show that the detection of OSA based apnea syndrome, mechanisms and usefulness of 24h electrocardiography
on recurrent neural network is more appropriate method than as a screening technique Lancet, pp. 126-13, 1984.
the traditional neural network based. Also, the accuracy of [20] W. Jifara , J. Feng, B. Zhang. et al., Hyperspectral image compression
based on online learning spectral features dictionary, Multi. Tools and
the model based on sensitivity and specificity values show the Appl (2017).
effectiveness of our model. [21] T. Penzel, G. Amend, K. Meinzer snd JH. Peter, A heart rate and snoring
In future work, we are considering OSA’s case and planning recorder for detection of obstructive sleep apnea Sleep, l3(2)pp. 175-182,
1990
to investigate the target problem with convolutional neural [22] S. Ioffe and C. Szegedy, Batch Normalization: Accelerating Deep
network, with accuracy, sensitivity, and specificity in mind. Network Training by Reducing Internal Covariate Shift, arXiv, 2015.
[23] T. Penzel, G. B. M. Rg, M. A. L. Goldberges, and H. Peter, The Apnea-
R EFERENCES ECG Database, Computers in cardiology, pp. 255-258, 2000.
[24] C. Dong, C. C. Loy, K. He, and X. Tang, Learning a deep convolutional
[1] J. A. Dempsey, S. C. Veasey, B. J. Morgan, and C. P. O. Donnell,
network for image super-resolution, Eccv, pp. 184-199, 2014.
Pathophysiology of Sleep Apnea, Physiological Reviews, Vol.90 No.1,
[25] K. He, X. Zhang, S. Ren, and J. Sun, Delving Deep into Rectifiers:
pp. 47-112. 2008
Surpassing Human-Level Performance on ImageNet Classification, IEEE
[2] W. T. Mcnicholas and M. R. Bonsignore, Sleep apnoea as an independent
Int. Conf. Comput. Vis., pp. 1026-1034, 2015.
risk factor for cardiovascular disease: current evidence, basic mecha-
[26] D. P. Kingma and J. L. Ba, Adam: a Method for Stochastic Optimization,
nisms and research priorities, ur Respir J., Vol. 29, No. 1, pp. 156-178,
Int. Conf. Learn. Represent., 2015.
2007.
[27] M. Kriboy, A.Tarasiuk, and Y. Zigel, Obstructive Sleep Apnea Detection
[3] S. Tregear, R. James, S. Karen and P. Barbara, Obstructive Sleep Apnea
Using Speech Signals,Proceedings of the annual conference of the Afeka-
and Risk of Motor Vehicle Crash: Systematic Review and Meta-Analysis,
AVIOS in Speech Processing. pp. 1-5, 2013
J Clin Sleep Med Vol. 5 No. 1, pp. 573-581, 2009.
[28] M. Al-Abed, M. Manry, J. R. Burk, E. A. Lucas and K. Behbehani,
[4] P. De Chazal, T. Penzel, and C. Heneghan, Automated detection of
A Method to Detect Obstructive Sleep Apnea Using Neural Network
obstructive sleep apnoea at different time scales using the electrocar-
Classification of Time-Frequency Plots of the Heart Rate Variability, 29th
diogram, Physiological measurement vol. 25, No. 4, pp. 967-983, 2004.
Annual International Conference of the IEEE Engineering in Medicine
[5] J. Feng, L. Chunwei, W. Hailiang and Z. Debin, Game theory based no-
and Biology Society, pp. 6101-6104, 2007.
reference perceptual quality assessment for stereoscopic images, Journal
of Supercomputing, Vol. 71, No. 9, pp: 3337-3352 (2015).
[6] M. Bsoul, H. Minn and L. Tamil, Apnea MedAssist: Real-time Sleep
Apnea Monitor, in IEEE Transactions on Information Technology in
Biomedicine, Vol. 15, No. 3, pp. 416-427, 2011.
202
Authorized licensed use limited to: Seoul National University. Downloaded on December 05,2023 at 00:01:23 UTC from IEEE Xplore. Restrictions apply.