Algorithms 17 00527
Algorithms 17 00527
Article
Sleep Apnea Classification Using the Mean Euler–Poincaré
Characteristic and AI Techniques
Moises Ramos-Martinez 1 , Felipe D. J. Sorcia-Vázquez 1 , Gerardo Ortiz-Torres 1 , Mario Martínez García 1 ,
Mayra G. Mena-Enriquez 2 , Estela Sarmiento-Bustos 3 , Juan Carlos Mixteco-Sánchez 4 ,
Erasmo Misael Rentería-Vargas 1 , Jesús E. Valdez-Resendiz 5, * and Jesse Yoe Rumbo-Morales 1
Abstract: Sleep apnea is a sleep disorder that disrupts breathing during sleep. This study aims to
classify sleep apnea using a machine learning approach and a Euler–Poincaré characteristic (EPC)
model derived from electrocardiogram (ECG) signals. An ensemble K-nearest neighbors classifier
Citation: Ramos-Martinez , M.; and a feedforward neural network were implemented using the EPC model as inputs. ECG signals
Sorcia-Vázquez, F.D.J.; Ortiz-Torres, were preprocessed with a polynomial-based scheme to reduce noise, and the processed signals were
G.; Martínez García, M.; Mena- transformed into a non-Gaussian physiological random field (NGPRF) for EPC model extraction from
Enriquez, M.G.; Sarmiento-Bustos, E.; excursion sets. The classifiers were then applied to the EPC model inputs. Using the Apnea-ECG
Mixteco-Sánchez, J.C.; Rentería-
dataset, the proposed method achieved an accuracy of 98.5%, sensitivity of 94.5%, and specificity
Vargas, E.M.; Valdez-Resendiz, J.E.;
of 100%. Combining machine learning methods and geometrical features can effectively diagnose
Rumbo-Morales, J.Y. Sleep Apnea
sleep apnea from single-lead ECG signals. The EPC model enhances clinical decision-making for
Classification Using the Mean
evaluating this disease.
Euler–Poincaré Characteristic and AI
Techniques. Algorithms 2024, 17, 527.
https://doi.org/10.3390/a17110527
Keywords: sleep apnea; Euler characteristic; machine learning; random field
unfeasible and extremely expensive for a large population. Some alternative methods
were developed using single ECG signals and machine learning techniques to diagnose
OSA problems.
Studies, including [8–10], have demonstrated the capability of ECG signals to identify
respiratory events. Furthermore, research results such as in [11,12], indicate that heart
rate variability (HRV) signals can be used to measure and detect apnea events. Atrial
fibrillation (AF) is widely related to OSA problems, as mentioned in [13,14], where the
authors conducted questionnaires and home sleep studies to check this relation.
Researchers have explored two approaches to detect sleep apnea events in the litera-
ture: feature engineering-based techniques and deep learning-based methods. In the first
category, the ECG signal is analyzed, and different features are extracted from the P-wave
(atrial depolarization), QRS complex (ventricular depolarization), and T-wave (ventricular
repolarization), which reflect different cardiac cycle phases. For example, Babaeizadeh et al.
presented a cost-effective, noninvasive algorithm for detecting sleep apnea using single-
lead ECG. By analyzing heart rate variability and QRS complexes, the algorithm accurately
classifies apnea episodes, achieving 84.7% accuracy and demonstrating high potential for
sleep medicine applications [15]. Yilmaz explored the utility of using a single-lead ECG to
determine sleep stages and detect OSA across 30-s epochs throughout the night, potentially
replacing more complex polysomnography systems. Data from 18 subjects, including
10 diagnosed with OSA, revealed promising results: support vector machines (SVMs) and
quadratic discriminant analysis (QDA) achieved over 82% accuracy in classifying sleep
stages and around 88% in detecting OSA. Using the RR-interval (time interval between two
successive R-peaks in an ECG), three features were extracted, resulting in high classification
performance. This suggests that single-lead ECG, combined with SVM or QDA, could
effectively monitor sleep and OSA. However, integrating additional physiological features
could further enhance accuracy [16]. Zarei et al. described an algorithm that detects sleep
apnea using ECG features and a combined convolutional neural network (CNN) and long
short-term memory (LSTM) recurrent network [17]. Using the same combination of net-
works, we looked at the work by Bahrami and Forouzanfar [18], which reported accuracy,
sensitivity, and specificity of 88.13%, 84.26%, and 92.27%, respectively.
Feature extraction using machine learning (ML) methods was employed to detect OSA
events. In the study by Pant et al. [19], wavelet transform was used to extract features from
the sub-bands and classify them using various ML methods. In the work of Yang et al., the
HRV analysis and ECG-derived respiration (EDR) were used to extract complementary
information using a residual group network [20]; their results had an accuracy of 90.3%, a
sensitivity of 87.6%, and a specificity of 91.9%. Liu et al. demonstrated a CNN that learned
features from the ECG, reaching a sensitivity of 88.2% in classification [21].
Instead of relying on an overall diagnostic analysis of the entire biomedical signal,
certain studies focus on determining if a patient is experiencing apnea by analyzing specific
indicators. One approach measures the variation in oxygen saturation over a short inter-
val (12 s) [22,23]; other indicators include non-linear methods mentioned in [24]. Maier
et al. used Holter-ECG to screen for sleep-disordered breathing (SDB) by comparing it
with nocturnal polygraphy (PG) in 50 cardiology patients. The ECG estimates demon-
strated strong agreement with PG, exhibiting high specificity (0.96) and good sensitivity
(0.77) for detecting significant SDB, promising an effective, cost-efficient method for SDB
screening [25].
Some studies have adopted an approach of using fragments of the signal, such as
analyzing it minute by minute [26] or using windows of varying sizes [27], to identify
occurrences of apnea instead of making an overall diagnosis of OSA, which is generally
regarded as the responsibility of physicians.
Various biomedical signals are utilized for the classification and diagnosis of OSA. For
instance, the photoplethysmography signal ([28], the S p O2 signal [24,29,30], the oronasal air
flow signal [31], the ECG signal [23,26], and so on. These works use techniques that involve
Algorithms 2024, 17, 527 3 of 22
RR variability [26,32,33], frequency domain features using wavelet transform [29,34], and
machine learning techniques as neural networks [17,29,34–36], and so on.
Artificial intelligence models currently play a huge role in medicine, especially artificial
neural networks, which have been used for the classification and detection of diseases
such as diabetes [37], heart diseases [38], chronic kidney disease [39], and in oncological
diagnostics [40]. Due to the efficiency and utility of these tools, we use neural networks in
this work.
Our study makes significant contributions to the field of ECG analysis by introducing
an innovative algorithm that integrates geometric models as features and inputs for AI
models, specifically designed to classify and detect sleep apnea and heart diseases. This
algorithm leverages geometric features that closely match the behavior of the ECG, enhanc-
ing the accuracy of classifications. We ensure relevance and continuity in ECG research by
addressing the challenges posed by limited and imbalanced datasets and aligning our work
with historical benchmarks established in the 2000 challenge [41] using the Apnea-ECG
database [42]. Overall, this comprehensive approach not only deepens our understanding
of ECG signal behavior but also lays the groundwork for future studies involving larger and
more balanced datasets, ultimately improving diagnostic capabilities and patient outcomes.
Existing OSA detection methods often rely on handcrafted features and struggle to
achieve high accuracy with single-lead ECG signals. To address these limitations, this article
introduces a novel algorithm that uses random algebraic polynomials (RAP) for signal
smoothing and creates a non-Gaussian physiological random field (NGPRF) to capture
intricate, non-Gaussian ECG features. This innovative framework models critical ECG
peaks (P-waves, QRS-complex, T-waves) and extracts their geometrical characteristics as
Euler–Poincaré characteristics (EPCs). By capturing unique geometrical forms in the ECG
signal, the EPCs provide robust inputs to our classification system. Unlike conventional
approaches, we integrate these advanced geometric descriptors with machine learning
classifiers, including ensemble K-nearest neighbors (EKNN) and feedforward multi-layer
neural networks (FNNs), to significantly improve OSA detection accuracy. This novel
combination of RAP-based signal processing and advanced classification methods bridges
existing gaps, making single-lead ECG-based OSA detection more accurate and potentially
adaptable for real-time and diverse clinical applications.
This article is organized as follows: In Section 2, we describe the mathematics involved.
In Section 3, we describe the data used. In Section 4, we discuss the methodology applied
to the cases. Then, in Section 5, we present the results and discussion. Finally, a conclusion
and future works are provided in Section 6.
2. Mathematical Framework
This section can help one understand the main steps of the methodology mentioned
in [43].
2.1. Polynomization
The first step of the method involves pre-processing to smooth the signal. In this step,
we model the ECG signals using RAP to reduce noise and construct the NGPRF. RAP is
denoted by φ(X, ξ ), for an ECG cycle j from 1 to N. The elemental waves in the ECG are
P-waves, QRS complex, and T-waves. In this case, each cycle is divided by a threshold R( j),
resulting in two intervals: I1 = [1 R( j)] and I2 = [ R E( j)], with E(j) representing the final
index in each cycle. Additionally, we define the RAP of order D representing the P-waves,
as follows:
D
φ B (S , Ω, X ( j)) = ∑k=0 ak ( j, Ω)X ( j)k , (1)
where S = (Ω, F , P ) represents a complete probability space, Ω denotes the sample space,
F denotes the σ-algebra of events, and P denotes the probability measure on F . Moreover,
ak ( j, ω̄ ) denotes a sequence of independent and identically distributed random variables
Algorithms 2024, 17, 527 4 of 22
for each cycle. The selected interval includes both the R-peak and the P-wave, represented
as X ( j) = [1, R( j)], where R( j) indicates the index of the R-peak.
with φ B (S , ξ̄, X ( j)) as the random polynomial that represents the ECG behavior, and δ is
the Dirac’s distribution. According to Equation (2), polynomials φ B (S , ξ̄, X ( j)) are used to
decompose each ECG signal at a fixed point into an NGPRF in the coordinate X2 .
Aλ (θ, D) = {X ∈ D , θ (X , ξ ) ≥ λ} (3)
ξ j (h) = sup θ̇ j (X , ξ ) − θ̇ j (Y , ξ ) ,
∥X −Y ∥<h,ξ
and
ξ jk (h) = sup θ̈ jk (X , ξ ) − θ̈ jk (Y , ξ ) ,
∥X −Y ∥<h,ξ
respectively.
To ensure that the realizations of θ (X , ξ ) are sufficiently smooth, the following condi-
tions must be met:
• C1 : The maximum of ξ j (h) and ξ jk (h) should be asymptotically negligible, specifically
o (h N ), as h → 0.
• C2: The Hessian θ̈ of θ̇ jk must have a finite variance conditional on θ, where θ̇ is the
gradient of θ̇ j .
• C3: The densities of θ and θ̇ must be uniformly bounded for all X ∈ D .
At a boundary point X on ∂D :
• θ̇⊥ is the gradient of θ in the direction perpendicular to ∂D .
• θ̇D is the gradient in the tangent direction within the plane of ∂D .
• θ̈D denotes the 1 × 1-Hessian matrix in the tangent plane.
• r is the 1 × 1 matrix representing the internal curvature of ∂D .
Using the sign function, denoted as sign, and following Knuth’s notation [44], which
assigns a value of 1 to a true expression in parentheses, and 0 if false, the EPC is then given
by the following:
with a probability of one. In R2 , integral geometry characterizes φ(Aλ (θ, D)) as the differ-
ence between the count of connected components and the number of voids in Aλ (θ, D).
Moreover, the expected value of φ(Aλ (θ, D)) over multiple realizations is as follows:
Z
E{Ψ(Aλ (θ, D))} = E{(θ ≥ λ) det(−θ̈)|θ̇ = 0} β(0)dX
D
Z (8)
+ E{(θ ≥ λ)(θ̇⊥ < 0) det(−θ̈D − θ̇ ⊥ r )|θ̇D = 0} × β D (0)dX ,
∂D
where β(.) is the density of θ̇ and β D (.) is the density of θ̇D . It is shown that, under the
condition that the boundary of D consists of a finite number of piecewise filtered segments,
the expected value of the excursion set of a mean-zero, unit-variance random field is given
by the following:
N
E{Ψ(Aλ (θ, D))} = ∑ ρ j (λ)L j (D) (9)
j =0
where ρ j (λ) = (2π )−( j+1)/2 Hj−1 (λ) exp(−λ2 /2) is the intensity of the EPC per unit volume,
Hj denotes the j − th Hermite polynomial, and L j (D) represents the Lipschitz–Killing
curvatures.
Algorithms 2024, 17, 527 6 of 22
3. Data Used
The Apnea-ECG database [42] was used in this study. It contains 70 records, divided
into two groups: a training set of 35 records, including 20 severe cases, 5 mild cases, and
10 non-apnea cases, and a validation set consisting of the remaining 35 records. All ECG
signals in the dataset are annotated with QRS complexes. The data are derived from a
population aged between 27 and 60 years, with all records digitized at 100 samples per
second. The length of the records ranges from 7 to 10 h.
4. Methodology
Figure 1 represents the proposed methodology used for classifying sleep apnea. The
methodology consists of the following five steps:
1. Pre-processing: As part of this step, the ECG signals were filtered using random
polynomials. This process is referred to as polynomization.
2. Random field transformation: The filtered signal was used to build the NGPRF,
collapsing c number of cycles into a geometric structure.
3. Geometrical property: Each NGPRF was sectioned at several levels, denoted by λ,
known as excursion sets.
4. Feature extraction: For each excursion set, a value was calculated that represented the
difference between the number of connected components and the number of holes,
capturing key aspects of the set’s geometric structure. This feature is referred to as the
Euler–Poincaré characteristic.
5. Classifier selection: An EKNN model is proposed to classify OSA from the EPC
models. The training dataset was used for learning, and the test dataset was used to
validate the model. Also, a feedforward multi-layer neural network is proposed for
the binary classification.
Figure 1. Methodology to classify sleep apnea. The first stage involves the data or ECG. The second
stage involves pre-processing, where the ECG is cleaned. The third stage involves random field
conversion. The fourth stage focuses on geometrical properties, where the excursion set is obtained.
The fifth stage is feature extraction. Finally, the last stage involves selecting a classifier model (EKNN,
SVM, FNN) to differentiate between an apnea patient and a non-apnea patient.
Algorithms 2024, 17, 527 7 of 22
4.1. Pre-Processing
The pre-processing stage is referred to as ‘polynomization’, and was dealt with as
follows. First, the ECG cycle was divided into two interval parts, as our focus was on the
part containing the P-waves and R-peaks, only one interval was selected. The function for
this process is presented in (1).
We identified the R-peaks using the Pan–Tompkins algorithm [45] to achieve this
objective. Afterward, we split the ECG cycle from R-peak to R-peak using the middle
points, mk , and a fixed threshold. Each ECG cycle preserved the main waves, i.e., P,
Q, R, S, and T. Every cycle Nj was segmented two sections, P1 (C ) = [mk Rk+1 ], and
P2 (C ) = [ Rk+1 mk+1 ]. Upon completion of the process, the result was in the form of
polynomials that correspond to the appropriate order D. In these cases, we only used the
P1 (C ) polynomials.
We assessed the normalized root mean square error (NRMSE) using Equation (10) to
identify the optimal order of the random polynomials that best approximated the data.
D (C )
P1 (C ) − ∑k=1 0 âk (k, ω̄ ) X j (k)k
FIT = 1001 − (10)
∥ P1 (C ) − P̄1 (C )∥
where P1 (C ) represents the section of the ECG containing the P-waves and R-peaks, P̄1 (C ) is
the mean of each interval P1 , and the inverse of the Vandermonde matrix is used to calculate
the vector of estimated coefficients âk [46]. Our goal is to find the maximum FIT based on
NRMSE. To do this, we evaluate a group of samples (100,000) from each of the 35 patients
for the training set using polynomial orders ranging from 15 to 25 (D1 (c) = 15, . . . , 25).
To calculate the order of polynomials for the sections of the ECG from the R-peaks to the
T-waves, we used Equation (10), and instead of P1 (C ), we used P2 (C ). Also, we used
the integral absolute error (IAE) criterion. The results for P1 (C ) and P2 (C ) are shown in
Figure 2a,b with both criteria.
(a) (b)
Figure 2. Polynomial order results for the sections of the ECG; sections P1 (C ) and P2 (C ). (a) His-
togram of the polynomials of P-waves (blue) and T-waves (red) using FIT (Equation (10)). (b) His-
togram of the polynomials of P-waves (blue) and T-waves (red) using the IAE criterion.
The optimal polynomial order is 15 according to the FIT criterion and 21 based on the
IAE criterion. It is later shown that the order of the polynomials significantly influences the
final results, particularly during the classification process. Algorithm 1 shows the entire
procedure used for selecting the orders and obtaining the polynomials P1 (C ) and P2 (C ).
However, we only use the P-wave polynomials P1 (C ) in the following steps.
Algorithms 2024, 17, 527 8 of 22
Figure 3. Random field of the P-waves, Q-peaks, and R-peaks in a short number of cycles (100).
To ensure homogeneity across the random fields, any empty spaces should be filled
with zeros. Figures 4 and 5 show the behaviors of the excursion set at threshold level
λ = 0, where we note the R-peaks and the P-waves of each type of patient. We developed
Algorithm 2, which measures the vectors with the P-waves and R-peaks to build the non-
Gaussian random field. The algorithm first determines the maximum length of the cycles.
If the length of any cycle is less than this maximum, the algorithm fills the empty spaces
with zeros to ensure homogeneity.
100
R-peaks
Cardiac cycle number
80
P-waves
60
40
20
0
260 200 150 100 50 0
Sample number
Figure 4. P-waves and R-peaks from the binary image (excursion set) at level λ = 0.2 for an apnea
patient. The binary representation of the P-wave varies depending on the level of u.
Algorithms 2024, 17, 527 9 of 22
100
90
80
60
P-waves
50
40
30
20
10
0
260 200 150 100 50 0
Sample number
Figure 5. P-waves and R-peaks from the binary image (excursion set) at level λ = 0.2 for a non-apnea
patient. Normally, the P-wave follows a straight line at each level u.
4.4. Classification
The last step of the methodology involves searching for the best classifier. To predict
the type of apnea, we use a matrix X with 102 columns; columns 1 to 101 contain the
stacked EPC values, and the last column represents the target value, where sleep apnea is
denoted as 0 and non-apnea as 1. The matrix described is utilized for training the classifier.
where Z jk denotes the predictors with j = [1, 101], and Yk denotes the class of each patient.
Algorithms 2024, 17, 527 10 of 22
Figure 6. EPC values from the sleep apnea patients. Patients from 1 to 20 show OSA events at
different times with severe cases. In the majority of these cases, the duration of the OSA event is
about 1 hour.
Figure 7. EPC values from sleep apnea patients with borderline cases (patients 21–25), where activity
was less than an hour, and non-apnea patients (patients 26–35), who served as control cases.
applying EPC models derived from 15th-order polynomials as inputs for the classifiers.
The computations were conducted on an AMD Ryzen 5 processor with 16 GB of RAM,
utilizing the parallel pool option. We used k-fold cross-validation with k = 5 in all cases.
Table 1. Comparing machine learning techniques to classify sleep apnea using EPC models as inputs.
Figure 8. The ensemble KNN classifier example; each dataset is composed of 65 random features. In
this setup, 30 KNN classifiers (learners) are activated, and the final prediction is determined by a
majority vote.
Parameters Values
Number of Neighbors (k) 10
Weighting Method ‘distance’
Distance Metric ‘euclidean’
Algorithm for Finding Neighbors ‘auto’
Number of Estimators 30
Ponderation of Models Uniform
Algorithms 2024, 17, 527 12 of 22
where ω ji denotes the weights, xi denotes the input values, and b j denotes the bias. The
weighted sum z j is then passed through an activation function f (z j ) to introduce non-
linearity. This nonlinearity is essential for the network to model complex patterns in the
data. The final output from the network depends on both the network architecture and the
activation function choice.
Figure 9 shows the neural network used in this work to classify apnea, where an
input layer, two hidden layers, and an output layer were implemented. A Swish activation
function was implemented in the input layer, a ReLU activation function was implemented
in the first hidden layer, a tanh activation function was used in the second hidden layer,
and a softmax was used in the output layer.
Table 3 summarizes the values of the parameters of the FNN builder in Python using
the TensorFlow library.
Figure 9. Feedforward multi-layer neural network architecture proposed for classifying sleep apnea;
an input layer using a Swish activation function, two hidden layers—one with a ReLU function and
the other with a tanh function—and an output layer equipped with a softmax function.
Algorithms 2024, 17, 527 13 of 22
Below are the results obtained using two types of polynomial orders to smooth the
signal. They are also compared with other models.
Figure 10. Confusion matrix for the training phase using 15th- and 21st-order polynomials. Both
cases had the same results.
Figure 10 shows the total correct predictions of the trained model, where it achieved
92% accuracy in apnea cases and 50% accuracy in non-apnea cases. In this work, we
used 15th- and 21st-order polynomials to soften the signal, but the model achieved the
same results obtained with the training data; Figure 10 expresses the results for the two
polynomial orders in this phase.
Algorithms 2024, 17, 527 14 of 22
In the testing phase, we used the validation data to obtain the results presented in
Figures 11 and 12; one set of results uses a 15th-order polynomial and the other uses a
21st-order polynomial. Figure 11 shows that patients with apnea were correctly classified
100% of the time, while those without apnea were correctly classified 88% of the time. In
addition, the accuracy, sensitivity, and specificity were calculated with the above-mentioned
formulas, yielding results of 97%, 96%, and 100%, respectively.
Figure 11. Results of the confusion matrix for the validated data using a 15th-order polynomial.
Figure 12 shows the results using the 21st-order polynomial, where the patients with
apnea were correctly classified 100% of the time, and those without apnea were correctly
classified 75% of the time. Additionally, the accuracy, sensitivity, and specificity were
calculated using the formulas mentioned above, yielding results of 94%, 93%, and 100%,
respectively.
Figure 12. Results for the test phase using a 21st-order polynomial.
A new method for classifying sleep apnea is proposed, which involves performing a
geometric transformation and extracting information through the Euler–Poincaré charac-
teristic model from Holter ECG and one lead (lead V3 ). Using a 15th-order polynomial in
the pre-processing phase, the model achieves an average accuracy of 89%, a sensitivity of
89%, and a specificity of 86%.
The results obtained with the feedforward neural network are presented for the
training phase in Figure 13 and for the test phase in Figure 14. The summary of these
results is shown in Table 4.
Algorithms 2024, 17, 527 15 of 22
Figure 13. Confusion matrix for the training phase using a 15th-order polynomial and FNN.
Figure 14. Results of the confusion matrix for the test set using a 15th-order polynomial and FNN.
Table 4. Table presenting the accuracy, sensitivity, specificity, and F1 score results of the FNN classifier.
The FNN has a better response than the EKNN. We used a 15th-order polynomial EPC
model to obtain the FNN classifier model because it had better results compared to the
21st-order polynomial. The next step is to compare the two approaches with several cases
in the literature.
Table 5 compares our approach with various cases from the 2000 challenge to modern
techniques that employ deep learning machines.
The heart rate variability (HRV) analysis has been employed in the literature. For
example, [26] used domain time features of the HRV, achieving a performance of 92.6%.
In [34], the authors analyzed the frequency domain features from the T-wave, using the
wavelet transform, and reached 92.3% accuracy. In [32], the spectral analysis of HRV
features achieved an accuracy of 89.36%.
Other works used oxygen saturation (S p O2 ) data to classify OSA. In [29], three different
algorithms using the wavelet transform were compared, and the results yielded an accuracy
of 88%.
The decision methods can vary by work. The most used classifiers include random
forest, support vector machines, linear or quadratic regression, neural networks, and KNN.
In [50], a linear discriminant using frequency domain features extracted from the Hilbert
transform achieved 90% accuracy. In [30], a decision tree combined with blood oxygen
saturation levels classified the OSA and achieved an accuracy of 93.03%, a sensitivity of
92.35%, and a specificity of 93.52%. In [36], a neural network was used to classify RR
interval data and multi-frequency filters, achieving a specificity of 99%.
Algorithms 2024, 17, 527 16 of 22
In [51], a random forest classifier used features from the power spectrum and discrete
wavelet transform. The best features were selected as inputs with the aid of the particle
swarm optimization method. The reported accuracy was 99.22%.
The authors of [35] and [17] used deep neural networks. A multi-layer feed-forward
neural network (FNN) using information from the ECG, S p O2 , and BMI yielded an accuracy
of 97.8% [35]. In [17], the authors proposed an algorithm that used deep learning layers
(convolutional neural networks and long short-term memory) to extract features and
classify the OSA. It achieved an accuracy of 97.21%, a sensitivity of 94.41%, and a specificity
of 98.94% on the Apnea-ECG database.
The related works and each study’s performance measures, signals used, techniques,
and decision methods are summarized in Table 5. Our approach stands out in terms of per-
formance measures (sensitivity, specificity, and accuracy); we also employed a geometrical
approach, which is unique among the studies reviewed. We used a different multi-layer
FNN and the EPC model as features, obtaining a similar performance to Li et al. [35].
Table 5. Comparison between our approach and the approaches used in the literature.
Author Contributions: Conceptualization, M.R.-M. and G.O.-T.; methodology, F.D.J.S.-V. and M.M.G.;
validation, E.S.-B. and J.C.M.-S.; formal analysis, J.E.V.-R. and E.M.R.-V.; Investigation, M.R.-M. and
M.G.M.-E.; writing—review and editing, J.Y.R.-M. All authors have read and agreed to the published
version of the manuscript.
Funding: This research received no external funding.
Data Availability Statement: The database Apnea-ECG, described in [42], is available on PhysioNet
at https://physionet.org/content/apnea-ecg/1.0.0/ (accessed on 22 August 2024).
Acknowledgments: We thank the Centro Universitario de los Valles of the University of Guadalajara
for the access and use of the research laboratories.
Conflicts of Interest: The authors declare no conflicts of interest.
Abbreviations
The following abbreviations are used in this manuscript:
Accu accuracy
BMI body mass index
CNN convolutional neural network
CTM central tendency measure
DWT discrete wavelet transform
ECG electrocardiogram
EDR ECG-derived respiration
EEG electroencephalogram
EKNN ensemble k-nearest neighbors
EMG electromyogram
EPC Euler–Poincaré characteristic
FENet frequency extraction network
FNN feedforward neural network
Algorithms 2024, 17, 527 18 of 22
Figure A1 shows the confusion matrix for the training set with an accuracy of 92.31%,
a sensitivity of 100%, and a specificity of 84.62%.
Figure A2 shows the confusion matrix for the test set with an accuracy of 84.62%, a
sensitivity of 80.77%, and a specificity of 88.46%.
The summary of the metrics for this dataset, using the SMOTE algorithm to balance
the data, is presented in Table A1.
Confusion Matrix - Train
25
0 22 4 20
15
True label
10
1 0 26
5
0
0 1
Predicted label
Figure A1. Confusion matrix for the training set using the balanced data. Class 0 represents the
apnea patients, and class 1 represents the non-apnea patients.
20.0
0 23 3
17.5
15.0
True label
12.5
10.0
1 5 21
7.5
5.0
0 1
Predicted label
Figure A2. Confusion matrix for the test set using the balanced data. Class 0 represents the apnea
patients, and class 1 represents the non-apnea patients.
Algorithms 2024, 17, 527 20 of 22
References
1. Malhotra, A.; Ayappa, I.; Ayas, N.; Collop, N.; Kirsch, D.; Mcardle, N.; Mehra, R.; Pack, A.I.; Punjabi, N.; White, D.P.; et al. Metrics
of sleep apnea severity: Beyond the apnea-hypopnea index. Sleep 2021, 44, zsab030. [CrossRef]
2. Baranchuk, A. Sleep apnea, cardiac arrhythmias, and conduction disorders. J. Electrocardiol. 2012, 45, 508–512. [CrossRef]
[PubMed]
3. Suen, C.; Wong, J.; Ryan, C.M.; Goh, S.; Got, T.; Chaudhry, R.; Lee, D.S.; Chung, F. Prevalence of Undiagnosed Obstructive Sleep
Apnea Among Patients Hospitalized for Cardiovascular Disease and Associated In-Hospital Outcomes: A Scoping Review. J.
Clin. Med. 2020, 9, 989. [CrossRef] [PubMed]
4. Anzai, T.; Grandinetti, A.; Katz, A.R.; Hurwitz, E.L.; Wu, Y.Y.; Masaki, K. Association between central sleep apnea and atrial
fibrillation/flutter in Japanese-American men: The Kuakini Honolulu Heart Program (HHP) and Honolulu-Asia Aging Study
(HAAS). J. Electrocardiol. 2020, 61, 10–17. [CrossRef] [PubMed]
5. Leung, A.A.; Williams, J.V.; Padwal, R.S.; McAlister, F.A. Prevalence, Patient Awareness, Treatment, and Control of Hypertension
in Canadian Adults With Common Comorbidities. CJC Open 2024. [CrossRef] [PubMed]
6. Rundo, J.V.; Downey, R., III. Polysomnography. Handb. Clin. Neurol. 2019, 160, 381–392.
7. Gottlieb, D.J.; Punjabi, N.M. Diagnosis and management of obstructive sleep apnea: A review. Jama 2020, 323, 1389–1400.
[CrossRef]
8. Khandoker, A.H.; Palaniswami, M.; Karmakar, C.K. Support vector machines for automated recognition of obstructive sleep
apnea syndrome from ECG recordings. IEEE Trans. Inf. Technol. Biomed. 2008, 13, 37–48. [CrossRef]
9. Varon, C.; Caicedo, A.; Testelmans, D.; Buyse, B.; Van Huffel, S. A novel algorithm for the automatic detection of sleep apnea
from single-lead ECG. IEEE Trans. Biomed. Eng. 2015, 62, 2269–2278. [CrossRef]
10. Hwang, S.H.; Lee, Y.J.; Jeong, D.U.; Park, K.S. Apnea–hypopnea index prediction using electrocardiogram acquired during the
sleep-onset period. IEEE Trans. Biomed. Eng. 2016, 64, 295–301.
11. Mohammadzadeh-Asl, B.; Setarehdan, S.K. Neural network based arrhythmia classification using heart rate variability signal. In
Proceedings of the 2006 14th European Signal Processing Conference, Florence, Italy, 4–8 September 2006; pp. 1–4.
12. Asl, B.M.; Sharafat, A.R.; Setarehdan, S.K. An adaptive backpropagation neural network for arrhythmia classification using RR
interval signal. Neural Netw. World 2012, 22, 535. [CrossRef]
13. Starkey, S.Y.; Jonasson, D.R.; Alexis, S.; Su, S.; Johal, R.; Sweeney, P.; Brasher, P.M.; Fleetham, J.; Ayas, N.; Orenstein, T.; et al.
Screening for Obstructive Sleep Apnea in an Atrial Fibrillation Population: What’s the Best Test? CJC Open 2021, 3, 442–449.
[CrossRef] [PubMed]
14. Sun, D.; Schaff, H.V.; Somers, V.K.; Nishimura, R.A.; Geske, J.B.; Dearani, J.A.; Ommen, S.R. Association of Preoperative
Sleep-Disordered Breathing With Functional Status After Septal Myectomy for Obstructive Hypertrophic Cardiomyopathy. CJC
Open 2022, 4, 848–853. [CrossRef] [PubMed]
15. Babaeizadeh, S.; White, D.P.; Pittman, S.D.; Zhou, S.H. Automatic detection and quantification of sleep apnea using heart rate
variability. J. Electrocardiol. 2010, 43, 535–541. [CrossRef] [PubMed]
16. Yılmaz, B. Sleep staging and apnea detection from single-lead electrocardiogram. J. Electrocardiol. 2011, 44, e31–e32. [CrossRef]
17. Zarei, A.; Beheshti, H.; Asl, B.M. Detection of sleep apnea using deep neural networks and single-lead ECG signals. Biomed.
Signal Process. Control 2022, 71, 103125. [CrossRef]
18. Bahrami, M.; Forouzanfar, M. Sleep Apnea Detection From Single-Lead ECG: A Comprehensive Analysis of Machine Learning
and Deep Learning Algorithms. IEEE Trans. Instrum. Meas. 2022, 71, 1–11. [CrossRef]
19. Pant, H.; Dhanda, H.K.; Taran, S. Sleep apnea detection using electrocardiogram signal input to FAWT and optimize ensemble
classifier. Measurement 2022, 189, 110485. [CrossRef]
20. Yang, Q.; Zou, L.; Wei, K.; Liu, G. Obstructive sleep apnea detection from single-lead electrocardiogram signals using one-
dimensional squeeze-and-excitation residual group network. Comput. Biol. Med. 2022, 140, 105124. [CrossRef]
21. Liu, H.; Cui, S.; Zhao, X.; Cong, F. Detection of obstructive sleep apnea from single-channel ECG signals using a CNN-transformer
architecture. Biomed. Signal Process. Control 2023, 82, 104581. [CrossRef]
22. Magalang, U.J.; Dmochowski, J.; Veeramachaneni, S.; Draw, A.; Mador, M.J.; El-Solh, A.; Grant, B.J. Prediction of the Apnea-
Hypopnea Index From Overnight Pulse Oximetry. Chest 2003, 124, 1694–1701. : 10.1378/chest.124.5.1694 [CrossRef] [PubMed]
23. Heneghan, C.; Chua, C.P.; Garvey, J.F.; de Chazal, P.; Shouldice, R.; Boyle, P.; McNicholas, W.T. A Portable Automated Assessment
Tool for Sleep Apnea Using a Combined Holter-Oximeter. Sleep 2008, 31, 1432–1439. [CrossRef] [PubMed]
Algorithms 2024, 17, 527 21 of 22
24. Álvarez, D.; Hornero, R.; Abásolo, D.; del Campo, F.; Zamarrón, C. Nonlinear characteristics of blood oxygen saturation from
nocturnal oximetry for obstructive sleep apnoea detection. Physiol. Meas. 2006, 27, 399–412. [CrossRef] [PubMed]
25. Maier, C.; Friedrich, J.; Katus, H.; Dickhaus, H. Prospective evaluation of a Holter-ECG derived severity index for screening of
sleep disordered breathing. J. Electrocardiol. 2016, 49, 919–924. [CrossRef] [PubMed]
26. McNames, J.N.; Fraser, A.M. Obstructive sleep apnea classification based on spectrogram patterns in the electrocardiogram.
In Proceedings of the Computers in Cardiology 2000. Vol.27 (Cat. 00CH37163), Cambridge, MA, USA, 24–27 September 2000;
pp. 749–752. [CrossRef]
27. Gil, E.; Vergara, J.M.; Laguna, P. Study of the relationship between Pulse Photopletismography amplitude decrease events and
sleep apneas in children. In proceeding of 2006 International Conference of the IEEE Engineering in Medicine and Biology
Society, New York, NY, USA, 30 August–3 September 2006; pp. 3887–3890.
28. Gil, E.; Monasterio, V.; Laguna, P.; Vergara, J.M. Pulse Photopletismography Amplitude Decrease Detector for Sleep Apnea
Evaluation in Children. In proceeding of 2005 IEEE Engineering in Medicine and Biology 27th Annual Conference, Shanghai,
China, 17–18 January 2006; pp. 2743–2746.
29. Lee, Y.K.; Bister, M.; Blanchfield, P.; Salleh, Y.M. Automated detection of obstructive apnea and hypopnea events from oxygen
saturation signal. In Proceedings of the The 26th Annual International Conference of the IEEE Engineering in Medicine and
Biology Society, San Francisco, CA, USA, 1–5 September 2004; Volume 1, pp. 321–324. [CrossRef]
30. Burgos, A.; Goñi, A.; Illarramendi, A.; Bermudez, J. Real-Time Detection of Apneas on a PDA. IEEE Trans. Inf. Technol. Biomed.
2010, 14, 995–1002. [CrossRef]
31. Varady, P.; Micsik, T.; Benedek, S.; Benyo, Z. A novel method for the detection of apnea and hypopnea events in respiration
signals. IEEE Trans. Biomed. Eng. 2002, 49, 936–942. [CrossRef]
32. de Chazal, P.; Heneghan, C.; Sheridan, E.; Reilly, R.; Nolan, P.; O’Malley, M. Automatic classification of sleep apnea epochs using
the electrocardiogram. In Proceedings of the Computers in Cardiology 2000. Vol.27 (Cat. 00CH37163), Cambridge, MA, USA,
24–27 September 2000; pp. 745–748. [CrossRef]
33. Maier, C.; Dickhaus, H.; Laguna, P. Amplitude variability extraction from multi-lead electrocardiograms for improvement of
sleep apnea recognition. In Proceedings of the Computers in Cardiology, Lyon, France, 25–28 September 2005; pp. 355–358.
[CrossRef]
34. Raymond, B.; Cayton, R.M.; Bates, R.A.; Chappell, M. Screening for obstructive sleep apnoea based on the electrocardiogram-the
computers in cardiology challenge. In Proceedings of the Computers in Cardiology 2000. Vol.27 (Cat. 00CH37163), Cambridge,
MA, USA, 24–27 September 2000; pp. 267–270. [CrossRef]
35. Li, Z.; Li, Y.; Zhao, G.; Zhang, X.; Xu, W.; Han, D. A model for obstructive sleep apnea detection using a multi-layer feed-forward
neural network based on electrocardiogram, pulse oxygen saturation, and body mass index. Sleep Breath. 2021, 25, 2065–2072.
[CrossRef]
36. Ye, G.; Yin, H.; Chen, T.; Chen, H.; Cui, L.; Zhang, X. FENet: A Frequency Extraction Network for Obstructive Sleep Apnea
Detection. IEEE J. Biomed. Health Informatics 2021, 25, 2848–2856. [CrossRef]
37. Rashid, M.M.; Askari, M.R.; Chen, C.; Liang, Y.; Shu, K.; Cinar, A. Artificial Intelligence Algorithms for Treatment of Diabetes.
Algorithms 2022, 15, 299. [CrossRef]
38. Asif, D.; Bibi, M.; Arif, M.S.; Mukheimer, A. Enhancing Heart Disease Prediction through Ensemble Learning Techniques with
Hyperparameter Optimization. Algorithms 2023, 16, 8. [CrossRef]
39. Mondol, C.; Shamrat, F.M.J.M.; Hasan, M.R.; Alam, S.; Ghosh, P.; Tasnim, Z.; Ahmed, K.; Bui, F.M.; Ibrahim, S.M. Early Prediction
of Chronic Kidney Disease: A Comprehensive Performance Analysis of Deep Learning Models. Algorithms 2022, 15, 308.
[CrossRef]
40. Khoperskov, A.V.; Polyakov, M.V. Improving the Efficiency of Oncological Diagnosis of the Breast Based on the Combined Use of
Simulation Modeling and Artificial Intelligence Algorithms. Algorithms 2022, 15, 292. [CrossRef]
41. Goldberger, A.L.; Amaral, L.A.; Glass, L.; Hausdorff, J.M.; Ivanov, P.C.; Mark, R.G.; Mietus, J.E.; Moody, G.B.; Peng, C.K.;
Stanley, H.E. PhysioBank, PhysioToolkit, and PhysioNet components of a new research resource for complex physiologic signals.
Circulation 2000, 101, e215–e220. [CrossRef] [PubMed]
42. Penzel, T.; Moody, G.B.; Mark, R.G.; Goldberger, A.L.; Peter, J.H. Apnea-ECG Database. Comput. Cardiol. 2000, 27, 255–258.
[CrossRef]
43. Ramos-Martinez, M.; Corbier, C.; Alvarado, V.M.; Lopez, G.L. Decomposed Mean Euler-Poincaré Characteristic Model for a
Non-Gaussian Physiological Random Field. IEEE Access 2021, 9, 21180–21191. [CrossRef]
44. Knuth, D.E. Two notes on notation. Am. Math. Mon. 1992, 99, 403–422. [CrossRef]
45. Pan, J.; Tompkins, W.J. A Real-Time QRS Detection Algorithm. IEEE Trans. Biomed. Eng. 1985, BME-32, 230–236. [CrossRef]
46. Klinger, A. The Vandermonde Matrix. Am. Math. Mon. 1967, 74, 571–574. [CrossRef]
47. Gray, S.B. Local Properties of Binary Images in Two Dimensions. IEEE Trans. Comput. 1971, C-21, 551–561. [CrossRef]
48. Richardson, E.; Werman, M. Efficient classification using the Euler characteristic. Pattern Recognit. Lett. 2014, 49, 99–106.
[CrossRef]
49. Gul, A.; Perperoglou, A.; Khan, Z.; Mahmoud, O.; Miftahuddin, M.; Adler, W.; Lausen, B. Ensemble of a subset of k NN classifiers.
Adv. Data Anal. Classif. 2018, 12, 827–840. [CrossRef] [PubMed]
Algorithms 2024, 17, 527 22 of 22
50. Corthout, J.; Van Huffel, S.; Mendez, M.O.; Bianchi, A.M.; Penzel, T.; Cerutti, S. Automatic screening of Obstructive Sleep
Apnea from the ECG based on Empirical Mode Decomposition and wavelet analysis. In Proceedings of the 2008 30th Annual
International Conference of the IEEE Engineering in Medicine and Biology Society, Vancouver, BC, Canada, 20–25 August 2008;
pp. 3608–3611. [CrossRef]
51. Rajesh, K.; Dhuli, R.; Kumar, T.S. Obstructive sleep apnea detection using discrete wavelet transform-based statistical features.
Comput. Biol. Med. 2021, 130, 104199. [CrossRef] [PubMed]
52. Chawla, N.V.; Bowyer, K.W.; Hall, L.O.; Kegelmeyer, W.P. SMOTE: Synthetic Minority Over-sampling Technique. J. Artif. Intell.
Res. 2002, 16, 321–357. [CrossRef]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual
author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to
people or property resulting from any ideas, methods, instructions or products referred to in the content.