Content uploaded by İbrahim Delibaşoğlu
Author content
All content in this area was uploaded by İbrahim Delibaşoğlu on Jul 07, 2021
Content may be subject to copyright.
ECG Based Sleep Apnea Detection Using Wavelet
Analysis of Instantaneous Heart Rates
İbrahim Delibaşoğlu1, Cafer Avcı2, Ahmet Akbaş3
Department of Computer Engineering
Yalova University
Yalova, Turkey
idelibasoglu@yalova.edu.tr1, cavci@acm.org2, ahmedakbas@gmail.com3
ABSTRACT
The time series of instantaneous heart rates (IHR) derived
from overnight sleep electrocardiography (ECG) are analyzed
by using wavelet decompositions. It is aimed to find a reliable
and practical way for detecting the minute by minute
occurrence of sleep-disordered breathing (SDB). The two sets
of single-lead ECGs extracted from polysomnography
recordings are obtained from PhysioNet apnea-ECG database.
Wavelet decompositions are implemented to the segments of 6-
minutes length IHR signals in which the 4th minute is accepted
as deciding minute for SDB. Results obtained from analysis of
the first set of the 35 recordings showed that variances of the
5th, 6th and 7th detail components of IHR time series can be
used as distinguishing features disclosing the minute-based real
time sleep apneas. Second set of the 35 ECG recordings is used
for testing this result. For this aim, a nonlinear autoregressive
(NARX) type artificial neural network (ANN) classifier is
configured and trained, by using the feature vectors obtained
from the first data set. Evaluations based on the assessment of
whole length of overnight sleep ECGs showed that
implementation of the NARX based classification following the
feature extraction with wavelet decompositions has success
level greater then %96.6 to decide on whether a subject is
apneic or non-apneic. The same approach has %83.4 and
%82.6 success level, respectively, referring to the minute-based
deciding on the first (learning) and second (test) data set.
Keywords
sleep apnea; ecg; ihr; disordered breathing; sdb
1. INTRODUCTION
SDB describes a group of disorders characterized by
abnormalities of respiratory pattern or the quantity of
ventilation during the sleep. It has two main categories:
obstructive sleep apnea (OSA) and central sleep apnea (CSA).
Some SDB subjects have a combination of both: mixed sleep
apnea. If there is a shallow breathing disorder but not complete
cessation of airflow, generally smaller than 50% of normal, the
episode is called hypopnea [1].
The first category of SDB, OSA, is characterized by repetitive
pauses caused by a physical block to airflow in breathing.
Entering the air to the lungs is prevented due to the temporary
closure of upper airway. In this case, the signs, symptoms, and
consequences are direct result of the repetitive collapse of the
upper airway. Some of them are sleep fragmentation,
hypoxemia and hypercapnia [2]. The second category, CSA, is
characterized by a lack of respiratory effort managed by the
central nervous system. In this case, the brain's respiratory
control centers are imbalanced during sleep. The carbon
dioxide level of blood and the neurological feedback
mechanism monitoring it do not react quickly enough to
maintain respiratory rate. After the episode of stopping breath,
as a compensatory mechanism, breathing may be faster for a
period of time to absorb more oxygen [3].
Traditionally SDBs are evaluated by the sleep studies. These
studies are carried out by taking the overnight
polysomnography records consisting of the multiple physiologic
variables including electromyography (EMG) and some
respiratory signals. Disordered breathing and its effects on
sleep can be exactly quantified by this way. However, sleep
studies are expensive and frustrate for SDB subjects, because
of that subjects must be stayed in sleep laboratories over a
night with intense hardware connections of polysomnography.
On the other hand, besides their own problematic situation
SDBs might cause various other health problems, such as heart
failure and stroke which are more common in people having
CSA (1). Therefore, real-time detection of SDBs can help
taking precautions against important health problems that
might be caused by SDBs. An easy implemented hardware,
such as single-lead ECG holter, can be used for this aim. Real
time SDB decisions can be extracted from such a system by
using various signal analyzing methods.
For instance, appealing to the fact that the low-frequency
oscillation in the frequency spectrum of the IHRs indicates the
variability of respiratory rates. Therefore frequency content of
the IHR time series can give supporting data for SDB analysis.
As a consequence of this tendency Sleep Scoring Manual now
includes the scoring of a continuous-lead ECG as a
recommended component of polysomnography [4].
In the context of ECG based study, the cyclical variation in IHR
was described as being characteristic of OSA, in 1984 [5]. This
was applied to the detection of sleep apnea by few groups [6, 7,
8]. Chazal et. al. [9] studied the presence of major sleep apnea
Permission to make digital or hard copies of all or part of this work for
personal or classroom use is granted without fee provided that copies are
not made or distributed for profit or commercial advantage and that copies
bear this notice and the full citation on the first page. To copy otherwise, to
republish, to post on servers or to redistribute to lists, requires prior specific
permission and/or a fee.
ISABEL '11, October 26-29, Barcelona, Spain Copyright©
2011 ACM ISBN 978-1-4503-0913-4/11/10... $10.00
by analyzing the ECG derived respiratory signal (EDR)
obtained from ECG recordings. Subjects were classified as
apneic or normal, however, minute-based diagnosis was not
carried out in this study. Similar approach using the wavelet
based features of ECG has been used in another study [10].
For minute-based real time detection of apnea episodes
Babaeizadeh et.al [11] implemented spectral analysis of the
power spectral density (PSD) on the 6-minutes length of ECG
recordings by using the Lomb’s method [12]. Similar analysis
has been implemented in this study by using the wavelet
decompositions of the time series of IHRs derived from the
overnight sleep ECG. A NARX type ANN based classifier has
been configured and trained for this aim.
2. MATERIAL & METHODS
Single-lead ECG recordings used in this study have been
obtained from apnea-ECG databank of PhysioNet which is a
web-based library of physiologic data and analytic software
sponsored by the US National Institutes of Health [13]. The
time series of estimated IHRs have been determined for all of
the subjects in given data sets.
2.1 Data
PhysioNet apnea-ECG databank includes freely accessible
overnight ECG recordings extracted from polysomnogram
measurements. It is provided by Philipps University, Marburg,
Germany, and divided into two data sets each containing 35
recordings: the learning and test data sets. Each set includes 20
apnea subjects, 10 control subjects and 5 borders subjects.
The subject codes in the first data set are a01-a20 for apnea
subjects, b01-b05 for border subjects, and c01-c10 for control
subjects. For the second data set the subject codes are between
x01 and x35. Each ECG signal in database is sampled at a rate
of 100 samples per second with an amplitude resolution of 5
μV. Duration of the recordings for each subject varies between
401 and 578 minutes. The subjects are between 27 and 63
years of age with weights between 53 and 135kg.
The database includes the standard apnea annotations done by
an expert who visually scored each minute of each recording for
sleep apnea events on the basis of respiration and oxygen
saturation signals using amplitude criteria for airflow and de-
saturation. An epoch is classified as apneic if apnea was in
progress at the beginning of the associated minute; otherwise, it
is classified as non-apneic (normal). By counting the number of
apnea events over a given period of time (e.g., a night's sleep)
and averaging these counts on a per-hour basis leads to
commonly used standards such as the apnea/hypopnea index
(AHI) [14].
Subjects in the PhysioNet database are classified into three
classes: A, B, and C. Recordings in class A (OSAS+) contain at
least 1 h with an AHI of 10 or more, and at least 100 min with
apnea during the recording. There are 40 recordings in this
class. Recordings in class B (borderline) contain at least 1 h
with an AHI of five or more, and between 5 and 99 min with
apnea during the recording. There are 10 recordings in this
class. We have excluded 10 recordings of class B from the
analysis in this study for subject-based diagnosis but all
recordings were analyzed for minute-based apnea detection.
2.2 Obtaining the Time Series of IHRs
At the end of each minute, estimated time series of IHRs have
been calculated over the last 6-minutes length of ECG. For this
aim, we used the ready C-code for IHR calculation in the
PhysioNet web site [15]. For the wavelet decompositions,
homogeneous time series of IHRs have been produced by a 2
Hz re-sampling process following the FFT-interpolation.
Wavelet decompositions have been applied to the segments of
6-minutes length IHR signals in which the 4th minute has been
accepted as apnea deciding minute.
The two 6-minutes length of ECG segments and their
corresponding homogeneous time series of IHRs with
indication of minute-based ‘N’ (non-apneic) and ‘A’ (apneic)
markings are shown in Figure 1 and Figure 2, respectively.
Figure 1. A 6-minutes length ECG and corresponding IHRs
with markings ‘N’
Figure 2. A 6-minutes length ECG and corresponding IHRs
with markings ‘A’
2.3 Feature Extraction by Wavelet Analysis
Wavelet is suitable for the analyses of non-stationary signals.
Because there is no prerequisite regarding the stability of the
frequency content along the signal analyzed. For a given signal
x(t), wavelet decomposition is given as follows:
(1)
Here cN,k represents approximation coefficients at level N,
while dj,k (j=1,….., N) represents detail coefficients or wavelet
coefficients at level j. ψ(t) is the wavelet function, while ϕ(t) is
a companion function, named scaling function [16].
Decomposed signals include the detail and approximation
components. IHR signal has been decomposed into 8-levels of
signals (a1 to a8, and d1 to d8) using Daubechies order 3 (db3)
wavelet transformation. After splitting we have obtained the
variances of 6-minutes length of detail components for all 8-
levels, over the 35 recordings of the first data set. The mean of
the variances have been calculated for each detail components.
Table 1 includes the calculated mean variances for all subjects
of first data set (a01-a20, b01-b05, c01-c10).
Table1. The mean variances of 8-levels detail components
and average variances for the subject groups (a, b, c) of
first data set
mean variance
sub.
d1
d2
d3
d4
d5
d6
d7
d8
a01
0,13
2,48
3,71
6,94
13,96
15,98
10,49
3,91
a02
0,12
0,42
0,75
2,47
6,16
6,90
5,84
4,63
a03
0,12
1,08
2,00
3,07
8,21
14,82
3,85
2,60
a04
0,10
0,61
0,68
1,92
7,20
14,11
2,39
1,11
a05
0,08
0,69
1,31
1,65
3,79
6,17
5,62
2,27
a06
0,08
0,85
1,64
1,76
2,22
3,53
3,43
2,44
a07
0,29
2,55
5,50
8,73
13,20
10,39
8,74
7,97
a08
0,24
0,65
0,98
2,97
6,68
8,50
3,88
2,08
a09
0,05
0,34
0,20
0,70
1,68
2,38
2,82
1,80
a10
0,08
0,51
1,82
1,86
2,51
4,55
3,93
2,75
a11
0,22
1,19
0,88
1,44
1,94
1,65
1,43
1,65
a12
0,07
0,60
1,02
2,48
7,60
11,10
2,88
1,55
a13
0,21
0,69
1,18
3,62
7,73
11,10
4,31
2,76
a14
0,09
2,26
3,47
4,87
8,83
9,42
7,66
4,59
a15
0,07
0,39
0,78
2,21
8,33
11,15
5,74
3,31
a16
0,22
1,40
2,60
4,70
9,10
9,11
5,51
4,47
a17
0,28
1,84
4,42
4,25
6,50
6,03
3,07
1,67
a18
0,04
0,26
0,18
0,58
1,46
1,68
1,62
0,72
a19
0,10
0,27
0,50
1,18
3,11
5,11
1,44
0,85
a20
0,14
0,72
1,23
1,48
3,24
3,86
3,09
1,01
avg.
0,14
0,99
1,74
2,94
6,17
7,88
4,39
2,71
b01
0,24
1,47
2,61
3,45
4,76
5,89
5,26
4,69
b02
0,05
0,23
0,45
1,45
4,07
4,95
1,99
1,47
b03
0,05
0,24
0,41
1,23
3,87
4,52
1,78
1,16
b04
0,12
1,58
2,55
4,50
4,15
4,22
3,84
2,92
b05
0,08
0,96
3,24
3,24
3,11
4,50
5,08
4,63
avg.
0,11
0,89
1,85
2,77
3,99
4,82
3,59
2,97
c01
0,12
1,61
4,06
4,38
2,95
3,02
4,31
2,00
c02
0,21
0,75
0,73
0,97
1,34
2,32
3,21
2,16
c03
0,09
2,57
5,90
6,09
4,10
4,57
4,75
4,27
c04
0,02
0,62
1,73
1,76
1,84
2,09
2,46
2,78
c05
0,09
1,07
2,88
2,40
2,00
2,23
2,55
1,97
c06
0,09
1,05
2,91
2,39
2,05
2,18
3,04
1,63
c07
0,17
0,77
2,20
3,65
3,25
3,31
3,73
2,64
c08
0,07
1,09
2,40
5,10
4,53
4,01
5,08
4,00
c09
0,14
0,51
0,81
1,32
1,48
2,23
3,13
2,14
c10
0,06
0,93
2,43
2,12
2,60
3,85
3,15
3,46
avg.
0,11
1,10
2,61
3,02
2,61
2,98
3,54
2,70
Average variances of detail components are given at the end of
each group for apnea (a), border (b) and control (c) subjects in
Table 1. These are also plotted in Figure 3. It is clear from the
Figure 3 that the variances of the 5th, 6th and 7th detail
components can be used as distinguishing features disclosing
the minute-based real time sleep apneas.
2.4 Classification
It has been used a tree-layer NARX type ANN model as the
classifier. It has an input layer with 6 neurons, a hidden layer
with 3 neurons, and an output layer with one neuron. Number
of inputs and output are 3 and 1, respectively.
The input layer (or first hidden layer) collects the weighted
values of the actual and previous inputs, and weighted values of
the first and second previous output. The transfer functions are
chosen as tan-sigmoid function for all the nodes. Figure 4
shows the MATLAB configuration of the NARX classifier [17].
Figure 3. Average variances of detail components for the
subject groups
Figure 4. MATLAB configuration of NARX type ANN
classifier
For the training process it is used the Levenberg-Marquardt
error backpropagation training algorithm (trainlm) with
adaptive learning function (leangdm). Training time is reduced
by using the adaptive learning function, which attempted to
keep the learning step size as large as possible, while keeping
the learning stable. Data division for the training process is
carried out automatically by a random process. Mean square
error (MSE) algorithm is selected as the performance function,
so that training automatically stops when generalization stops
improving, as indicated by an increase in the MSE of the
validation samples. In the output stage, the aim is to assign the
input patterns to one of the two classes: apneic (‘A’ or ‘1’) and
non-apneic (‘N’ or ‘0’).
Minute-based feature vectors derived from the learning and test
data sets have been used for training process. However, for the
testing process, both the learning and test data sets have been
used for evaluation of the trained NARX classifier.
3. RESULTS
Feature vectors were extracted from the time series of IHRs
through the minute-based epochs of the learning and test data
sets. Totally 16810 feature vectors have been obtained from
annotations of the learning data set. This was 17038 for test
data set. The NARX type ANN has been trained by using the
learning data set with its corresponding outputs which are
annotated originally. Border subjects have been excluded for
the training process. Trained network has been used to classify
the two data sets. The classification results due to the obtained
minute-based correct epoch numbers related to learning and
test data sets are given in Table 2. The total numbers of
correctly classified epochs are 14007 and 14070, respectively
for learning and test data sets. Subject-based evaluations have
been carried out by using the AHI implementation of the
obtained results. Subject-based evaluation results are given in
Table 3.
Due to the results given in Table 3, the number of correctly
classified subjects are 19 for apneic and 10 for non-apneic
classes, while they are 20 and 10 due to the annotations.
Therefore, resulting accuracy depending on the subject-based
classification is %96.66 for learning set and %100 for test set.
Table 2. Minute-based classification results for learning and test data sets
Data set
Number of correctly classified
epochs
Number of annotated epochs
Total number of epochs
Accuracy
apneic
non-apneic
apneic
non-apneic
correctly
classified
annotated
learning
4679
9328
5703
11107
14007
16810
%83,33
test
4787
9283
6044
10994
14070
17038
%82,58
Table 3. Subject-based classification results for learning and test data sets
Data set
Number of correctly classified
subjects
Number of annotated subjects
Total number of subjects
Accuracy
apneic
non-apneic
apneic
non-apneic
correctly
classified
annotated
learning
19
10
20
10
29
30
%96,66
test
20
10
20
10
30
30
%100
4. DISCUSSION AND CONCLUSIONS
In this study, the time series of IHRs derived from overnight
sleep ECGs have been analyzed. Homogenous time series of
IHRs have been produced by a process of 2 Hz re-sampling
following the FFT-interpolation. Wavelet decompositions have
been implemented to the segments of 6-minutes length IHR
signals in which the 4th minute has been accepted as deciding
minute for SDB. Results obtained from analysis of the first set
of the 35 ECG recordings showed that variances of the 5th, 6th
and 7th detail components of IHR time series can be used as
distinguishing features disclosing the minute-based real time
sleep apneas. Second set of the 35 ECG recordings is used for
testing this result. However, 5 recordings with borderline apnea
were excluded for learning and evaluation data sets. A NARX
type ANN classifier is configured and trained, by using the
feature vectors obtained from the learning data set. Evaluations
depending on assessment of the whole length of overnight sleep
ECGs showed that implementation of the NARX classification
following the feature extraction with wavelet decompositions
has success level greater then %96.6 to decide on whether a
subject is apneic or non-apneic. The same approach has %83.4
and %82.6 success level, respectively, referring to the minute-
based deciding on the learning and test data sets.
As a result of this study we can conclude that the minute-based
implementation of NARX classifier following the wavelet
decomposition of a IHR time series extracted from single-lead
ECG recording can be sufficiently used to decide the minute-
based real time occurrence of SDBs.
5. REFERENCES
[1] Somers V.K., White, D.P., Amin, R. , 2008, Sleep apnea
and cardiovascular disease: an American Heart
Association/American College of Cardiology Foundation
scientific statement from the American Heart Association
Council for High Blood Pressure Research Professional
Education Committee, Council on Clinical Cardiology,
Stroke Council, and Council on Cardiovascular Nursing.
In collaboration with the National Heart, Lung, and Blood
Institute National Center on Sleep Disorders Research
(National Institutes of Health). American College of
Cardiology Foundation Circulation, pp.118-1080.
[2] Epstein, L.J., Kristo, D., Strollo, P.J. , 2009, Clinical
guideline for the evaluation, management and long-term
care of obstructive sleep apnea in adults. J Clin Sleep
Med., pp.5-263.
[3] www.wikipedia.org , visited at the date 01.07.2011
[4] Caples, S.M, Somers, V.K, Rosen, C.L. , 2007, The
scoring of cardiac events during sleep. J Clin Sleep Med
,pp.3-147.
[5] Guilleminault, C., Connolly, S., Winkle, R., Melvin, K.,
Tilkian, A. , 1999, Cyclical variation of the heart rate in
sleep apnoea syndrome. Mechanisms, and usefulness of
24 h electrocardiography as a screening technique. Lancet,
pp.1-126.
[6] Roche, F., Gaspoz, J.M., Court-Fortune, I. ,1999,
Screening of obstructive sleep apnea syndrome by heart
rate variability analysis. Circulationpp.100-1411.
[7] Penzel, T., Amend, G., Meinzer, K., Peter, J.H. ,1990,
VonWichert P. ,Mesam. A heart rate and snoring recorder
for detection of obstructive sleep apnea. Sleep pp.13-175.
[8] Hilton, M.F., Bates, R.A., Godfrey, K.R., Chappell, M.J.,
Cayton, R.M. , 1999, Evaluation of frequency and time-
frequency spectral analysis of heart rrate variability as a
diagnostic marker of the sleep apnoea syndrome. Medical
and Biological Engineering and Computing 37 pp.760–
769.
[9] Chazal, P., Heneghan, C., Sheridan, E., Reilly, R., Nolan,
P. and O’Malley, M. , 2003, Automated Processing of the
Single-Lead Electrocardiogram for the Detection of
Obstructive Sleep Apnea. IEEE Transactions on
Biomedical Engineering, Vol.50, No.6, pp. 686-696
University College Dublin, Ireland.
[10] Khandoker, A. H., Karmakar, C.K., Palaniswami, M.,
2009, Automated recognition of patients with obstructive
sleep apnoea using wavelet-based features of
electrocardiogram recordings . Computers in Biology and
Medicine 39 pp. 88 – 96.
[11] Babaeizadeh, S., White, D.P., Pittman, S. D., Zhou, H.
,2010, Automatic detection and quantification of sleep
apnea using heart rate variability. Journal of
Electrocardiology 43 pp.535–541.
[12] Lomb, N.R. ,1976, Least-squares frequency analysis of
unequally spaced data. Astrophysics and Space Science
pp.39-447.
[13] www.physionet.org , visited at the date 01.07.2011
[14] Ruehland, W.R., Rochford, P.D., O'Donoghue, F.J.,
Pierce, R.J., Singh, P., Thornton, A.T. ,2009, The new
AASM criteria for scoring hypopneas: impact on the apnea
hypopnea index. PubMed Central Journals, Sleep 32 (2)
pp. 150–157.
[15] http://www.physionet.org/physiotools/wfdb/app/ihr.c ,
visited at the date 01.07. 2011
[16] Ebrahimi, F., ,Mikaeili, M., Estrada, E., Nazeran, H.
,2008, Automatic sleep stage classification based on EEG
signals by using neural networks and wavelet packet
coefficients. 30th Annual International IEEE Conference,
Vancouver, British Columbia, Canada, pp.1151-1154.
[17] MATLAB version 7.12.0.635 (2011a).