0% found this document useful (0 votes)
8 views

Design of Smart Wearable System For Sleep Tracking Using SVM and MultiSensor Approach

The document discusses the design of a smart wearable system for sleep tracking using multiple sensors and machine learning techniques. It aims to develop an affordable, portable, and easy-to-use system for measuring sleep quality and detecting sleep stages. The system uses sensors to monitor vital signals like heart rate and oxygen levels during sleep. Machine learning algorithms are then used to analyze the sensor data and classify sleep into different stages.

Uploaded by

Andrew Hernandez
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Design of Smart Wearable System For Sleep Tracking Using SVM and MultiSensor Approach

The document discusses the design of a smart wearable system for sleep tracking using multiple sensors and machine learning techniques. It aims to develop an affordable, portable, and easy-to-use system for measuring sleep quality and detecting sleep stages. The system uses sensors to monitor vital signals like heart rate and oxygen levels during sleep. Machine learning algorithms are then used to analyze the sensor data and classify sleep into different stages.

Uploaded by

Andrew Hernandez
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

JES, Vol. 51, No. 4, July 2023 DOI: 10.21608/JESAUN.2023.205964.

1220 Part B: Electrical Engineering

Design of Smart Wearable System for Sleep Tracking Using SVM and Multi-
Sensor Approach
Received 14 April 2023; Revised 07 May 2023; Accepted 08 May 2023

Mohammed M. Abo-Zahhad 1 Abstract


Moaz Elsayed 2 Healthcare has been considered one of the main issues to be spotted and
Abdelrahman Fawaz 2 improved in a high manner. Thus, many technology trends are customized for
Ahmed H. Abd El-Malek 2 healthcare. One of the fields that highly affects health is sleeping. Therefore, the
Mohammed S. Sayed 2 development of a portable and cost-affordable sleep-tracking system has arisen.
Ahmed Sharshar 2
This could be done by monitoring vital signals that affect sleep quality such as
Mohammed Abo-Zahhad 2
heart rate, blood oxygen saturation, and positioning. Furthermore, these signals
are used to detect sleep stages and sleep quality. In this paper, commercial off-
the-shelf sensors are used to develop a sleep quality monitoring system. The
aim is to make it cheap, portable, lightweight, and easy to use with good sleep
Keywords
quality and sleep stage detection. REM and NREM sleep cases are also
investigated based on EEG signals which measure brainwaves. So, two types of
Internet of Things;
Wearable electronics; delta waves that occur during REM sleep are differentiated. Slower (2 Hz)
waves were recorded in the medial-occipital areas that are present in both
Sleep tracking; Vital signs;
NREM and REM sleep, and quicker sawtooth waves (2.5-3 Hz), were present in
Sleep stages; Sleep quality;
REM sleep only. In the proposed system the heart rhythm is measured by ECG
Support vector machine.
signals using heart-rate sensors. ECG data is used to define REM and NREM
by monitoring the heart rate variability (HRV), which changes as a person
moves between light, deep, and REM sleep stages. In addition, the market-
available Amazfit T-Rex Pro watch is used for data labelling. Comparison with
similar systems shows that it performs better given its lower cost, lighter
weight, and smaller size. The obtained results indicate that sleep quality and
sleep stage accuracy are 97.5% and 67.5% respectively, which are better than
similar systems used with commercial off-the-shelf sensors.
.

1. Introduction

Recently, integration between the Internet of Things (IoT) and healthcare has risen and become
essential [1]. One of the fields that affect health in a high manner is sleeping, which is why
monitoring it was very demandable. Getting enough sleep with good quality is crucial to living a
healthy life. Therefore, quality of sleep could be one of the main issues that should be observed to
get a better daily life routine. Studies and research have linked the productivity and concentration of
people with getting good sleep hygiene. Furthermore, sleeping connects directly with several

1
Department of Electrical Engineering, Faculty of Engineering, Sohag University, Sohag Governorate, New Sohag
City, Egypt. [email protected]
2
Department of Electronics and Communications Engineering, Egypt-Japan University of Science and Technology,
New Borg El-Arab City, Alexandria, Egypt. (moaaz.elsayed, abdelrhman.fawaz, ahmed.abdelmalek, mohammed.sayed,
mohammed.zahhad}@ejust.edu.eg

https://doi.org/10.21608/JESAUN.2023.205964.1220
This is an open access article under the CC BY-NC-ND license (http://creativecommons.org/licenses/by-nc-nd/4.0/).
1
Mohammed M. Abo-Zahhad et al., Design of Smart Wearable System for Sleep Tracking Using SVM and Multi-Sensor …

functions performed by the brain such as concentration, productivity, and cognition. Sleep is
considered a brain activity used to release exhaustion [2].
The most common method of measuring sleep is polysomnography (PSG), which is regarded as the
standard for identifying sleep disorders [3]. SleepScore, the most sophisticated sleep monitor on this
list, measures sleeping patterns using sonar technology. According to PSG, there are multiple
distinct phases of sleep that alternate between non-rapid eye movement (NREM) and rapid eye
movement (REM) phases. Some sleep monitors use heart rate to estimate REM sleep as well as
deep and light sleep stages. Although it is well known that heart rate and respiration rate change
significantly while we sleep, they are closely correlated with each stage of sleep because the
autonomic nervous system has a big impact on both. About 20 to 25 percent of adult sleep time is
typically devoted to REM, which appears to be normal during typical sleep cycles. However, sleep
research is raising some interesting questions. With time, the disorder frequently gets worse.
Movement in response to exciting or violent dreams, such as being followed by an attack, maybe a
symptom of REM sleep behavior disorder. This movement may take the form of punching, kicking,
flailing arms, or jumping from bed. The brain activity, respiration, heart rate, blood pressure, and
eyelids move rapidly while closed during REM sleep. Antidepressants, for example, can reduce
REM sleep. People who smoke a lot frequently have light sleep and less REM sleep. After a few
hours, they might awaken from the effects of nicotine withdrawal. Around 90 minutes of the entire
sleep time, or the restorative sleep stage where dreams take place if one sleeps between seven and
eight hours each night, will be spent in REM sleep. Anything more than that puts your health at
excessive risk.

Fig. 1: Graphical representation of traces of the polysomnography technology [5].

Sleep monitoring could be accessed using a wide range of methods or systems that could be
wearable or non-wearable devices. One of the concepts that are tracked is sleep quality and it is the
measurement of how well you are sleeping—in other words, whether your sleep is restful or
restorative. It differs from sleep satisfaction, which refers to a more subjective judgment of how you
feel about the sleep you are getting. The most accurate one is the PSG laboratory test, shown in Fig.
1. This test depends on collecting several parameters that characterize sleep patterns. These
parameters are brain waves, heart rate, blood oxygen saturation, respiration, besides, positioning,

2
JES, Vol. 51, No. 4, Pp. 1 - 15, July 2023 DOI: 10.21608/JESAUN.2023.205964.1220 Part B: Electrical Engineering

and leg and arm movements. They are used aiming to distinguish between sleep stages.
Additionally, PSG could distinguish if the user struggles with any sleeping disorder, and the
collected data gives neat information that helps form a treatment plan. This system provides high
reliability; however, it is not portable and cannot be used in daily monitoring [4].
On the other hand, wearable devices that are used for sleep monitoring provide mobility and
portability while they have less accuracy than PSG. Many commercial sleep monitoring systems
vary between monitoring the quality of sleep and detecting sleep stages. The common point
between all these commercial devices is that they collect data and then transfer them directly to the
smartphone or laptop that they relate to. After that, these devices could perform complex analyses
and algorithms to get information from the gathered data [6]. The first proposed system is
actigraphy described in [7]. It is a device that looks like a wristband and could be worn on either
wrist or ankle. In addition, it has an accelerometer that is used to detect body movements and using
them to detect and calculate other sleep parameters. This type of device could figure out when you
fall asleep and wake up as well as the interval of sleep. These parameters based on observing
movements are useful to detect sleep disorders such as insomnia. People with such disorders have
problems with their sleeping habits as they have irregular sleep and wake-up times. On the other
hand, actigraphy has many limitations as it has not been confirmed to determine sleep stages.
Furthermore, the effectiveness of the system is decreased while monitoring poor sleep quality [8].
The second considered system is Fitbit [9], it is a wrist-worn activity tracker that records everyday
activities such as walking, running, swimming, and cycling. A 3-axis accelerometer is used in all
Fitbit trackers and watches to detect motion and other movements, with complex algorithms to
detect patterns of them. Additionally, it measures heart rate depending on the
photoplethysmography (PPG) signal. The data collected is used to detect the quality of sleep with a
specified score. Then, the gained information can be viewed via the Fitbit app. Fitbit has an
acceptable accuracy in comparison with PSG and could perform better than actigraphy in some
cases. It has been found that Fitbit underestimated total sleep time by 6.1 minutes, whereas the
actigraphy underestimated it by 31.5 minutes. From another perspective, Fitbit overestimated sleep
efficiency by 3.0% and actigraphy by 12.9% [10].
The third system is Oura Ring [11] which is a commercial device based on a smart ring and has the
most accurate sleep tracking system in comparison with other commercial systems. This ring has
sensors that measure health parameters and collect data that could be translated into information.
Then, the data collected is transferred to the company’s customized mobile application called Oura
App via Bluetooth. This smart ring gathers readings of acceleration and gyroscope, PPG signal, and
body temperature to detect sleep parameters. Oura Ring has high accuracy in determining the four
statuses of sleep represented awake, light sleep, deep sleep, and Rapid Eye Movement (REM) [12],
[13].
The fourth considered system is a device that uses COS sensors [2]. This system used an ADXL345
accelerometer for determining movements, MAX30100 to monitor heart rate, SpO2, and a
MAX9814 microphone amplifier. The system has three steps: 1) the collected data is transferred to
the used microcontroller, which is an Arduino, 2) this data is sent to a computer, and 3) the data will
be processed using a random forest classifier. These steps are used with the target of determining
the quality of sleep. It classified sleep quality as very unpeaceful, unpeaceful, medium, peaceful, or
very peaceful. This monitoring system has reached an accuracy of 95% in categorizing the sleep of
patients into these classes. However, the system has limitations as it is not a portable system.

3
Mohammed M. Abo-Zahhad et al., Design of Smart Wearable System for Sleep Tracking Using SVM and Multi-Sensor …

Furthermore, replacing Arduino with Raspberry Pi would enhance the system’s processing
capability without the need for an external computer.
In this paper, the proposed system comes in a similar design to a regular watch which provides
portability. Furthermore, it provides an enhancement as it could track sleep stages using COS
sensors. We have used a Support Vector Machine (SVM) that leads to better performance and a
robust system. The system detects body movements and uses them to detect and calculate sleep
parameters such as sleep onset latency (SOL), wake after sleep onset (WASO), total sleep time
(TST), and sleep efficiency (SE). The proposed system could figure out when you fall asleep and
wake up as well as the interval of sleep. So, based on observing movements, the system could detect
sleep disorders such as insomnia. The remaining parts of this paper are arranged as follows. Section
II provides the proposed system concepts, functions, and a brief background. Section III presents a
detailed description of the proposed system. In section IV, the proposed system prototyping results
are discussed. Section V concludes the paper.

2. The Proposed System Functions

In this section, we first provide an explanation of the main concept behind the suggested system as
well as all its functions. After spotting challenges and identifying recent advances in the area of
interest, many advancements appeared with feasible features and improvements to be considered.
We would start defining these features, how they are calculated, and the mathematical aspects
utilized in this demand.

2.1 Sleep Quality


As we have mentioned, sleep quality represents a vital parameter that could affect health in many
aspects. Thus, the importance of detecting factors that affect sleep quality has arisen considerably.
These factors are represented in having an irregular sleep schedule, a bad sleeping environment
such as being in a room that has too much noise or its light is blue light which enhances alertness,
drinking too much caffeine, and being diagnosed with a sleeping disorder such as insomnia or
obstructive sleep apnea (OSA) [14]-[15]. Although the notion of sleep quality has been widely used
in sleep medicine, it is not specified to a particular parameter. Many quantitative measures are
meant to be part of the concept of sleep quality. Examples of these measures are mentioned in [5] as
SOL, WASO, TST, and sleep efficiency (SE).
• SOL: represents the waking required to make the transition from full wakefulness to sleep.
• WASO: symbolizes the intervals of waking during the sleeping period and it could be
calculated as:

(1)

where NA represents the number of awakens in the interval between sleep onset (Son) which
represents the first time of falling asleep and sleep offset (Soff) which signifies the time of waking
up and cannot fall asleep again. Moreover, Awd(i) is the duration of the waking at instance i.
• TST: it is the total time of being asleep during the interval of bedtime. We can figure it out as the
duration from sleep onset to awake.

4
JES, Vol. 51, No. 4, Pp. 1 - 15, July 2023 DOI: 10.21608/JESAUN.2023.205964.1220 Part B: Electrical Engineering

TST = TIB – (SOL + WASO) (2)


where TIB is the bedtime.

• SE: it is defined as the amount of time you spend sleeping while in bed. It could be defined as
the percentage between total sleep time and bedtime.

SE = TST / TIB (3)

These parameters and measures are used to target a well understanding of the experience of
sleeping which will reflect the quality of sleep.

2.2 Sleep stages


Some fitness monitoring wearable manufacturers, such as Fitbit, have already integrated a sleep
detection capability for wearable devices. However, rather than just identifying whether a person is
sleeping, a more in-depth study might be performed to track one's health while sleeping. With this
type of analysis, the focus has shifted from the number of hours of sleep you get to how efficient
and restorative that sleep is. The sleep cycle's seamless passage through four different sleep stages
is critical to sustaining a healthy body. Table 1 shows the various stages of sleep. The classification
of these stages is based on an examination of brain activity during sleep and the patterns of nerve
signals [16]-[17]. Furthermore, the data collected based on heart rate, blood oxygen saturation, and
body movement could be an alternate technique to detect these stages. In addition, body
temperature is a factor as it got reduced while sleeping. Deeper sleep stages are also distinguished
by the reduced amount of oxygen required by the brain, resulting in a lower blood SpO2 level.
Another noteworthy aspect is that when stress levels change, so does the time distribution of sleep
stages, allowing for a more accurate and exact diagnosis of excessive stress. Additionally, body
temperature is decreased during sleep.

Table 1: Sleep Stages


Sleep Stages Type Alternative Name Duration (Minutes)
Stage 1 NREM N1 1-5
Stage 2 NREM N2 10-60
Stage 3 NREM Deep Sleep 20-40
Stage 4 REM REM Sleep 10-60

2.3 Measuring heart rate and blood Oxygen level


Heart rate is an important characteristic for sleep tracking for a variety of reasons. This is
considered crucial for anything from increasing sports performance to regulating stress levels to
tracking heart rate. Otherwise, it is considered a vital parameter in detecting stages of sleep without
the need to monitor brain activity. A light-emitting diode (LED) is used in heart rate sensors, paired
with an LED light sensor. The sensor's output is presented in beats per minute (BPM). The
operating premise of the heart rate sensor is to measure the time difference between periodic
changes in the volume of blood, knowing that oxygenated blood has more volume than
deoxygenated blood. The volume change, which occurs because of an increase in blood oxygen
levels with each heartbeat, is followed by a change in the fluid's reflection properties and is thus
detected indirectly via an optical sensor.

5
Mohammed M. Abo-Zahhad et al., Design of Smart Wearable System for Sleep Tracking Using SVM and Multi-Sensor …

In [18], an IoT-based smart wearable system for remote health monitoring adopted MAX30100 for
measuring heart rate and blood oxygen saturation. However, it suffers from many design problems
that make it operate improperly. We upgraded MAX30100 with MAX30102. MAX30102 has
higher storage, resulting in higher data transfer as it has 32-bit FIFO in comparison with the 16-bit
FIFO of MAX30100. It is more sensitive to changes in IR receiver voltage [19]. Thus, the
MAX30102 sensor consists of a pair of LEDs that emit monochromatic red light at a wavelength of
660 nm and monochromatic infrared light at 940 nm. The reason behind selecting these two specific
values is that oxygenated and deoxygenated hemoglobin, which is the protein molecule in red blood
cells that carry oxygen, exhibits different absorptive properties. This allows us to calculate the
proportion of oxygenated and deoxygenated hemoglobin present. Then, a pair of photodiodes
measure the portion of light of each wavelength that is reflected by the sensor and convert this to an
electrical signal. Using the Beer-Lambert principle, which relates the attenuation of light to the
properties of the material through which the light travels, a relation between absorbance and time
for both wavelengths is determined. These values are then converted to oxygen saturation levels
obtained from experimental data of healthy volunteers. Furthermore, a graph of the changing
volume can be plotted as shown in Fig. 2, indicating the change in blood volume with every
heartbeat or simply the blood oxygen saturation. Finally, the time difference between each heartbeat
is easily calculated by measuring the distances between peaks on the time-saturation graph.

2.4 Body Movements


The main idea of body movements is to detect any activity as it is a vital parameter with heart rate
to distinguish between awake or asleep, then, the detection of sleep stages. Furthermore, it could be
an indication of sleeping disorders such as OSA that may cause movement of legs or arms while
sleeping [20]. Thus, we used MPU9250 IMU which stands for Inertial Movement Unit, and
measures velocity, orientation, and gravitational force. This module depends on combining a 3-axis
accelerometer, 3-axis gyroscope, and 3-axis magnetometer and these nine different readings could
be used as indications for body movements. These nine different readings are correlated aiming to
identify movements of the wrist. Detecting these movements represents a vital factor in the process
of sleep tracking. First, the accelerometer measures acceleration and vibration. This could be done
through two main principles it could measure the displacement of mass or frequency of a vibrating
element. Second, since the gyroscope is mounted on a frame, it can detect angular velocity when the
frame is rotating. It could be used to detect deviation from the object orientation [21]. The third and
last element is the magnetometer, which detects the strength and direction of the magnetic field.
This could indicate the orientation [22].

2.5 Body Temperature


Providing a clinical-grade measurement of human body temperature is of substantial importance to
the indication of many health deviations. From fever diagnoses to basal body temperature
monitoring, the current developments in wearable thermometers have achieved a widespread set of
fundamental advantages. Furthermore, it has been monitored that there are slight differences
between body temperature in cases of being awake or asleep as it has been shown that while
sleeping body temperature is falling by one or two degrees. In this demand, they utilized a touchless
temperature sensor to detect the temperature by using an infrared thermometer for the detection of
temperature.

6
JES, Vol. 51, No. 4, Pp. 1 - 15, July 2023 DOI: 10.21608/JESAUN.2023.205964.1220 Part B: Electrical Engineering

Fig. 2: SpO2 Sensor Working Principle. [19]

3. The Proposed System

Figure 3 illustrates the proposed system architecture. The process of building the system can be
broken down into five primary stages: the first, or sensing stage, deals with collecting important
health signals utilizing MAX30102, MLX90614, and MPU9250 sensors. The second stage transfers
sensor readings using the I2C communication protocol to a centralized unit. This centralized unit
represents the third stage, and it is a powerful microprocessor (Raspberry Pi Zero W) that performs
the required data processing. In the next stage, we adopted a Support Vector Machine classifier that
uses the gained data to be trained to recognize patterns for further data processing. In the following,
a detailed description of the custom Printed Circuit Board (PCB), communication with Raspberry
Pi, data collection, labeling, pre-processing, and modelling will be described.

3.1 Custom Printed Circuit Board


The proposed sleep-tracking device is implemented on a double-layer PCB. As the need to make it
as small as possible to be portable, we customized the dimensions of the PCB to be the same as Pi
Zero W of dimension 65mm × 30mm. The used sensors are soldered on the top side to be on the
side facing the hand directly to access the data collection, while Raspberry Pi is spotted on the
bottom. Furthermore, we have designed and drawn tracks of SCL and SDA on the top layer as
shown in Fig. 4.a, whereas tracks of power and ground are on the bottom layer that appeared in Fig.
4.b.

7
Mohammed M. Abo-Zahhad et al., Design of Smart Wearable System for Sleep Tracking Using SVM and Multi-Sensor …

Fig. 3: Sleep Tracking System Architecture.

(a) Top Layer. (b) Bottom Layer.


Fig. 4: PCB Design

3.2 Communication Between Sensors and Raspberry Pi


This stage is considered the second stage in system architecture. The I2C communication protocol
is used to establish a connection between sensors and Pi. The two connection lines are SCL and
SDA. SCL is the line on which clock signals that are generated by the master devices and used to
synchronize the data are sent. SDA is the line that carries the actual data sent from master to slave
and vice versa. Every sensor has a specific address as shown in Table 2, as each device is allocated
to a unique address, thus, the master could choose the sensor to communicate with [23].

Table 2: I2C addresses of used sensors.


Device Address
MPU9250 0x68
MAX30102 0x57
MLX90614 0x5a

8
JES, Vol. 51, No. 4, Pp. 1 - 15, July 2023 DOI: 10.21608/JESAUN.2023.205964.1220 Part B: Electrical Engineering

3.3 Data Collection


This step is considered the first step in the system architecture. The sensor data collection application
is written in Python and uses existing sensor libraries. The application extracts the desired
parameters from the registers and saves them as a CSV file for further processing. The collected data
is going to pass through data processing aiming to extract information from them. The collected
parameters are:
• Accelerometer: (x, y, and z-axis) measured in gravitational force constant (g).
• Gyroscope: (x, y, and z-axis) measured in degrees per second.
• Magnetometer: (x, y, and z-axis) measured in metric gauss (G).
• Ambient temperature in Celsius.
• Object temperature (i.e., skin temperature) in Celsius.
• Heart rate pulses in beats per minute (bpm).
• Blood oxygen saturation (%SPO2).

The collected data has two classifications. The first one distinguishes between being awake or
asleep. The importance of this classification is raised from the need to differentiate between being
in bed and when you fall asleep. This is necessary to calculate sleep efficiency. The second
classification is to differentiate between sleep stages represented in light sleep, deep sleep, and
REM. Furthermore, the characteristics of the collected data are represented by the number of
samples, average age, and average hours of sleep as illustrated in Table 3.

Table 3: Data Summary.


No. of Participants Average Age Average Hours of Sleep
10 Participants 22 years 4 hours

3.4 Data Labeling


In this stage, we needed to use a reference device to label the collected data. Thus, we used Amazfit
T-Rex Pro Watch to differentiate between stages [24]. This watch has a heart rate sensor,
accelerometer, magnetometer, barometer for measuring air pressure, and ambient light sensors.
Most sleep tracker devices have accuracy in detecting stages of sleep that vary between 60% to 65%
[11]. However, Amazfit has an overall accuracy of determining sleep at 95.2% ± 0.36% in
comparison with actigraphy [25]. It could classify data into different stages based on body
movement, and heart rate. It is integrated with a mobile application called Zepp to display results.
The displayed results show TST by dividing it into stages with the interval of each stage. Then, we
labeled data as awake, light sleep (LS), deep sleep (DS), and REM based on reference results.

3.5 Data Pre-processing and Modelling


After finishing data labelling, we started to divide data into packets based on labelling. Data is
collected every second and this is the reason why we divided labelled data into packets and each
packet has 100 samples. This number of samples in each packet has been considered with the aim of
avoiding fluctuations that may occur while the process of data collection. As we have passed
through data labelling and utilizing reference data, we used a supervised machine learning model.
We trained algorithms based on the labelled data to be able to predict outcomes accurately. In this
phase, we used an SVM rather than a neural network, as it provides a robust system and better
performance. Moreover, it is better in the demand of the used dataset with a low number of samples

9
Mohammed M. Abo-Zahhad et al., Design of Smart Wearable System for Sleep Tracking Using SVM and Multi-Sensor …

because it avoids overfitting. In general, using simpler methods in the smaller dataset is better as it
leads to a more generalized model which prevents overfitting.
As the dataset may have many overlapping data, we have moved towards SVM. The idea behind it
is to make the best decision boundary that can classify n-dimensional space in a way that makes
further categorization for new data points. It may have different and several decision boundaries,
however, the best decision boundary is called the hyperplane of SVM. SVM chooses the extreme
points/vectors that help in creating the hyperplane. The methodology of it depends on moving data
from a relatively low dimension to a higher dimension to be able to classify them. This is done by
utilizing kernel functions to find SVM in higher dimensions. Furthermore, we have used a nonlinear
classifier as the data are not separated in a linear manner [26].
In the adopted model, we have used a grid search to get the most accurate results indicating the best
hyperparameters. This is done through hyperparameter tuning as it has several parameters. This
process is based on building and evaluating these different combinations of algorithm parameters.
Three major parameters need to be tuned to improve model accuracy. These parameters are:
• Kernels: As we have mentioned, data may appear to be overlapped and this is the reason why
we need to move it to a higher dimensional plane, especially in the case of nonlinear separation.
The main role of the kernel is to move the low-dimensional data into higher-dimensional data.
In our case, we have used a polynomial kernel.
• C: It is considered as the regularization parameter as it is used as the parameter of
misclassification or error term. This parameter is used to inform the SVM classifier how many
errors are accepted. It is used targeting to manage the trade-off between misclassification and
decision boundary. Higher values of C mean better classification of data points; however, a
higher chance of overfitting may occur.
• Gamma: It specifies how much the calculation of the line of separation is influenced. If gamma
has a higher value, it means a higher influence for nearby points, while lower values mean that
faraway points are also considered when determining the decision border.

3.6 REM and NREM Sleep Measurement


A healthy person experiences three to five REM cycles on average each night, with each episode
growing longer as the night progresses. The final one could go on for an hour or so. A good target
for healthy adults is to spend 20–25% of their time asleep in the REM state. Around 90 minutes of
the 7-8 hours of sleep should be REM. The electroencephalogram (EEG), which measures
brainwaves, is a simple method for detecting REM sleep. For tracking the signals travelling
throughout the brain, a headband is placed on the forehead. Because the normal latency to REM
sleep is 100 minutes, which is significantly longer than the average length of a routine EEG
recording of 20 to 30 minutes, REM sleep is typically not visible on routine EEGs. A sleep-onset
REM period (SOREMP), referred to as REM sleep during regular EEG, is regarded as abnormal
when it occurs. They differentiated two types of delta waves that occur during REM sleep: slower
(2 Hz) waves recorded in the medial-occipital areas that are present in both NREM and REM sleep,
and quicker (2.5-3 Hz), REM-sleep-only sawtooth waves.
In the proposed system the 3-axis accelerometer is used to determine the frequency, duration,
intensity, and patterns of the movement. It gathers the data and translates it into digital signals to
measure physical activity. This estimates the sleep stages using a combination of movement and
heart rate patterns. When you haven't moved for about an hour, your tracker or watch assumes that
you're asleep. The ECG measures the heart's electrical activity to find the heart rhythm assessment.

10
JES, Vol. 51, No. 4, Pp. 1 - 15, July 2023 DOI: 10.21608/JESAUN.2023.205964.1220 Part B: Electrical Engineering

For this purpose, the heart-rate sensor is used, so the system calculates how many times your heart
beats per minute (bpm). This data is used to define REM and NREM by monitoring the heart rate
variability (HRV), which changes as he moves between the stages of light sleep, deep sleep, and
REM sleep.

4. Results and Discussions

To find the system performance, 10 subjects are adopted for training and testing resources. In fact,
this number is small to yield good performance matrices. However, it is difficult to find more
people that accept the use of the proposed system during their sleep. This number is increased to
200 subjects using data augmentation techniques. To do that, data augmentation is used in this
paper by performing various transformations on the collected data. Flipping, rotating, and scaling
are used for this purpose to reduce overfitting and improve the model’s generalization performance,
Briefly, data augmentation is an essential tool for improving the accuracy and efficiency of the
proposed model data recognition, and classification [27]. Additionally, when the datasets are
unbalanced or the amount of training examples are insufficient to train the suggested model, data
augmentation is used. This is done to enhance the quantity and balance the data.
A confusion matrix is used to see how well the prediction model works [28]-[29]. The number of
predictions the model made when it properly or erroneously categorized the classes is indicated by
each entry in a confusion matrix. Table 4 presents the two classifications model results. It shows
that the proposed system has achieved acceptable results in terms of accuracy, precision, specificity,
F1 score, and recall.

Table 4: Classifiers results.


Awake/Asleep Sleep Stages Classifier
Parameters
Classifier Deep Sleep (DS) Light Sleep (LS) REM Overall
Accuracy (%) 97.5 % 88.0 % 84.8 % 65.2 % 79.3 %
Precision (%) 97.93 % 64.0 % 100.0 % 44.6 % 69.5 %
Specificity (%) 0.53 % 84.8 % 100.0 % 82.6 % 89.1 %
F1-Score (%) 98.71 % 78.1 % 84.8 % 35.2 % 66.0 %
Recall (%) 99.47% 100.0 % 73.5 % 29.0 % 67.5 %

The first classifier is used to differentiate between being awake or asleep. As displayed in the
confusion matrix shown in Fig. 5, if the true label is asleep, the predicted label indicates being
asleep. Due to the condition of lying down without being asleep, that will be mistaken for LS, being
awake in the true label illustrates that prediction matches the true label with an accuracy of 80%.
However, the classifier has achieved an accuracy of 97.5%. After differentiating between sleep
status, it could be used to determine intervals of TST and TIB. Based on these intervals, we could
measure sleep efficiency.
The second classification is used to detect sleep stages. LS represents a long interval of TST; thus,
LS is considered most data of the sample set. Furthermore, REM is only about 20% of total sleep
time and the heart rate could go up and down during this stage. Thus, it may be predicted LS while
its REM. However, it could differentiate between DS and LS in a high manner as the heart rate

11
Mohammed M. Abo-Zahhad et al., Design of Smart Wearable System for Sleep Tracking Using SVM and Multi-Sensor …

significantly gets dropped in the stage of DS. The confusion Matrix that visualizes the results is
shown in Fig. 6.
As shown in Table 5, the two classifications have acceptable accuracy. Regarding the first
classification, the system has achieved an accuracy of 97.5% in separating between being awake or
asleep and consecutively, used in calculating sleep quality. The second classifier has achieved an
accuracy of 67.74% in detecting sleep stages comparable to Amazfit [11].

Table 5: Comparison between sleep tracking systems.


Amazfit [11], Oura Ring [11], COS System [2],
Features Proposed System
2021 2021 2020
Sleep Stages 60 % – 65 % 79 % – 79.3 %
Sleep Quality 95.2 % – 95 % 97.5 %

Confusion Matrix

190 4
Asleep
True Label

Awake 1 5

Asleep Awake
Predicted label
Fig. 5: The First Classifier Confusion Matrix.

Fig. 6: The Second Classifier Confusion Matrix.

12
JES, Vol. 51, No. 4, Pp. 1 - 15, July 2023 DOI: 10.21608/JESAUN.2023.205964.1220 Part B: Electrical Engineering

5. Conclusions

In recent years, sleep tracking was recognized as one of the most important applications in health
monitoring. In this paper, we proposed a wearable sleep-tracking device using COS sensors that
could determine sleep quality and sleep stages. We managed to make a device that meets the design
requirements of portability, lightweight, small size, and ease of use. The device comes in a similar
design to a regular watch, with the addition of multiple sensors and a powerful processing unit. We
used the collected data to build an SVM classifier. Then, we used Amazfit T-Rex Pro as a reference
for data labeling. For this purpose, we built two classifiers. The first one is used aiming to
differentiate between being asleep or awake and the classifier accuracy was 97.5 %. Based on this
classification, we could measure sleep efficiency as it is the percentage between TST and TIB. The
second classifier is used to distinguish between sleep stages. This classifier has an accuracy of
67.74 %, which is acceptable as we depend on COS sensors, besides, the most accurate system in
this demand achieves an accuracy of 79% [11]. However, the sleep quality of this system is not
provided instead the authors considered the heart rate accuracy and the heart rate variability (HRV).
The suggested system monitors the HRV or beat-to-beat variations in the user’s heart rate, which
change as he moves between the stages of light sleep, deep sleep, and REM sleep. The current study
can be extended in two directions. First, we might collect information on patients with OSA and
insomnia symptoms. This collected data could be used as a reference to estimate if the user is facing
any of these problems and based on the answer, it could warn him and direct readings to his doctor.
The second direction will be concentrating on improving system efficiency. Thus, we will need to
collect more data on people with different sleeping habits. Moreover, we could use PSG as the
reference for labelling which will reflect a higher accuracy.

References
[1] D. Pacheco, “How is actigraphy used to evaluate sleep?” Sleep Foundation, 01-Oct-2021. [Online].
Available: https://www.sleepfoundation.org/sleep-studies/actigraphy. [Accessed: 25-March-2023].
[2] K. Saleem, I. S. Bajwa, N. Sarwar, W. Anwar, and A. Ashraf, “IoT healthcare: Design of smart and
cost-effective sleep quality monitoring system,” Journal of Sensors, vol. 2020, pp. 1–17, 2020.
[3] Kushida CA, Littner MR, Morgenthaler T, Alessi CA, Bailey D, Coleman J, Friedman L,
Hirshkowitz M, Kapen S, Kramer M, Lee-Chiong T, Loube DL, Owens J, Pancer JP, Wise M.
Practice parameters for the indications for polysomnography and related procedures: an update
for 2005. Sleep. 2005 Apr;28(4):499-521.
[4] “Polysomnography (Sleep Study),” Mayo Clinic, 01-Dec-2020. [Online]. Available:
https://www.mayoclinic.org/tests-procedures/polysomnography/about/pac-20394877. [Accessed: 26-
25-March-2023].
[5] A. Crivello, P. Barsocchi, M. Girolami and F. Palumbo, "The Meaning of Sleep Quality: A Survey of
Available Technologies," in IEEE Access, vol. 7, pp. 167374-167390, 2019, DOI:
10.1109/ACCESS.2019.2953835.
[6] C. Lashkari, “How do wearables track sleep?,” News Medical, 27-Feb-2019. [Online]. Available:
https://www.news-medical.net/health/How-Do-Wearables-Track-Sleep.aspx. [Accessed: 26-25-March-
2023].
[7] J. L. Martin and A. D. Hakim, “Wrist actigraphy,” Chest, vol. 139, no. 6, pp. 1514–1527, 2011.
[8] A. Alakuijala, T. Sarkanen, T. Jokela, and M. Partinen, “Accuracy of actigraphy compared to
concomitant ambulatory polysomnography in narcolepsy and other sleep disorders,” Frontiers in
Neurology, vol. 12, 2021.

13
Mohammed M. Abo-Zahhad et al., Design of Smart Wearable System for Sleep Tracking Using SVM and Multi-Sensor …

[9] A. Hunt and C. McGinley, “What is a Fitbit and how does it work? Plus, everything you need to know
about setting up your Fitbit,” Womanandhome.com, 23-Jun-2021. [Online]. Available:
https://www.womanandhome.com/health-and-wellbeing/how-to-set-up-a-fitbit-a-guide-206915/.
[Accessed: 08-25-March-2023].
[10] S. Burkart, M. W. Beets, B. Armstrong, E. T. Hunt, R. Dugger, L. von Klinggraeff, A. Jones, D. E.
Brown, and R. G. Weaver, “Comparison of multichannel and single-channel wrist-based devices with
polysomnography to measure sleep in children and adolescents,” Journal of Clinical Sleep Medicine,
vol. 17, no. 4, pp. 645–652, 2021.
[11] M. Altini and H. Kinnunen, “The promise of sleep: A multi-sensor approach for accurate sleep stage
detection using the Oura Ring,” Sensors, vol. 21, no. 13, p. 4302, 2021.
[12] C. Crider, “Oura Ring: A comprehensive review,” Healthline, 25-Feb-2022. [Online]. Available:
https://www.healthline.com/health/ fitness/oura-ring. [Accessed: 27-25-March-2023].
[13] M. Asgari Mehrabadi, I. Azimi, F. Sarhaddi, A. Axelin, H. Niela-Vilén, S. Myllyntausta, S. Stenholm,
N. Dutt, P. Liljeberg, and A. M. Rahmani, “Sleep tracking of a commercially available smart ring and
smartwatch against medical-grade actigraphy in everyday settings: An instrument validation study,”
JMIR mHealth and uHealth, vol. 8, no. 10, 2020.
[14] D. Pacheco, “Improving sleep quality: How is it calculated?,” Sleep Foundation, 24-Jun-2021. [Online].
Available: https://www.sleepfoundation.org/sleep-hygiene/how-is-sleep-quality-calculated. [Accessed:
25-March-2023].
[15] Almazaydeh L, Elleithy K, Faezipour M. Obstructive sleep apnea detection using SVM-based
classification of ECG signal features. Annu Int Conf IEEE Eng Med Biol Soc. 2012;2012:4938-41. doi:
10.1109/EMBC.2012.6347100. PMID: 23367035.
[16] Fell, Jürgen, J. Röschke, and C. Schäffner "Discrimination of sleep stages: a comparison between
spectral and nonlinear EEG measures." Electroencephalography and Clinical Neurophysiology 98.5
(1996): 401-410.
[17] M. El-Diasty, “An accurate heading solution using MEMS-based gyroscope and Magnetometer
Integrated System (preliminary results),” ISPRS Annals of the Photogrammetry, Remote Sensing and
Spatial Information Sciences, vol. II-2, pp. 75–78, 2014.
[18] M. Abo-Zahhad, M. S. Sayed and A. H. Ahmed H. Abd El-Malek, "An IoT-based Smart Wearable
System for Remote Health Monitoring," 2021 9th International Japan-Africa Conference on Electronics,
Communications, and Computations (JAC-ECC), 2021, pp. 192-197, DOI: 10.1109/JAC-
ECC54461.2021.9691431.
[19] “MAX30100 - heart rate oxygen pulse sensor,” Components101. [Online]. Available:
https://components101.com/sensors/max30100-heart-rate-oxygen-pulse-sensor-pinout-features-
datasheet. [Accessed: 25-March-2023].
[20] Suni, E. and Vyas, N., 2021. Stages of Sleep - Sleep Foundation. [online] Sleepfoundation.org.
Available at: <https://www.sleepfoundation.org/how-sleep-works/stages-of-sleep> [Accessed 25-
March-2023].
[21] I. Arun Faisal, T. Waluyo Purboyo, and A. Siswo Raharjo Ansori, “A review of accelerometer sensor
and gyroscope sensor in IMU sensors on motion capture,” Journal of Engineering and Applied
Sciences, vol. 15, no. 3, pp. 826–829, 2019.
[22] M. El-Diasty, “An accurate heading solution using MEMS-based gyroscope and Magnetometer
Integrated System (preliminary results),” ISPRS Annals of the Photogrammetry, Remote Sensing and
Spatial Information Sciences, vol. II-2, pp. 75–78, 2014.
[23] Conference on Communications, Signal Processing, and their Applications (ICCSPA), 2021. Available:
10.1109/iccspa49915.2021.9385761 [Accessed 25-March-2023].
[24] A. Siddiqui, “Huami Amazfit GTS review: Surprisingly different from the Apple Watch,” xda, 14-Dec-
2019. [Online]. Available: https://www.xda-developers.com/huami-amazfit-gts-review-surprisingly-
different-apple-watch-fitness-tracker-smartwatch/. [Accessed: 25-March-2023].
[25] J. Cheung, J. M. Zeitzer, H. Lu, and E. Mignot, “Validation of minute-to-minute scoring for sleep and

14
‫‪JES, Vol. 51, No. 4, Pp. 1 - 15, July 2023‬‬ ‫‪DOI: 10.21608/JESAUN.2023.205964.1220‬‬ ‫‪Part B: Electrical Engineering‬‬

‫‪wake periods in a consumer wearable device compared to an actigraphy device,” Sleep Science and‬‬
‫‪Practice, vol. 2, no. 1, 2018.‬‬
‫]‪[26‬‬ ‫‪T. Evgeniou and M. Pontil, “Support Vector Machines: Theory and applications,” Machine Learning‬‬
‫‪and Its Applications, pp. 249–257, 2001.‬‬
‫]‪[27‬‬ ‫‪Alomar K, Aysel HI, Cai X. Data Augmentation in Classification and Segmentation: A Survey and‬‬
‫‪New Strategies. Journal of Imaging. 2023 Feb 17;9(2):46.‬‬
‫]‪[28‬‬ ‫‪Joydwip Mohajon, Confusion Matrix for Your Multi-Class Machine Learning Model, 2020. [Online].‬‬
‫‪Available:‬‬ ‫‪https://towardsdatascience.com/confusion-matrix-for-your-multi-class-machine-learning-model-‬‬
‫‪ff9aa3bf7826 [Accessed: 25-March-2023].‬‬
‫]‪[29‬‬ ‫‪Bharathi, Latest Guide on Confusion Matrix for Multi-Class Classification, 2023. [Online]. Available:‬‬
‫‪https://www.analyticsvidhya.com/blog/2021/06/confusion-matrix-for-multi-class-classification/ [Accessed: 25-‬‬
‫‪March-2023].‬‬

‫تصميم نظام ذكي يمكن ارتداؤه لتتبع النوم باستخدام آلة متجهية داعمة ونهج متعدد المستشعرات‬

‫تعتبر الرعاية الصحية إحدى القضايا الرئيسية التي يجب رصدها وتحسينها بطريقة عالية‪ .‬وبالتالي‪ ،‬يتم‬
‫تخصيص العديد من اتجاهات التكنولوجيا للرعاية الصحية‪ .‬النوم هو أحد المجاالت التي تؤثر بشكل كبير على‬
‫الصحة‪ ، .‬لذلك برزت أهمية تطوير نظام محمول لتتبع النوم وبأسعار معقولة‪ .‬ويمكن القيام بذلك عن طريق‬
‫مراقبة اإلشارات الحيوية التي تؤثر على جودة النوم مثل معدل ضربات القلب‪ ،‬وتشبع الدم باألكسجين‪ ،‬وتحديد‬
‫المواقع‪ .‬عالوة على ذلك‪ ،‬تُستخدم هذه اإلشارات للكشف عن مراحل النوم ونوعية النوم‪ .‬في هذه الورقة‪ ،‬يتم‬
‫صا ومحمو ًال‬
‫استخدام مجسات تجارية جاهزة لالستخدام لتطوير نظام مراقبة جودة النوم‪ .‬الهدف هو جعله رخي ً‬
‫ضا فحص حاالت نوم حركة‬
‫وخفيف الوزن وسهل االستخدام مع جودة نوم جيدة واكتشاف مرحلة النوم‪ .‬يتم أي ً‬
‫العين السريعة (‪ )REM‬وحركة العين غير السريعة (‪ )NREM‬استنادًا إلى إشارات تخطيط كهربية الدماغ‬
‫(‪ )EEG‬التي تقيس موجات الدماغ‪ .‬لذلك‪ ،‬يتم التمييز بين نوعين من موجات الدلتا التي تحدث أثناء نوم حركة‬
‫العين السريعة‪ .‬تم تسجيل موجات أبطأ (‪ 2‬هرتز) في المناطق القذالية الوسطى الموجودة في كل من نوم حركة‬
‫العين غير السريعة ونوم حركة العين السريعة‪ ،‬وتم تسجيل موجات مسننة أسرع (‪ 3-2.5‬هرتز) في نوم حركة‬
‫العين السريعة فقط‪ .‬في النظام المقترح يتم قياس إيقاع القلب عن طريق إشارات تخطيط القلب باستخدام أجهزة‬
‫استشعار معدل ضربات القلب‪ .‬ت ُستخدم بيانات تخطيط كهربية القلب لتحديد حركة العين السريعة وحركة العين‬
‫غير السريعة من خالل مراقبة تقلب معدل ضربات القلب (‪ ،)HRV‬والذي يتغير مع انتقال الشخص بين مراحل‬
‫النوم الخفيف والعميق ومراحل نوم حركة العين السريعة‪ .‬باإلضافة إلى ذلك‪ ،‬يتم استخدام ساعة ‪Amazfit T-‬‬
‫نظرا‬
‫ً‬ ‫‪ Rex Pro‬المتوفرة في السوق لتصنيف البيانات‪ .‬تظهر المقارنة مع األنظمة المماثلة أن أداءها أفضل‬
‫لتكلفتها المنخفضة ووزنها الخفيف وحجمها األصغر‪ .‬تشير النتائج التي تم الحصول عليها إلى أن جودة النوم‬
‫ودقة مرحلة النوم تبلغ ‪ %97.5‬و‪ %67.5‬على التوالي‪ ،‬وهي أفضل من األنظمة المماثلة المستخدمة مع أجهزة‬
‫االستشعار التجارية الجاهزة‪.‬‬

‫‪15‬‬

You might also like