1. Introduction
Poor sleep quality or disturbed sleep is associated with multiple health complications, including mental disorders [
1,
2,
3] and cardiovascular and cerebrovascular diseases [
4,
5,
6]. Obstructive sleep apnea (OSA) is one of the most common diseases affecting sleep quality. It is a condition caused by repeated episodes of upper airway collapse and obstruction during sleep, associated with arousals with or without oxygen desaturation [
7,
8,
9,
10]. These episodes can be of total occlusion (apnea) or partial occlusion (hypopnea) of the air pathways, leading to a total or partial reduction of the airflow [
11].
Sleep position is an important factor to consider when analyzing sleep quality and diagnosing OSA. Previous studies highlight the role of sleep position in the appearance of apneas, a phenomenon known as positional OSA (pOSA) [
12,
13]. In addition, the effect of sleep position on the ocular surface has also been assessed and related to the occurrence of different diseases such as dry eye, ocular hypertension, or glaucoma [
14,
15,
16].
Multiple different techniques can be used to determine sleep quality. For instance, questionnaires, such as the Pittsburgh sleep quality index (PSQI) [
17], the Epworth sleepiness scale [
18], the STOP-Bang questionnaire [
19] and the Berlin questionnaire [
20], among others [
21], are commonly used tools for assessing sleep quality. Questionnaires and self-reported information aim to predict the severity of multiple symptoms related to poor sleep quality, including snoring associated with OSA [
22,
23], daytime sleepiness or fatigue, which predict the risk of accidents [
24]. Yet, questionnaires and self-reported information fail to properly determine the different sleep positions [
25].
Other techniques, such as polygraphy and polysomnography (PSG), aim to assess the sleep quality in a more objective manner. These techniques determine the apnea-hypopnea index (AHI), which is an indicator related to the severity of OSA. This indicator calculates the number of apneas and hypopneas per hour of sleep. According to the American Academy of Sleep Medicine (AASM) [
11], the AHI classifies patients into four different categories: healthy (AHI < 5); mild OSA (5 ≤ AHI < 15); moderate OSA (15 ≤ AHI < 30) and severe OSA (AHI ≥ 30). Home respiratory polygraphy (HRP) uses less sensors than PSG, which is the gold-standard method of assessing sleep quality and position. Since PSG includes video-surveillance, it is used to validate the sleep position. However, it has some limitations: the sleep position is classified into only four categories (supine, prone, left and right); the level of sleep comfort is changed (different bed and pillow, and full of PSG wires); and the prevalence of the supine sleep position in PSG studies [
26,
27], which can affect the diagnosed severity of OSA. Therefore, many patients remain undiagnosed and untreated [
28,
29], worsening their long-term consequences.
There exist multiple treatments for sleep apnea [
30]. These treatments range from more invasive options, such as surgical correction of the air pathways structures to prevent occlusions, to less invasive treatments, such as continuous positive airway pressure (CPAP) [
31] or positional therapy [
32], which aims to force the patient to sleep in non-supine sleep positions to reduce the AHI index and increase the sleep quality. Yet, self-reported sleep position is unreliable and objective measures are required [
25].
In recent years, smartphones have been suggested as potential candidates with which to monitor sleep apnea, due to their prevalence and the range of embedded sensors [
33]. The appearance of sensing technologies related to sleep has also increased in the last 10 years [
34]. Multiple approaches using different combinations of these smartphone sensors to monitor sleep apnea have been documented, including previous work by our group. Some studies have made use of the embedded microphone sensor to diagnose and monitor sleep apnea [
35,
36,
37,
38], and others have used the embedded accelerometry sensor of the smartphone to monitor sleep apnea and position [
39,
40,
41]. The treatment of pOSA has also been researched with smartphone applications which vibrated when the patient slept in a supine position, to promote lateral sleep positions [
42]. Besides smartphones, there have also been multiple attempts to develop applications which could be used to monitor sleep apnea with minimal sensors, which include accelerometry [
43,
44,
45], audio [
35,
46], pulse oximetry [
47,
48] and other sensors [
49,
50,
51]. Finally, recent studies have shown the importance of a higher-resolution sleep position for the diagnosis of pOSA [
52], since there could exist pOSA variability within the four clinically used sleep position categories (supine, prone, left and right).
The aim of this study is to propose a higher resolution sleep position detector using triaxial accelerometry from smartphones. To accomplish this, we divided our study into three separate tasks: (1) study the feasibility of smartphones as sleep position monitors and develop algorithms to retrieve the sleep position angle from smartphone accelerometry; (2) monitor the sleep position angle in adult patients with obstructive sleep apnea (OSA); and (3) discretize the sleep angle into the four sleep positions to compare it with the sleep position from the video-validated polysomnography (PSG) and analyze the OSA event distribution (pOSA).
2. Materials and Methods
2.1. Hospital Database and Acquisition Protocol
The acquisition protocol used for all of the experiments in this study was approved by the ethics committee from the Hospital Clínic of Barcelona and conducted with OSA patients. Two different devices were used simultaneously to record the sleep position during night-time acquisitions at the Sleep Lab in the Hospital Clínic of Barcelona. The reference device, a ‘Grael PSG’ (Compumedics, Melbourne, Australia), recorded the sleep position using the company’s proprietary algorithms at a sampling frequency of 32 Hz. The equipment was positioned according to the standard procedure. The second device, a Samsung S5 SM-G900F Android 6.0.1 smartphone (Samsung, Seoul, South Korea), was used as the test device. It recorded triaxial accelerometer data with its embedded MPU-6500 sensor at a sampling frequency of 200 Hz using the Sensors Logger application [
53]. This application saves the data in the smartphone memory as a text file. The smartphone was placed over the sternum and held in position with an elastic strap as seen in
Figure 1a, based on the configuration proposed by Nakano et al. [
35], which has been tested successfully in previous publications of our group [
36,
37,
38,
40,
41]. This configuration resulted in the smartphone triaxial accelerometry providing positive values when accelerations occurred from right to left (X-axis), from toe to head (Y-axis), and from front to back (Z-axis), as seen in
Figure 1b. The smartphone was used in flight mode, and with the Wi-Fi and Bluetooth options disabled.
The acquisition protocol described above was used to register 20 different OSA patients. The inclusion criteria were based upon medical examination of the medical doctors from the sleep lab in the Hospital Clínic of Barcelona. This medical examination aimed to obtain a gender-age-balanced database with patients with different AHI severity indexes. At random, 20 patients were included with mild to severe obstructive sleep apnea diagnosed by a full PSG performed in the previous 2 months. The exclusion criteria were: Patients with hypoventilation, central sleep apnea (Cheyne Stokes), uvulopalatopharyngoplasty, very severe nasal obstruction or in those who refused their consent. For technical reasons, one of the patients had to be discarded. Therefore, the database used for analysis is composed of 9 men and 10 women, with an average age of 60 (38–78) and an average AHI of 34 (6–70). Automatic PSG sleep positions were video-validated by sleep technicians, and automatic and validated positions were both saved separately. The patients were asked to rest in the supine position for some minutes at the beginning of the test. The minimum final valid duration for each patient was five hours of sleep.
2.2. Signal Preprocessing
The automatic and video-validated sleep positions obtained from the PSG were exported in .edf file format and the smartphone triaxial accelerometry was stored in .txt files. The three position signals were processed and analyzed using custom developed algorithms in MATLAB r2019b (Mathworks Inc., Natick, MA, USA).
The PSG signals were upsampled to 200 Hz and the signals from the two devices were automatically synchronized with the beginning and end timestamps of each file. Initial and final regions with no overlap between signals were discarded. The first and last 10 min were also removed due to artifacts related to equipment placement and displacement, respectively.
2.3. Sleep Position Monitoring: Sleep and Stand Angles
The algorithm described in this subsection aims to retrieve the sleep position angle, which allows us to obtain a more precise sleep position with better control of the position shifts. To calculate the sleep angle from the triaxial accelerometry the following steps were performed:
Each of the triaxial accelerometer signals (X, Y, and Z) was filtered with a median filter with a window of 60 s to remove high-frequency noise and keep the signal baseline containing the gravity acceleration.
For each sample of the triaxial accelerometry, two different angles were calculated using (1): the sleep position angle and the stand angle.
- 2.1.
The sleep position angle was used to determine the four sleep positions (supine, prone, left and right). It was calculated by (1), where
, with
and
being the values of the X and Z axis of the triaxial accelerometry at each specific timestamp;
, which is a static reference aligned with the left sleep position; and
, to be able to differentiate supine and prone positions. This angle explains the orientation of the accelerometry in the X-Z plane as shown in
Figure 1b.
- 2.2.
The stand angle was used to determine whether the patient is in a standing or lying position. It was calculated by (1), where
, with
and
being the values of the
Y and
Z axis of the triaxial accelerometry at each specific timestamp;
, which is a static reference aligned with the stand position; and
, to be able to differentiate stand and headstand positions. This angle explains the orientation of the accelerometry in the Y-Z plane, as shown in
Figure 1b.
Two different corrections were made to ensure that the angles calculated provided the real patient position:
- 3.1.
Module correction: to avoid unreal position angle calculations, due to small angle value variations in close-to-zero module vectors, both the sleep and stand angle values were replaced with their last module-correct angle value if the following criteria was found true:
where
is a threshold with a value of 0.5;
belongs to the
vectors declared for the sleep and stand angles in the steps 2.1 and 2.2 of this subsection; and
, with
,
and
being the values of the X, Y and Z axis of the triaxial accelerometry at each specific timestamp.
- 3.2.
Initial position correction: the supine positions in the first 10 min of the triaxial accelerometer signals were used to automatically self-correct the differences in smartphone placement due to anatomical variations in patients. The correction consisted of detecting the values of the angles associated with the supine positions within these initial 10 min and subtracting these values to correct the sleep and stand angles of the remaining data. Both the initial sleep and stand angles of the corrected position were 90° after the correction for the supine sleep position.
2.4. Discretization of Sleep and Stand Angles
The discretization of the sleep and stand position monitoring angles was performed to compare the positions obtained from the smartphone with the video-validated positions from the PSG system. To classify the angles into the four sleep positions, threshold values of −140°, −40°, 60° and 120° were used to segment the 360° circle in the X-Z plane, as described in
Figure 1b,c. Threshold values of −135°, −45°, 45° and 135° (
Figure 1d) were used to segment the 360° circle in the Y-Z plane (
Figure 1b) and classify the stand angles into two categories: standing (either stand or headstand) and lying. The thresholds used for the discretization of the X-Z and Y-Z planes were empirically set to mimic the criteria used by the sleep technicians to score the sleep position from the PSG video. Since a sleep position could not occur at the same time as a standing position, classification as standing overrides a simultaneously classified sleep position. For this reason, an extra rule was applied to determine the stand position to ensure that it was calculated with a non-close-to-zero vector module in the Y-Z plane. This rule was based on the following equation:
where
and
equal 0.8;
is the vector
described in step 2.1;
is the vector
described in step 2.2; and
is the vector
described in step 3.1, all of them in the subsection “Sleep Position Monitoring: Sleep and Stand Angles”.
2.5. Sleep Position Validation: Agreement by Patient
To investigate the agreement between the PSG and the smartphone, and the effect of the discretization (detailed in subsection “Discretization of Sleep and Stand Angles”), the smartphone initial correction (detailed in step 3.2 of the subsection “Sleep Position Monitoring: Sleep and Stand Angles” in this study) and the PSG video correction, we made three different comparisons for each patient:
The automatic smartphone accelerometry position vs. the validated hospital position: this analysis was made to compare the position obtained from the discretized smartphone angles, without the initial position correction, to the hospital video-validated reference position.
The automatic smartphone accelerometry corrected position vs. the validated hospital position: this analysis was made to compare the position obtained from the discretized smartphone angles with the initial position correction to the hospital video-validated reference position.
The automatic hospital position vs. the validated hospital position: this comparison served to understand how the corrections introduced by sleep technicians can improve the automatic sleep position from the PSG system.
For each of these pairwise comparisons, the percentage agreement between the two sleep positions was calculated for each patient. The sleep position vectors were compared sample-by-sample with the following equation:
where
is the vector with the position to be tested from the three comparisons;
is the reference position vector, which is the hospital video-validated position; and
N is the total number of samples.
2.6. Sleep Position Validation: Agreement by Position
To validate how accurately each position was detected, we calculated the confusion matrix comparing sample-by-sample the four sleep positions and the stand position between the automatic smartphone accelerometry corrected position (test) and the validated hospital position (reference). The confusion matrix explains how many minutes were correctly and incorrectly classified for each position.
To assess how well each position was detected, we calculated the sensitivity (Se), specificity (Sp), positive predictive value (PPV), negative predictive value (NPV), and accuracy (Acc) from the information in the confusion matrix with the equations below:
where
denotes the minutes in which the position is correctly detected in both the smartphone and PSG devices (e.g.,
);
the minutes in which the position is correctly not detected in both devices (e.g.,
);
the minutes in which the position is incorrectly detected as another position in the test device (e.g.,
); and
the minutes in which the position is incorrectly detected as the specific position in question in the test device (e.g.,
).
2.7. Sleep Position Characterization: Angle Distribution
To understand the interaction between the sleep and stand angles and the discretization limits described in the subsection “Discretization of Sleep and Stand Angles”, we used the discretized automatic smartphone corrected position to group each sample of the sleep angle into four categories (supine, prone, left, and right) and the samples of the stand angle, which belonged to the stand position into one category (stand).
For each of these five categories, we calculated the mean angle, the standard deviation (std), and the percentage of time spent by the patient around a window of ±5°, ±10°, ±15°, ±20°, and ±25° from the corresponding PSG reference angle. These PSG reference angles were set according to the axis direction of the smartphone accelerometry used in this study. The reference angles were 90° in the supine position, 0° in the left position, ±180° in the right position, and −90° in the prone position for the sleep angle (
Figure 1c); and 0° and ±180° for the stand angle (
Figure 1d). The equation used to calculate the percentage of angles recorded around these windows centered at the reference angle position is as follows:
where
and
are the limits of the reference threshold ± the window value in degrees;
N the number of angle samples; and
each of the samples with an angle value.
2.8. OSA Events Related to Sleep Position Angle
To address the relevance of the sleep position to the occurrence of OSA events, we used the OSA events from the simultaneous PSG study and assessed their distribution across the different sleep positions in the database.
For each patient, we calculated the percentage of time spent in a specific sleep position angle with the following formula:
where
provides the percentage of time spent in a specific sleep angle
θ;
N is the number of sleep position samples available;
represents each sleep position sample matching the criteria between brackets; and the
and
are the thresholds used around each sleep angle
θ, forming a window of 15° (
θ ± 7.5°). The evaluated sleep angles
θ ranged from −180° to 180° with 1° increase.
We also calculated the percentage of OSA events in a specific sleep position angle for each patient. To do this, we took each PSG event in the database and assigned to the event the median angle value from all sleep position angle samples which occurred during the event. We then determined the percentage of events occurring at a particular angle with the following formula:
where
is the percentage of events in a specific sleep angle
θ;
N is the number of events available;
represents the median angle linked to an event matching the criteria between brackets; and the
and
are the thresholds used around each sleep angle
θ with the same window and resolution as (11).
Finally, to determine the relationship between the occurrence of the events and the sleep position, two variables were calculated linked to their angle of occurrence: the local AHI and the ratio between the percentage of events and the percentage of position. These variables allowed us to estimate the severity of the OSA and to determine the sleep position angles with a greater incidence of events in comparison to the amount of time spent in that sleep position. The formulas used to calculate these two variables were as follows:
where the
provides an estimation of the AHI in a specific sleep angle
θ;
N is the number of events available;
represents the median angle linked to an event matching the criteria between brackets;
and
are the thresholds used around this angle with the same window and resolution as (11); the coefficient
is used to normalize the position to hours, taking into account the sampling frequency of the smartphone (200 Hz) and the conversion from seconds to hours (1 h = 3600 s); M is the number of sleep position samples available;
represents each sleep position sample matching the criteria between brackets; the
provides information about the occurrence of events at a specific sleep angle
θ; and
and
are the results from Equations (11) and (12) for each specific angle
θ.
To avoid high-value artifacts due to denominators being close to 0 in both the and variables, a minimum denominator value is used in both equations, which is 10 min for the and 1% for the . Moreover, the is smoothed with the mean value calculated from the window containing the previous and following two values.
5. Conclusions
Assessment of sleep position is an important step in polysomnographic (PSG) studies, since there is evidence that certain sleep positions or excessive position changes influence sleep quality. Nevertheless, sleep position is usually classified as one of only four different values: supine, prone, left, and right. In this study, we demonstrated how smartphones could be used as sleep monitoring devices. We calculated two different angles, which allowed us to determine the four sleep positions and the stand position with a higher resolution when compared to the PSG test. To validate the positions found with the smartphone, we performed simultaneous PSG-smartphone acquisitions in 19 patients. We then discretized the information from the smartphone angles into the four sleep positions to compare them with the manually video-validated positions from the PSG. We obtained a high average agreement (95.6%) in the detection of the positions and showed the dispersion of positions adopted by subjects for the non-supine sleep positions. In addition, we observed that the occurrence of OSA events in the lateral sleep positions varied depending on the distance of the sleep position from the supine position threshold. This highlights the fact that a higher resolution of sleep position is required to better assess pOSA.
The novel results presented in this study suggest that smartphones are promising mHealth tools for enhanced position monitoring at hospitals and at home.