<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta>
      <journal-title-group>
        <journal-title>H. Krasovska);</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <title-group>
        <article-title>Classifier for the Diagnostic of Obstructive Sleep Apnea Syndrome</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Olena Fedusenko</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Yaroslav Khrolenko</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Iryna Domanetska</string-name>
          <email>irinadomanetskaya@gmail.com</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Oleh Ilarionov</string-name>
          <email>oilarionov@gmail.com</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Hanna Krasovska</string-name>
          <email>annavkrasovska@gmail.com</email>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Institute for Information Recording of NAS of Ukraine</institution>
          ,
          <addr-line>2 Shpaka Street, Kyiv, 03113</addr-line>
          ,
          <country country="UA">Ukraine</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Taras Shevchenko National University of Kyiv</institution>
          ,
          <addr-line>60 Volodymyrska Street, Kyiv, 01033</addr-line>
          ,
          <country country="UA">Ukraine</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>1986</year>
      </pub-date>
      <volume>000</volume>
      <fpage>0</fpage>
      <lpage>0002</lpage>
      <abstract>
        <p>Opportunities of artificial intelligence (AI) are widely used in health care today. The main prerequisite for this was the shortage of highly qualified specialists in combination with large volumes of data that must be analyzed and taken into account. In addition, sensor networks, which are used during remote medical and biological research, monitoring of the main indicators of medical telemetry, drug admission control, etc., are rapidly becoming part of the reality of modern medicine and provide data collection and storage of information in some spatially distributed laboratories, providing researchers with remote access to accumulated data. Obstructive sleep apnea syndrome is one of the most common pathological conditions. Currently, in economically developed countries this disease is observed in approximately 8-10% of the population. Obstructive apnea - this is an episode of breath stop with a decrease flow air on 90% and more, that lasts more than 10 seconds, with further efforts of respiratory muscles, directed on restoration of breath. Polysonography is standard research to determine the course of sleep phases that is used for diagnostics of sleep disorders. Determining sleep phases is a complex, multifaceted task that requires the analysis of large volumes of heterogeneous data and highly qualified specialists. Therefore, the task of determining sleep phases using means of intelligent data processing, namely, neural networks technologies, is relevant and practically significant.</p>
      </abstract>
      <kwd-group>
        <kwd>Keywords1</kwd>
        <kwd>artificial neural networks</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>Obstructive sleep apnea syndrome is the most common breathing disorder during sleep,
characterized by narrowing or closing of the upper airways, breathing pauses during sleep, which are
often accompanied by a decrease in the level of oxygen in the blood, a compensatory increase in pulse
rate and blood pressure. Sleep becomes shallow, awakenings may occur repeatedly during the night.</p>
      <p>Currently, in economically developed countries, this disease is observed in approximately 8-10% of
the population [1] . Obstructive sleep apnea syndrome is the cause of a number of medical and social
problems. The danger is that frequent breathing stops lead to a significant lack of oxygen during the
night, which significantly (according to statistics, almost 5 times) increases the risk of developing severe
heart rhythm disorders, myocardial infarction, type II diabetes, mental disorders, stroke, and sudden
death in a sleep [1-3]. Chronically disturbed sleep, which is a constant companion of obstructive sleep
apnea, has devastating consequences not only for health. Patients with obstructive sleep apnea have</p>
      <p>2022 Copyright for this paper by its authors.
high irritability, depression, decreased attention and intellectual abilities, and their life and professional
activities are less effective[4]. All this leads to an increase in the risks of creating emergency situations
on the roads, in manufacturing, and in everyday life. The Bhopal accident, the Three Mile Island
accident, the Chernobyl nuclear power plant accident, and the Challenger shuttle disaster were officially
attributed to a fatal error due to fatigue and poor sleep and possibly sleep disorders.</p>
      <p>The diagnosis of obstructive sleep apnea syndrome is based, first of all, on the specific clinical
picture – the presence of snoring, excessive daytime sleepiness, insomnia. However, these symptoms
are not always associated with the presence of obstructive sleep apnea syndrome. They determine the
need for primary differential diagnosis of the sleep apnea syndrome with pathologies associated with
sleep disturbances, such as narcolepsy, idiopathic hypersomnia, restless legs syndrome, etc. It is often
necessary to differentiate obstructive sleep apnea syndrome with laryngospasm occurring during sleep
and gastroesophageal spasm reflux, which can also be accompanied by breathing disorders and cough.
A clinical picture similar to the syndrome of obstructive sleep apnea can be given by the Cheyne -Stokes
breathing syndrome, when hyperpnea alternates with complete cessation of breathing [5]. There are
medical studies showing that severe obesity has symptoms typical for obstructive sleep apnea syndrome
(snoring, daytime sleepiness) without the presence of the syndrome itself [6], etc., which must be
considered when making a diagnosis. In practical terms, it is very important to differentiate the above
disorders, because they require different treatment approaches.</p>
      <p>Despite existing evidence of the social and clinical significance of sleep-disordered breathing, the
majority of cases of obstructive sleep apnea remain unrecognized. This is explained, on the one hand,
by the insufficient awareness of patients, and on the other hand, by the difficulty of diagnosing the
disease by doctors of general therapeutic practice.</p>
      <p>Screening of patients with breathing disorders during sleep is carried out in various ways: taking an
anamnesis, using questionnaire scales, polygraphic cardiorespiratory monitoring, and computer pulse
oximetry. However, polysomnography remains the main method of diagnosing obstructive sleep apnea
syndrome.</p>
      <p>Currently, in global practice, a number of different questionnaires are used to identify the risk of
sleep-disordered breathing (for example, the Berlin questionnaire [7], STOPBang Questionnaire [8]),
as well as for assessing the severity of some symptoms (in particular, the Epworth Sleepiness Scale [9]
for assessing daytime sleepiness and others).</p>
      <p>The Berlin questionnaire was developed at the international congress in Berlin in 1996 as a method
of assessing the risk of obstructive sleep apnea syndrome [11]. The questions included in the
questionnaire were selected based on the available scientific data on the predictive power of certain
signs in the diagnosis of breathing disorders in sleep. The conference reached a consensus on the
inclusion of a limited number of questions related to the most typical manifestations of obstructive sleep
apnea syndrome. The Berlin questionnaire includes 3 categories of questions: category 1 consists of
questions about snoring and sleep apnea; category 2 - questions about daytime sleepiness and fatigue;
category 3 - blood pressure and body mass index value.</p>
      <p>Questionnaires contain a rather limited list of questions. Figure 1 shows the form of the Epworth
Sleepiness Scale.</p>
      <p>And although the authors of the study [10] note that the answers to the questionnaires have a great
prognostic value, they still believe that the data obtained during the subjective assessment of breathing
disorders in sleep according to the survey can be used only as a reference point at the first stage of the
diagnostic search, but they cannot be relied upon when establishing a diagnosis, and in particular, a
diagnosis of obstructive sleep apnea syndrome. Negative answers to questionnaire questions cannot be
a reason for refusing to conduct an in-depth study. In addition, when self-filling the questionnaires, the
analysis of the received data becomes difficult due to the large number of omissions and incomplete
answers.</p>
      <p>The modern medical community recognizes the possibility of alternative diagnosis of obstructive
sleep apnea using portable cardiorespiratory monitors, especially in patients with a high pretest
probability, that is, when the probability of detecting sleep apnea from a medical point of view is
initially high. Figure 2 shows a record of cardiorespiratory monitoring.</p>
      <p>The tracing shows pressure (red), flow (green), expiratory volume (blue), and pulse rate (red). The
blue arrow points a part of the volume entering the oropharynx at the start of the inflation. The green
arrow points at the part of volume entering the lungs when the pressure time integral is large enough
that overcome the resistance of the glottis and upper airway [13].</p>
      <p>But the accuracy of respiratory polygraphy results can be affected by the presence of serious
concomitant diseases, especially those accompanied by severe heart or respiratory failure. An unreliable
result can also be obtained for patients with chronic insomnia since the cardiorespiratory equipment
does not allow accurate control of the actual duration of sleep. In addition, cardiorespiratory monitors
are not equipped with sensors to accurately distinguish between sleep and wakefulness. This could
potentially lead to an underestimation of disease severity for individual patients. Therefore,
cardiorespiratory monitoring is not recommended for final diagnosis.</p>
      <p>Computer pulse oximetry is a method of screening diagnostics that has high sensitivity and
specificity in most cases of breathing disorders during sleep, as well as in the detection of nocturnal
hypoxemia (disordered blood oxygen saturation). With the help of computer pulse oximetry, patients
are only selected for carrying out clarifying methods of diagnosis. Polysomnography is a method of
studying the work of the human body during sleep, which allows to identify the cause of its disturbance.
The methodology makes it possible to evaluate the widest range of indicators (Figure 3)[14]:
 EEG (electroencephalography): study of the electrical activity of the brain in order to determine
its operation in different phases of sleep;
 ECG (electrocardiography): examination of the heart;
 EOG (electrooculography): control over the movements of the eyeballs;
 EMG (electromyography): examination of chin muscle tone;
 determination of respiratory flow;
 control over respiratory movements of the chest and abdomen;
 control over the movements of the lower limbs;
 pulse oximeter: determining the degree of blood saturation with oxygen;
 determining the position of the patient's body.</p>
      <p>During polysomnography, brain biorhythms are additionally recorded, which allows you to
physically record the sleep process. This, among other things, makes it possible to assess the severity
of respiratory disorders based on real sleep time.</p>
      <p>The human body requires daily rest. Normal sleep cycles are necessary to restore the immune
system, organize the flow of information received during the day, and perform many other functions.
During the night, a person goes through several phases in his sleep - the so-called "slow" and "rapid"
sleep. "Slow"sleeh phase gives the body rest and helps to produce hormones. In the phase of "rapid"
sleep, the brain acts like the brain of a person who is awake and even more active - it is the time when
we see dreams. Figure 4 shows the generalized structure of sleep.</p>
      <p>Sleep is subject to certain laws, it is a fairly clearly structured process of successive alternation of
the work of certain parts of the brain. Several phases and stages of sleep successively replace each other
[15]:</p>
      <p>• Relaxed wakefulness. Some specialists attribute the process of falling asleep - a gradual decrease
in brain activity - to the structures of sleep and call this state "before sleep".</p>
      <p>• Slow or Non -REM sleep (NREM). It occurs immediately after falling asleep. In this phase, four
stages are distinguished, each of which differs in a different degree of bioelectric activity of the brain,
has its own characteristics and duration. Slow sleep begins with a nap and ends in very deep, so-called
"delta sleep."</p>
      <p>• Rapid or REM sleep. This phase comes after the deep stages of slow sleep and its external
manifestation is rapid eye movements. They can often be noticed simply by watching a sleeping person.
At this time, the brain of a sleeping person is active almost like that of a sleepless person, it is the time
when a person sees the most vivid and meaningful dreams that are remembered.</p>
      <p>Figure 5 shows hypnograms of a healthy person and a person suffering from obstructive sleep apnea
syndrome. The sleep of a healthy person is characterized by a rhythmic change of REM and NREM
sleep (approximately 90 minutes). Deep stages of sleep are presented mainly in the first half of the
night.</p>
      <p>Sleep is subject to certain laws, it is a fairly clearly structured process of successive alternation of
the work of certain parts of the brain. Several phases and stages of sleep successively replace each other
[15]:</p>
      <p>• Relaxed wakefulness. Some specialists attribute the process of falling asleep - a gradual decrease
in brain activity - to the structures of sleep and call this state "before sleep".</p>
      <p>• Slow or Non -REM sleep (NREM). It occurs immediately after falling asleep. In this phase, four
stages are distinguished, each of which differs in a different degree of bioelectric activity of the brain,
has its own characteristics and duration. Slow sleep begins with a nap and ends in very deep, so-called
"delta sleep."</p>
      <p>• Rapid or REM sleep. This phase comes after the deep stages of slow sleep and its external
manifestation is rapid eye movements. They can often be noticed simply by watching a sleeping person.
At this time, the brain of a sleeping person is active almost like that of a sleepless person, it is the time
when a person sees the most vivid and meaningful dreams that are remembered.</p>
      <p>Figure 5 shows hypnograms of a healthy person and a person suffering from obstructive sleep apnea
syndrome. The sleep of a healthy person is characterized by a rhythmic change of REM and NREM
sleep (approximately 90 minutes). Deep stages of sleep are presented mainly in the first half of the
night.</p>
      <sec id="sec-1-1">
        <title>a) a healthy person</title>
      </sec>
      <sec id="sec-1-2">
        <title>b) a sick person</title>
        <p>If a person suffers from obstructive sleep apnea syndrome, his sleep changes noticeably, loses a clear
structure and becomes torn, superficial, restless. Falling asleep time is reduced. There are mostly first
and second stages of NREM sleep, which often alternate, with an almost complete absence of deep
sleep. The duration of REM sleep is also reduced</p>
        <p>The reason is that muscle tone decreases during sleep. This also applies to the muscles responsible
for the patency of the upper respiratory tract. As a result, the relaxed walls of the pharynx fluctuate
strongly in the air flow passing through the upper respiratory tract, sometimes coming together
completely and blocking the access of air to the lungs. In order not to suffocate in a sleep due to a
decrease in oxygen supply, a protective mechanism – micro-awakening - is activated in the brain. That
is, the brain "wakes up" for a few seconds, although the person himself may not realize it and will not
even remember the morning. At this moment, muscle tone increases and breathing is restored. Then the
person falls asleep again. But as soon as a person falls asleep, the muscles relax again and the cycle
"falling asleep - oxygen starvation - micro-awakening - recovery of breathing - falling asleep" repeats
again and again. Due to constant awakenings, the normal structure of sleep is grossly disturbed. Instead
of recovery processes, the human body spends most of the night fighting to keep breathing. As a result,
due to the lack of a full phase of deep sleep, a person does not get enough sleep, his/her brain does not
rest and recover sufficiently [15].</p>
        <p>Thus, when differentiating diagnoses, it is very important to correlate the values of numerous
parameters of a person's physiological state, which we obtain from polysomnography, with sleep phases
for the correct diagnosis of obstructive sleep apnea syndrome (see Table 1).</p>
        <p>Polysomnography is the current gold standard of high-resolution sleep monitoring; however, this
method is wearisome, expensive, and time-consuming. Since the research lasts for several hours, it
becomes necessary to have in addition to medical personnel also technical personnel, so-called sleep
technicians, in the laboratory. It is they who provide disconnection and connection of patients to the
electrodes and sensors of polysomnography in order to ensure comfortable conditions for the patient
during the night, provided that patients need to use the bathroom and move around the room for other
reasons. In addition, a patient tangled in wires with numerous sensors feels quite uncomfortable, which,
of course, affects the quality of sleep, which is the subject of the study. The gold standard is gold in the
literal sense, because it requires the patient to stay in a hospital with appropriate medical and technical
support, which seriously affects the cost of the study [17].</p>
        <p>Wireless touch sensors are a promising alternative to the standard polysomnography procedure due
to their portability, convenience, and advanced technologies for acquiring, transmitting, and accessing
data to customize analytics. Modern wireless body sensors can stick to the skin, bend around body
contours, and simultaneously collect and transmit a multitude of different parameters. [18]. Figure 6
schematically shows the patient's equipment for conducting a polysomnographic study using standard
(wired) and wireless technologies.</p>
        <p>Dennis Hwang, MD, a sleep and pulmonary medicine physician says “We're able that perform
polysomnography and even multiple sleep latency tests at home in the patient's natural sleep
environment. Utilizing [wireless PSG] in this fashion improves patient access that care by improving
our testing capability and removing barriers for patients unable that undergo polysomnography in a
sleep center overnight. We believe that this is an important strategy that help address racial and
demographic disparities that exist in healthcare.” [19]</p>
        <p>The figure 7 presents the generalized technology of polysomnographic research based on sensor
wireless networks. The equipment is completely autonomous (powered by batteries), stores data on a
built-in memory card and transmits data to the medical center through the base station. During the
examination, the patient can move freely, while the registered data remain under the full control of the
medical staff. Remote reconfiguration of the equipment is possible in case of problems.</p>
        <p>This approach will allow patients to be continuously monitored over several nights with minimal
discomfort, in a comfortable and familiar environment, allowing healthcare professionals to assess
longterm sleep patterns, diagnose sleep disorders and monitor disease risk factors both in the laboratory and
in the home conditions with real life conditions characteristic of patients more easily, more accurately
and less expensively.</p>
      </sec>
    </sec>
    <sec id="sec-2">
      <title>2. Basic material</title>
      <p>The rapid development of the main components of digitalization of medicine, especially in terms of
implementation of electronic disease histories, storage of large volumes of data about patients and
diseases, made artificial intelligence one of the most promising technologies in the field of medicine.
One of the areas of medicine in which intelligent technologies are most widely used is diagnostics.</p>
      <p>Task of automation diagnosis of obstructive syndrome apnea was considered and solved using
different artificial intelligence tools [20-26].</p>
      <p>In [27], SVM algorithms (support vector machine) were applied for construction of predictive
models for detection of obstructive syndrome apnea based on anthropometric data of the patient. A
specialized deep learning model called DeepSleepNet was investigated by the authors in [28] for
automatic sleep stage estimation based on single-channel EEG. In [29] the authors solve the problem
of diagnosing obstructive apnea syndrome using neural networks based on electrocardiogram data
obtained with the help of a specialized system built into a smartphone, investigate the efficiency of the
cascade of neural networks (autoencoder and multilayer perceptron). Presentation of the
electroencephalogram as a sequence of signals and the use of convolutional and recurrent networks, but
for another sleep disorder, which is also associated with sleep phases, are used by the authors in [30].
The work [30] is based on presenting the task of determining sleep phases as a task of
sequence-tosequence classification for the joint classification of the sequence of several epochs at the same time.
All the papers reviewed are interesting and give fairly good results, but are oriented towards a standard
polysomnography procedure. The authors of this work propose to combine the means of a wireless
sensor network, the results of questionnaires and machine learning algorithms to solve the problem of
automating the diagnosis of obstructive sleep apnea syndrome within the framework of a single system.
The generalized technology of the created system is presented in Figure 8.</p>
      <p>The system consists of three technologically heterogeneous subsystems.</p>
      <p>The patient data acquisition subsystem is intended for
 implementing the interaction of equipment that measures and transmits patient’s parameters by
means of a wireless sensor network;</p>
      <p> implementing the user interface for entering answers to the Berlin questionnaire (it was the one
chosen to supplement sensory data with subjective data of the patient himself).</p>
      <p>The AI data processing subsystem represents two neural networks working in parallel. Each of them
is focused on processing its part of input data: one processes data received from a wireless network, the
second processes survey data. Networks fundamentally differ in architecture.</p>
      <p>Within the framework of the same subsystem, the results obtained by each of the networks are
aggregated. Practically, the result aggregation block is another neural network.</p>
      <p>The operation of this subsystem can be considered as the operation of a neural network ensemble
with stacking technology in the aggregation block. The result of the work of such a neural network
ensemble will be predictions that are less sensitive to the specificity of data and heterogeneous learning
schemes. The prediction results obtained in the intelligent module are transferred to the doctor for
processing. It is the doctor who, based on the formed forecast that gives the system's confidence in the
diagnosis (degree of obstructive apnea), and based on his own experience, forms a medical conclusion
and recommendations. Let's consider in more detail each of the neural networks used to process input
data. The network that processes the answers of the Berlin questionnaire is simpler in terms of
architecture and learning algorithm. Architecturally, the network is a multilayer perceptron that solves
the problem of classification.</p>
      <p>The task of processing data from sensors is more difficult. To process time series, which is
polysomnogram data, neural networks that allow processing of sequences are needed. Since for the
diagnosis of obstructive sleep apnea syndrome, it is fundamentally important to know the phases of
sleep in which certain indicators of the patient's condition are observed, the main work will be
performed on the data of electroencephalograms, from which it is possible to obtain information about
the course of sleep phases in the patient. As possible alternatives, it is proposed to consider four
architectures of neural networks: three models based on the basic model, which is a multilayer
convolutional network, and a network of the DeepSleepNet architecture [28, 32].</p>
      <p>The basic model consists of three sequentially connected blocks, which contain two 1D-convolution
layers, a max-pooling (subdiscrediting) layer, and a spatialdropout logical module. The obtained result
is transmitted to serially connected blocks of fully connected Dense layers, on all layers, except for the
original fully connected layer, the ReLU activation function is used, the latter uses softmax (see
Fig. 9 a). The CNN-CNN model consists of a basic model and two sequentially connected blocks that
contain two 1D-convolution layers and a spatialdropout logical module. The obtained result is
transferred to the last 1D-convolution layer, which uses the softmax function. These additional layers,
in fact, represent another convolutional network, so the model is called CNN-CNN (see Fig. 9b).</p>
      <p>The CNN-CRF model contains a basic model and two sequentially connected blocks, each of which
is formed by two 1D-convolution layers and a spatialdropout logical module. The obtained result is
transferred to the last CRF layer, which is a probabilistic model for structured prediction, which is
successfully used in various fields, such as computer vision, bioinformatics, natural language
processing. This model is called CNN-CRF (see Fig. 9c). The CNN-LSTM model, in addition to the
basic model, includes two consecutive LSTM blocks (elements of long/short-term memory). The
dropout module is located ffter the first LSTM layer. And after the last one is the last 1D-convolution
layer, which uses softmax. This model is called CNN-LSTM (see Fig. 9 d).</p>
      <p>The architecture of DeepSleepNet [28] consists of two main parts, as shown in Fig.
10. The first part - RepresentationLearning is trained using filters to extract time independent
characteristics in each of the "raw" single channel EEG epochs.</p>
      <p>The second part is SequenceResidualLearning to process information such as rules for determining
sleep epochs in a sequence of EEG epochs based on previously acquired data.</p>
      <p>In the first part of RepresentationLearning, there are two CNN models working in parallel. Each of
the two CNNs consists of four convolutional layers and two max-pooling (discrediting) layers. Each
convolutional layer performs three operations in sequence: 1D-convolution with its filters,
batchnormalization (data normalization), and application of the ReLU activation function . Each
maxpool layer shows the pool size and step size.</p>
      <p>Each of the CNN models has an individual set of values of the size of the convolution kernel and the
shift steps. The СNN1 model uses a layer conv1 filter size equal to half the sample (Fs /2) and a shift
value equal to (Fs /16) to detect large-scale patterns.</p>
      <p>In СNN2, the filter size of the conv1 layer was set to Fs×4 for better capture, the shift value (Fs /2)
to perform fine-grained convolution.</p>
      <p>The second part of SequenceResidualLearning uses two bidirectional LSTM layers to obtain
information about the rules of sleep stages, which experts use to determine the next possible sleep stages
from the sequence of previous stages. Before each LSTM layer there is a dropout module. The last one
is the 1D-convolution layer, which uses softmax . The task of classification of sleep phases was solved
on the Sleep-edf data set [21]. The Sleep-edf database contains 197 PolySomnoGraphic sleep recordings
containing electroencephalogram (EEG) , electrooculogram (EOG) and electromyogram (EMG).
Some records include respiratory and body temperature readings. The Sleep-edf database contains *
PSG.edf and * Hypnogram.edf files. The * PSG.edf files are full-night sleep polysomnograms
containing EEG, EOG, chin EMG, and event marker. SC * PSG.edf files often also contain oro-nasal
respiration and rectal body temperature. The * Hypnogram.edf files contain the runtime annotations
that execute the PSG file. These schemes (hypnograms ) consist of sleep phases W, R, 1, 2, 3, 4, M
(movement time). All EDF header fields also conform to the EDF+ specification, and unrecorded
signals have been removed from the ST * PSG.edf files .</p>
      <p>Polysomnogram recording files are formatted in EDF, and hypnograms are in EDF+ format. Each
EDF and EDF+ file has a header indicating the patient, recording details (including time period) and
characteristics of the signals, including their calibration amplitude.</p>
      <p>EOG and EEG signals were transmitted and processed at a frequency of 100 Hz. The EMG signal
was filtered to find high frequencies, after that the signal was rectified using low-pass filtering, after
which the EMG was processed at a frequency of 1 Hz . Oro-nasal airflow data and event markers were
also processed at a frequency of 1 Hz. Template for forming the names of processed files:
ST7ssNJ0PSG.edf, where ss is the number of the subject, and N is the number of the night [21]. Scheme of
conducting an experiment to compare the effectiveness of the proposed architectures is as follows:
 Stage 1 – comparative analysis of networks built on a single basic model, namely CNN-CNN,
CNN-CRF, CNN-LSTM;</p>
      <p> Stage 2 – comparative analysis of the network-winner of the 1st stage with the DeepSleepNet
network
1st stage.</p>
      <p>During the experiment, three CNN models based on CNN-CNN, CNN-CRF, CNN-LSTM were
trained on the same input data and with the same number of epochs (30). The training time of the models
was, respectively, CNN-CNN - 6.9 hours, CNN-CRF - 7.1 hours, and CNN-LSTM - 1.5 hours.</p>
      <p>Figure 11 shows graphs of accuracy curves during model training and testing, and Figure 12 shows
error graphs with metrics for comparing models. The CNN-CRF model was determined to be the best
model by all parameters. This model has the highest level of accuracy and the lowest level of loss among
all other models. Figures A1 (in Appendix) show reports with metrics for comparing models.
2nd stage .</p>
      <p>In the first stage, the CNN-CRF architecture was determined to be the best of the three. Therefore,
we compare CNN-CRF with a neural network built on the DeepSleepNet architecture. The training time
of the model was 200 hours. Figure 13 shows graphs of accuracy curves during training and testing of
CNN-CRF and DeepSleepNet (DSN) models. Among all considered architectures, the DeepSleepNet
model is one of the most complex and resource intensive. But although DeepSleepNet needed much
more time for its own training, it showed the highest indicators (see Fig. 14). Thus, DeepSleepNet is
the best model among those presented in this study. It is this network that will be used in the
implementation of the system of automated diagnosis of obstructive sleep apnea syndrome based on the
use of wireless sensor networks.
accuracy during training</p>
      <p>accuracy during testing
1
0.5
0
losses during training</p>
      <p>losses during testing</p>
    </sec>
    <sec id="sec-3">
      <title>3. Conclusion</title>
      <p>Obstructive sleep apnea syndrome is a common pathology associated with a sharp decrease or
complete cessation of breathing during night rest. The consequences of sleep-disordered breathing can
be devastating and should not be underestimated.
accuracy during training
accuracy during testing
6
4
2
0
loss LSTM
loss CRF
loss CNN
1.5</p>
      <p>1
0.5
0
2
1</p>
      <p>Over the past two decades, the knowledge of doctors regarding the problem of obstructive sleep
apnea syndrome has increased significantly, large amounts of data have been accumulated and
structured, and the means of sensor wireless networks have been introduced into the practice of
medicine for conducting examinations of patients at home. To assess the degree of severity and
stratification of the degree of risk of obstructive apnea syndrome, it is necessary to evaluate clinical
data, statistical data obtained as a result of instrumental diagnostic methods - polysomnography,
cardiorespiratory monitoring, daily ECG monitoring, etc. Unfortunately, even experienced doctors do
not always see the full picture of the disease, because the data in the medical record is not structured,
and the medical history can be very voluminous. The effectiveness of their work is also affected by
fatigue and, in some cases, lack of knowledge in narrow areas. Intelligent developments in medicine
become reliable assistants of doctors: they save time, help them make accurate diagnoses, prescribe
timely therapy for patients, and monitor their condition. With the constant accumulation of training data
and a significant increase in its volume for many types of diseases, the role of deep learning methods
has become dominant in intelligent medical systems. In summary, in this work a generalized
architecture of intelligent technology for diagnosing obstructive sleep apnea syndrome, based on data
obtained by means of wireless sensor networks, was proposed. The basis of the intellectual technology
is a neural network module for complex processing of polysomnogram data and the results of patient
screening surveys. DeepSleepNet is the best model among those presented in this study.</p>
    </sec>
    <sec id="sec-4">
      <title>5. References</title>
      <p>[15] The structure of sleep in the norm and with obstructive sleep apnea
https://somnologpulmonolog.ru/blog/o-khrape/struktura-sna-v-norme-i-pri-obstruktivnom-apnoe/
[16] Abdur Rab Dhruba, Kazi Nabiul Alam, Md Shakib Khan, Sami Bourouis, Mohammad
Monirujjaman Khan, "Development of an IoT-Based Sleep Apnea Monitoring System for
Healthcare Applications", Computational and Mathematical Methods in Medicine, vol. 2021,
Article ID 7152576, 16 pages, 2021. https://doi.org/10.1155/2021/7152576
[17] Boe, AJ, McGee Koch, LL, O'Brien, MK et al. Automating sleep stage classification using
wireless, wearable sensors. npj Digit. Med. 2, 131 (2019).
https://doi.org/10.1038/s41746-0190210-1
[18] Karmakar NC, Yang Y., Rahim A. (2018) Wireless Monitoring of Sleep Apnea Patients. In:
Microwave Sleep Apnea Monitoring. Series in BioEngineering. Springer, Singapore.
https://doi.org/10.1007/978-981-10-6901-7_3
[19] WireLESS Is More Sometimes with Polysomnography Systems
https://www.sleepreviewmag.com/sleep-diagnostics/in-lab-tests/polysomnography/wireless-psg/
[20] A Systematic Review of Detecting Sleep Apnea Using Deep Learning [Electronic resource]. –
2019. – Mode of access to the resource: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6891618/
Access date: 06/05/2020
[21] Liu, Cheng &amp; Weng, Tongfeng &amp; Liu, Xinhua. (2018). ResSleepNet: Automatic sleep stage
classification on raw single-channel EEG. IOP Conference Series: Materials Science and
Engineering. 466. 012101. 10.1088/1757-899X/466/1/012101.
[22] Sors, Arnaud &amp; Bonnet, Stephane &amp; Mirek, Sebastien &amp; Vercueil, Laurent &amp; Payen,
JeanFrançois. (2018). A convolutional neural network for sleep stage scoring from raw single-channel
EEG. Biomedical Signal Processing and Control. 42. 107-114. 10.1016/j.bspc.2017.12.001.
[23] O. Tsinalis, PM Matthews, and Y. Guo, “Automatic Sleep Stage Scoring Using Time-Frequency
Analysis and Stacked Sparse Autoencoders,” Ann. of Biomedical Eng., vol. 44, no. 5, pp. 1587–
1597, 2016.
[24] T. Lajnefet al., “Learning machines and sleeping brains: Automatic sleep stage classification using
decision-tree multi-class support vector machines,” J. of Neuroscience Methods, vol. 250, pp. 94–
105, 2015.
[25] CS Huang et al., “Knowledge-based identification of sleep stages based on two forehead
electroencephalogram channels,” Frontiers in Neuroscience, vol. 8, p. 263, 2014.
[26] S. G ̈une, K. Polat, and e. Yosunkaya, “Efficient sleep stage recognition system based on EEG
signal using k-means clustering based feature weighting,” Expert Syst. with Applicat., vol. 37, no.
12, pp. 7922–7928, 2010.
[27] Liu WT, Wu Ht, Juang JN, Wisniewski A, Lee HC, Wu D, et al. (2017) Prediction of the severity
of obstructive sleep apnea by anthropometric features via support vector machine. PLoS ONE
12(5): e0176991. https://doi.org/10.1371/journal.pone.0176991
[28] A. Supratak, H. Dong, C. Wu and Y. Guo, "DeepSleepNet: A Model for Automatic Sleep Stage
Scoring Based on Raw Single-Channel EEG," in IEEE Transactions on Neural Systems and
Rehabilitation Engineering, vol. 25, no. 11, pp. 1998-2008, Nov. 2017, doi:
10.1109/TNSRE.2017.2721116.
[29] Kaguara, Antony &amp; Nam, Kee &amp; Reddy, Siddarth. (2014). A deep neural network classifier for
diagnosing sleep apnea from ECG data on smartphones and small embedded systems.
10.13140/2.1.4174.5448
[30] Stephansen, Jens &amp; Zahid, Alexander &amp; Olsen, Mads &amp; Ambati, Aditya &amp; Leary, Eileen &amp; Moore,
Hyatt &amp; Carrillo, Oscar &amp; Lin, Ling &amp; Han, Fang &amp; Yan, Han &amp; Sun, Yun &amp; Dauvilliers, Yves &amp;
Scholz, Sabine &amp; Barateau, Lucie &amp; Högl, Birgit &amp; Stefani, Ambra &amp; Hong, Seung &amp; Kim, Tae
&amp; Pizza, Fabio &amp; Mignot, Emmanuel. (2018). Neural network analysis of sleep stages enables
efficient diagnosis of narcolepsy. Nature Communications. 9. 10.1038/s41467-018-07229-3.
[31] Phan, Huy &amp; Andreotti, Fernando &amp; Cooray, Navin &amp; Chén, Oliver &amp; de Vos, Maarten. (2019).</p>
      <p>SeqSleepNet: End-to-End Hierarchical Recurrent Neural Network for Sequence-to-Sequence
Automatic Sleep Staging. IEEE Transactions on Neural Systems and Rehabilitation Engineering.
27. 400 - 410. 10.1109/TNSRE.2019.2896659
[32] Sleep-EDF Database [Electronic resource] - Resource access mode:
https://www.physionet.org/content/sleep-edfx/1.0.0/ Access date: 06/05/2020</p>
    </sec>
    <sec id="sec-5">
      <title>5. Appendix</title>
      <p>CNN-CRF</p>
    </sec>
  </body>
  <back>
    <ref-list />
  </back>
</article>