STEM I

STEM I consists of an independent research project taught by Dr. C.

Reminder Device for People who Need and Forget to Use a CPAP

This project aims to create a device that can wake someone up who forgets to wear their CPAP to sleep. While the current prototype only alerts with an accuracy of 53.6%, the collected human data can be further analyzed to create a device that can improve the lives of people with Obstructive Sleep Apnea.

Abstract

Obstructive sleep apnea (OSA) is an illness characterized by airway blockages during sleep. 20% of people have moderate to severe symptoms, which are often treated by wearing a continuous positive air pressure (CPAP) device during sleep. However, people can forget to wear this device, leading to exhaustion and increased vehicular and workplace accident risk. While on-body alerts exist, they can be inconvenient. Consequently, this project aims to create a device that will wake people up if they fall asleep while not wearing a CPAP with minimal on-body sensor use. To detect apneas, respiratory movements were modeled in two ways: a fan-caused blanket’s movement and an orbital shaker’s movement. An ultrasonic sensor was pointed at the models when respiration was and was not simulated. The model to sensor distance also varied. In both models, respiration trials measured periodically varying distances, whereas no respiration measurements were more constant. This periodic movement could be used for a respiration detection algorithm. Additionally, substantial noise was found at higher distances. Therefore, lower distances, such as the 80-120cm range should be a main focus. The original code also measured less noise in the orbital shaker compared to the fan model. This difference implies that ultrasonic sensor measurements highly depend on environment. To circumvent environmental limitations, other kinds of sensors should be investigated as well as ways to ensure the user is not wearing a CPAP before alerts. These ultrasonic sensor measurements can be used to create a device, improving the quality of life of OSA patients.

infographic

Click Here for Research Proposal

Problem and Goal

People with Obstructive sleep apnea may forget to use a CPAP while they sleep, leading to symptoms such as exhaustion and an increased risk of car accidents.

Create a device that will accurately notify people at least 90% of the time if they are not wearing their CPAP with minimal use of on-body sensors.

Introduction

infographic

20% of people have moderate to severe obstructive sleep apnea (OSA), an illness characterized by episodic airway blockages during sleep (Mayo Clinic, 2020; Stevens et al., 2020). In the short term, these blockages cause symptoms such as exhaustion, excessive daytime sleepiness, and headaches, increasing risk for workplace and vehicular accidents (Kerner & Roose, 2016; Lin & Suurna, 2018; Mayo Clinic, 2020). To combat OSA symptoms, a continuous positive air pressure (CPAP) device is given to the patient to use while they sleep; however, people with OSA may forget to consistently wear a CPAP, hindering treatment (Lin & Suurna, 2018). While current solutions can detect apneas with an accuracy of over 90%, many require on-body sensors, which can be inconvenient (Niroshana et al., 2021). The aim of this project is to mitigate the chance that someone who relies on a CPAP accidentally falls asleep without using one.

Treatment

While the symptoms of untreated OSA can be severe, treatments for OSA can substantially improve a patient’s condition. The most effective treatment for moderate to severe OSA is a continuous positive air pressure (CPAP) device, which forces the airway open (Lin & Suurna, 2018). Other options include surgery, sleep position change, and oral appliance use.

CPAP use has many benefits. A main advantage is that CPAP use alleviates daytime sleepiness, reducing the chance that someone will trip and falls. Consistent CPAP use for more than four hours also has been proven to reduce the chance of getting into a motor vehicle accident by 70% compared to untreated OSA (Karimi et al., 2015). Furthermore, using this treatment regularly can delay dementia onset by eight years (Kerner & Roose, 2016). For people who have both Chronic Obstructive Pulmonary Disease (COPD) and OSA, also known as overlap syndrome, Marin et al. (2010) showed that consistent CPAP use can lengthen life and prevent COPD exacerbations. In specific, Marin et al. (2010) followed approximately 600 people; one group had only COPD, another had overlap treated with CPAPs, and the last had overlap not treated with CPAPs. The median follow up was 9.4 years. As seen in the introduction infographic, the overlap with CPAP and the COPD curves differ by at most 10%, but people who have overlap and do not use a CPAP have a survival and exacerbation-free survival rate that is about 20% lower by the end of 12 years. While CPAPs mitigate the symptoms of OSA, prescribed CPAP use for more than seven hours a night has a compliance rate of 34.1% mostly because many find CPAPs uncomfortable (Rotenberg et al., 2016; Stevens et al., 2020).

However, even those who like and need to use CPAPs while they sleep may forget to use them. Some studies estimate that 90% of men and 78% of women over 65 years old have OSA (Lin & Suurna, 2018). People who are over 75 years old tend to take more medications and have more illnesses that impair cognitive function compared to the general population (Smaje et al., 2018). These factors are associated with decreased medication adherence, potentially because decreased cognitive function or complex medication schedules can cause people to forget to take all their medicine correctly.

Current and Possible Solutions

Devices exist that can prevent people from forgetting to use a CPAP. Although few have been made that include alarms, many, such as oximeters, electrocardiograms (ECGs), cameras, and doppler radars, could alert people given that alarms were included.

Oximeters measure oxygen saturation levels, which drop when someone experiences apneas though the metric is imperfect (Singh et al., 2020). Oximeters and smartwatches can monitor and alert people when oxygen saturation levels have fallen below a healthy point. Oximeters work by shining light through skin and analyzing the reflections since oxygenated blood reflects light differently from deoxygenated blood. However, movement and ambient temperature affect light reflection, meaning everyday use of an oximeter would likely cause inaccuracy (United States Food and Drug Administration, 2022). Oximeters also tend to be less accurate for people with darker skin because of the differences in light reflection. One way to mitigate the effects of movement artifacts would be to use an accelerometer, and oximeters could be tested more to account for different skin tones. Nevertheless, FDA-approved sensors have a margin of error of 4% in real-world scenarios. Because oximeters rely on calculations and light to derive oxygen levels, oximeters can even be inaccurate in resting positions, leading to false positives that may annoy the user. In addition, even if an oximeter works perfectly, wearing a bracelet or sensor every day for an event (such as accidentally falling asleep watching TV) that may not occur often could be undesirable. As a result, a major criterion for this project is that it does not use on-body sensors. Also, oximeters have been used with other algorithms in order to detect sleep apnea in patients as a screening method (Wu et al., 2021). Many screening methods require at least minutes of apneic or hypopneic behavior; however, detecting apneas and hypopneas to alert patients would require that the patient has already fallen asleep and is experiencing OSA symptoms.

Another method includes using an electrocardiogram (ECG) to detect sleep apnea and alert people (Niroshana et al., 2021). One study uses a single-lead ECG to obtain time-frequency graphs of cardiovascular functions and compare apneic time segments to non-apneic time segments. While this method has an accuracy rate of 92% when tested with a dataset of 20,000 non-apneic and 13,000 apneic 1-minute time segments, wearing contact sensors every night can cause mental stress (Kagawa et al., 2016; Niroshana et al., 2021). As a result, this project will also aim to notify people that they fell asleep without wearing a CPAP with an accuracy of at least 90%.

Also, one could instead detect drowsiness using a camera, similar to methods to detect drowsy driving (Malla et al., 2010). Malla et al. (2010) tracked blink rates as well as the amount of time that a person’s eyes were closed to determine drowsiness. In the case relating to OSA, one could either attach a camera to the head or use one from a distance. The benefits of these approaches include being able to prevent OSA from fragmenting someone’s sleep since they could be warned before they fall asleep. A patient would also not need to worry about having to put a remote camera on, so it would be a low-maintenance way to increase CPAP compliance. However, eye tracking may be inaccurate, especially from a distance. In addition, the camera would have to account for low-light level situations. On top of this, a remote camera alone would only be able to detect sleep from certain angles unlike an on-body sensor and using a remote camera would at best improve CPAP compliance in the places that someone is most likely to fall asleep.

Going with the non-contact approach, one study decided to use doppler radars to track breathing patterns and, therefore, diagnose OSA (Kagawa et al., 2016). Doppler radars use microwave rays, which could be a safety concern, and distance and environment greatly impact the sensor signal. Another approach is to attach an alarm to a CPAP that will detect whether someone is using it or not. However, this would only warn at set times and would not catch when people fall asleep at non-standard times. All of these methods so far have been made for use with mattresses. However, people can fall asleep in areas other than mattresses, leading to the major criterion that the device can be used in the places where someone is most likely to fall asleep.

Main Approach

Similar to Kagawa et al. (2016), the main approach for this project was to use ultrasonic sensors to send high frequency sounds, measuring respiratory movements. An ultrasonic sensor is a device that sends out a high frequency sound and measures the amount of time it takes for the sound to return. This duration is commonly used to calculate the distance of the ultrasonic sensor from the object in front of it. To develop a prototype, the HC-SR04 ultrasonic sensor was used to detect apneas. Given that a person stays still apart from their breathing, it is expected that when someone inhales, an ultrasonic sensor pointed at their abdomen or chest will show a decrease in distance. Likewise, when that person exhales, it is expected that the distance will increase. This indirect relationship can be used to measure the lung movement displacements. According to Kagawa et al. (2016), lung movement displacement has a linear relationship with tidal volume—the quantity of air that the lungs receive or send with each breath (respiratory cycle). When an obstructive apnea occurs, the patient cannot fully inhale or exhale. As a result, they have little to no tidal volume, meaning that the distance between the ultrasonic sensor and the person’s chest or abdomen will not change as much.

Procedure

infographic

Role of Student vs. Mentor

Mentors provided feedback on prototypes created by the student in this 5-month long research project. The student was responsible for brainstorming ideas, building and testing prototypes, and analyzing data. The mentors provided advice on project direction.

Equipment and Materials

An ultrasonic sensor is a device that sends out a high frequency sound and measures the amount of time it takes for the sound to return. This duration is commonly used to calculate the distance of the ultrasonic sensor from the object in front of it. To develop a prototype, the HC-SR04 ultrasonic sensor was used to detect apneas. Given that a person stays still apart from their breathing, it is expected that when someone inhales, an ultrasonic sensor pointed at their abdomen or chest will show a decrease in distance. Likewise, when that person exhales, it is expected that the distance will increase. This indirect relationship can be used to measure the lung movement displacements. According to Kagawa et al. (2016), lung movement displacement has a linear relationship with tidal volume—the quantity of air that the lungs receive or send with each breath (respiratory cycle). When an obstructive apnea occurs, the patient cannot fully inhale or exhale. As a result, they have little to no tidal volume, meaning that the distance between the ultrasonic sensor and the person’s chest or abdomen will not change as much.

In particular, the HC-SR04 ultrasonic sensor can detect distances between a range of 2 cm and 400 cm with an accuracy of 3 mm (Last Minute Engineers, 2018). According to a study by Reheem et al. (2020), the normal range of chest expansion during respiration depends on age and gender and decreases for older populations. All the mean chest expansion values are greater than 2.5 cm, however, meaning that the ultrasonic sensor should be capable of accurately detecting chest expansion (Reheem et al., 2020).

An Arduino UNO Rev 3 was used to collect and analyze data from the ultrasonic sensor. An Arduino UNO Rev 3 is an inexpensive microcontroller that has 14 digital input and output pins, allowing for a wide variety of sensors and expansions to be connected (Arduino Uno Rev3, n.d.). Its versatility and low price of $27.60 are the primary reasons it was chosen for this project. A limitation of the Arduino is that it only has 32 KB of memory, meaning that the amount of space variables take up must be carefully considered when creating algorithms. To program the Arduino UNO, the Arduino IDE was used.

Other significant materials include a White B20100 Lasko 20’’ Galaxy Box Fan with 3 Speeds, a Land’s End Plush Fleece Bed Blanket Twin Size 90’’ by 95’’ (228.6 cm by 241.3 cm), and a Digital Orbital Shaker MaxQ 2000 Barnstead|Lab-line, which were the primary pieces of equipment used to create models of human respiration. Jumper wires, a breadboard, and LEDs were also important for prototype building. In addition, Google Sheets was used to store data. To analyze data, Google Sheets along with StatKey and StatisticsKingdom were used.

Model 1

Before human testing was approved, multiple models of respiration were created. The first of these models consisted of a box fan and a blanket. The Galaxy box fan represented the force that would expand the lungs, gravity represented the force that would contract the lungs, and the blanket acted as the chest. The Galaxy box fan was placed such that it faced forward and ran parallel to the wall behind it, shown in the methods infographic. These materials were chosen because the inward and outward motion of the blanket caused by the fan can represent the respiratory movements of a human when they are leaning back against a recliner. Limitations of this model include that the movement caused by the fan was around 5 cm on average, which is over the average human chest expansion.

Model 2

The second model of respiration consisted of a Digital Orbital Shaker MaxQ 2000 Barnstead|Lab-line and a pillow. In essence, an ultrasonic sensor was pointed directly towards a pillow attached to a box on top of the orbital shaker. When the shaker was turned on, the box with the pillow moved toward and away from the sensor at a set interval. This orbital shaker, in particular, had an orbit diameter of 1.9 cm, meaning the distance between the sensor and the pillow attached to the shaker would likely vary by around 1.9 cm when the shaker was turned on. This distance variation is preferable to the old model lung mainly because it does not exaggerate chest movements as much and varies less. Since humans tend to breathe between 8 and 15 times per minute, the shaker was set to 15 rpm (MedlinePlus, n.d.).

Data Collection

In both models, data with and without modeled respiration were measured using the ultrasonic sensor Prototype 1 at distances of 80 cm, 120 cm, 160 cm, and 200 cm from the model. Measurements were recorded for 60 seconds for each kind of trial. Averaging algorithms were created to be used with Model 2 after noticing that reflections from the ultrasonic sensor likely caused noisy measurements.

After averaging algorithms were created, human testing was also performed on 1 subject with Prototype 2. The participant was asked to breathe normally in 3 out of 4 samples. In the third sample, the participant held their breath for the first 10 seconds.

For human testing, the data taken from Prototype 2 was placed in a fast Fourier transform (FFT) to calculate breathing rate according to the flow chart. This method was done because it was believed that breathing would occur at even intervals when the subject was breathing naturally.

Human Volunteers

After Prototype 2 was tested, Prototype 3 was improved to use an SD card along with an ultrasonic sensor, Arduino, battery, LEDs, and a buzzer. All of these were attached to a breadboard. Prototype 3 primarily used the mean absolute deviation of points over the prior 50 samples in order to determine whether breathing was detected. To test Prototype 3, data was collected by asking the subject to sit in the chair. The distance from the chair to the sensor was kept constant at 90 cm, but the distance from the subjects’ chests to the sensor varied. As a result, some errors likely occurred.

The sensor was placed at approximately the same height as the center of the back of the chair and pointed approximately at the chair’s back’s center. The experimental setup is shown in the figures below. In addition, subjects were asked to breathe normally for 30 seconds, hold their breath for 10 seconds, and then breathe normally for another 20 seconds in the chair. The researcher told subjects when to start and stop holding their breath. There were 28 subjects total.

Statistical Tests

Multiple people were consulted for which tests to perform on the data (K. Burns, personal communication, February 15, 2023; K. Crowthers, personal communication, February 15, 2023; T. Eswar, personal communication, February 14, 2023; February 15, 2023; A. Shekhar, personal communication, February 14, 2023; J. Shnee, personal communication, February 15, 2023). Since t tests assume a normal distribution in the data, the confidence intervals with t distributions were invalid—the histograms for accuracy, specificity, ect., were skewed and/or not normal. Therefore, instead of a t test, a percentile bootstrap was performed using StatKey (n.d.) with 5,000 resamples since this method does not require a normal distribution (4.4 - Bootstrap Confidence Interval, n.d.; Frost, 2018; Lebedeva, 2020). In essence, bootstrapping works by resampling the given data multiple times. In the percentile bootstrap in this case, the mean was calculated for each of these resamples. After 5,000 runs, the middle 95% of the distribution is taken, the lower and upper bounds generating a 95% confidence interval. Similar to a t test, using a percentile bootstrap will find the bounds when a true mean would be different enough from the samples to suggest significance.

One stipulation of the percentile bootstrap is that the distribution of the sample approximates the distribution of the true population (Frost, 2018; Lebedeva, 2020). It is believed that the data satisfied this condition, given the sample size of 28 and the fact that certain kinds of clothing lead to low sensitivities where there are no positives of any kind. A limitation of this study, however, is that the sampling is not random, which must be kept in mind when viewing the calculated confidence intervals.

In addition, it was suggested to use a Wilcoxon paired signed rank test to determine if there were significant differences between the means of the calculated MADs when someone was breathing and the MADs when the same subject was not breathing (K. Crowthers, personal communication, February 15, 2023). The null hypothesis for a Wilcoxon paired signed rank test is that the median of the differences between the 2 paired samples is 0. The alternative hypothesis is that this difference is not 0. For the purposes of this test, the mean breathing MAD was the average of the MADs from 0 to 30,000 ms and from 40,000 to 60,000 ms because the subject was consistently told to hold their breath from 30,000 to 40,000 ms. For this reason, the mean no breathing MAD was the average of the MADs from 30,000 to 40,000 ms.

The Wilcoxon paired signed rank test has several assumptions. One of which is that the data points within each sample should be independent. It is believed that this assumption is satisfied since the tests between different subjects should not influence one another. Another assumption is that the data is a random sample. Since the data was tested on adult volunteers in Worcester, this fact must be considered when viewing the computed confidence intervals. A third assumption is that the distribution of the paired differences should be symmetric. To satisfy symmetry, a Shapiro-Wilk test was performed using the website software StatisticsKingdom (n.d.). The null hypothesis of a Shapiro-Wilk test is that the data is normally distributed. The alternative hypothesis is that the data is not normally distributed. This test was used because if the data can be assumed to be normal, it can likely be assumed to be symmetrical. A graph of the histogram was also displayed, which seems symmetrical. The samples were independent, and the sample size is 28 subjects, which is less than 50 and greater than 10, so the conditions for a Shapiro-Wilk test are satisfied. A p-value of 0.5694 > 0.05 was obtained, meaning that there was not enough evidence to reject the null hypothesis that the data is normally distributed. As a result, it is assumed to be normally distributed, and it is believed that the conditions for a Wilcoxon paired signed rank test have been satisfied.

Figures

One of my friends with a frog One of my friends with a frog One of my friends with a frog One of my friends with a frog
One of my friends with a frog One of my friends with a frog One of my friends with a frog One of my friends with a frog

Analysis

Some objectives were accomplished for this project. A major criterion for this project was that the device would have an accuracy of at least 90%. The confidence intervals are shown in Table 1, and the accuracy of the ultrasonic sensor is significantly less than 90%. For other criteria mentioned, however, the prototype does weigh less than 15 pounds and can be used when someone is in a chair.

There does seem to be a significant difference between the MAD when someone is breathing and when that same person is not breathing when outliers are removed as shown in Table 2. As a result, this difference may be able to analyzed further to create higher accuracy values. Even when outliers are removed, however, the common use effect size is 74%, implying that the highest accuracy attainable with this metric would be 74% since a difference between MADs only appears in 74% of samples.

One highly relevant failure is the switch from an approach using an FFT to an approach using variation. This change was done since the Arduino has a severely limited memory and could only perform FFTs with sample sizes of 64, meaning that the frequencies attained were difficult to analyze since inputted points needed to be greatly filtered even with windowing. Some data using an FFT and also using variation are shown in Figure 4, Figure 5, and Figure 6.

Other limitations include the effect of the environment on ultrasonic sensor measurements. Even when the same code is used at the same distance from a model, as shown in Figure 9 and Figure 10, measurements can still look substantially different. Figure 1 shows values that jump from 70 cm to 90 cm whereas Figure 2 does not have these extra lines, likely due to the higher height of the sensor in this case or the different material of Model 2.

Ultrasonic sensors also seem to be greatly impacted by material. Figure 5 shows data collected when the same subject is and is not wearing a jacket. When the subject is wearing a jacket, respiratory movements seem to be greatly obscured, causing incorrect determinations about respiration to be made. The realizations about environmental and material limitations made it extremely difficult to create a prototype that could meet the criterion of a 90% accuracy.

Overall, this work differs from studies such as those by Kagawa et al. (2016), Niroshana et al. (2021), and Wu et al. (2021) mainly on the specific goal of having the device work when the subject is in a recliner or chair whereas other studies have been specific to mattresses. The accuracy of this device is significantly better than 50%, implying that it is better than random chance. As a result, a device using an ultrasonic sensor could still be useful for people with OSA; however, the environment, position, and clothing of the client would likely greatly impact the efficacy of this use. This study explores an inexpensive way to alert someone who has accidentally fallen asleep without wearing a CPAP and expands upon the work with doppler radars of Kagawa et al. (2016). An ultrasonic sensor could be potentially used as a secondary sensor. However, an approach using only ultrasonic sensors was not shown to be effective to the desired extent, so different methods should be attempted to create a device that can more effectively improve the lives of people with OSA.

Conclusions

Future studies could include this kind of sensor to monitor patients in hospitals or monitor other kinds of respiratory diseases. The researcher plans to continue their work by using different sensors and algorithms to improve the accuracy of the prototype. The data collected from the 28 subjects will also be further analyzed to investigate the possibility of the ultrasonic sensor as a secondary measure. Other approaches in particular that could be tried include alarms at set times as well as using thermal or infrared cameras and/or pressure pads to detect sleep. These investigations are notable in order to effectively improve the quality of life of people with OSA.

OSA is a prevalent illness that can have substantial impacts if left untreated. As a result, creating a device to improve treatment compliance is salient. The current prototype has some promise since its accuracy level is above 50%. However, the metric used to detect respiration was MAD, and the common language effect size of 74% implies that that could be the maximum accuracy possible, which would not meet the criterion of an accuracy of at least 90%. As a result, alternative approaches or further analysis of the raw distance data should be investigated. Since clothing and environment likely have a large effect on readings from an ultrasonic sensor, adding another sensor to reduce errors could also be future work. Though the device is not perfect, overall, it has some utility when being used as an alert for when someone with OSA accidentally falls asleep on a couch/recliner and experiences an apnea. Not only could a device like this improve quality of life for people with OSA, but, with further improvement, it could also be used for monitoring those with other breathing disorders or potentially infants. Further prototypes will attempt to improve on the aforementioned shortcomings, hopefully creating a device that will help people with OSA.

References

Poster