Machine Learning Algorithms for Posture Identification of Obstructive Sleep Apnea Patients using IoT Solutions

Sleep apnea is a serious sleep disorder in which individuals breathing repeatedly stops and starts. Even after the continuous sleep of 6-8 hours, person feels fatigue and tiredness. This disorder turns even more serious if the person has history of heart problem. The symptoms of sleep apnea are snoring, fatigue, and somnolence, while the main types of sleep apnea are: obstructive sleep apnea, central sleep apnea and complex sleep apnea. Among these obstructive sleep apnea (OSA) is most frequent and can be treated by correct sleeping posture. Research has proved that a change in in-bed posture plays vital role for OSA. In this research we used data of two separate experiments from thirteen healthy subjects in different sleeping postures using two commercially available internet of thing (IoT) based pressure mats. On this data we employed machine learning based supervised learning algorithms for posture identification. This monitoring system may help sleep apnea patients and caregivers to be alerted of improper postures in timely manner and helps in identifying sleeping style of each patient.


I. INTRODUCTION
Sleep has many benefits on human body. It heals it andrecovers energy. It is also considered as a proven diagnosticindicator for diverse medical conditions [1]. Around the globe, over 100 million people suffer from sleep apnea [2]. Ameri-cans are in the thick of a sleep epidemic. In US around 50-70million adults are facing sleep disorder and one of the mostprevalent is OSA. Also 175 million Europeans are affected bythis chronic condition in breathing during sleep. The main af-flict is that 75-80% of cases remained undiagnosed. The reasonbehind unidentification is expenses and practical limitationsof whole night polysomnography (PSG) in sleep labs wherea practitioner works for over night. This sleep apnea turns tobiggest threat for the people who goes through heart problems.Patients sleeping on supine posture can have issues like heartdisease, which may eventually become the reason of death. In [3,4] it has been verified that QT interval variability is intentlyassociated with heart rate (HR) variability. HR variability iseffected by certain mechanisms together with the sympatheticand parasympathetic systems, and a decrease in HR variabilityhas been shown to be correlated with serious cardiac mortalityand sudden death in patients with heart disease as well asto healthy controls. Similarly authors in [5] suggested thatpatients suffering from some respiratory conditions shouldignore supine position. Another research in [6] explained thatthe severity and irregularity of respiratory events in patientswith OSA are elevated in supine posture as compared to lateralrecumbent posture because of the effect of posture on upperairway shape and size.
OSA patients could be divided into positional and nonpositional patients [7]. A positional patients analyse revealsthe fact that most of their breathing irregularity is causedby sleeping in supine position. Sleeping in lateral positionsignificantly reduce the number of hypopaneas and apneas.The main objective of this research is to monitor sleepingpostures of participants using IoT based pressure mats. Theprime goal is to avoid supine sleep positive using objectivemeasurements.

SLEEPINGPOSTURES
With continuous advances in healthcare system and medicaltechnologies there are numerous available posture detection and monitoring systems. The researchers in [8] conducted experiments to prove that changes in sleep posture improve OSA. They used nasal continuous positive airway pressure (nCPAP) mask to measure upper airway closing pressure (UACP) and upper airway opening pressure (UAOP) andimplemented ANOVA (analysis of variance) for statisticalcomparisons. The result shows that in case of severe OSApatients, the lateral positioning improves upper airway stabilityduring sleep. In [9] a system is proposed for analyzing posturesand subjects using pressure sensing mats.
The experiments used deep learning technique for subjectsidentification in three common postures by extracting statis-tical features from pressure distribution. In [10], the authorsintroduced a light and small wireless sleep activity monitoringsystem, the postures and change in posture were detectedusing tri-axis accelerometer. In [11,12] OSA is diagnosedusing electrocardiogram (ECG) signals and the system can beused as a basis for future development of a tool for OSA screening. As previously discussed, the sleeping positionsare used in a number of medical applications, one of thembeing pressure ulcer. In [13] lying postures are classified forpressure ulcer prevention. In [14] a pressure sensitive bedsheetis designed for obstructive sleep posture monitoring with aprecision of 83%. The study from [15] used kurtosis andskewnes estimation, principal component analysis (PCA) andsupport vector machine (SVM) for posture classification withthe help of pressure sensitive mattress in order to also avoidpressure ulcers. As state of art, [16] introduced a supervisedlearning approach on data collected beforehand to build amodel for long tern sleep monitoring application. Hence, thereis a wide range of IoT based monitoring systems available inthe market.
Internet of things (IoT) is a generic term to denote objectsconnected to each other and exchanging information from realworld i.e. medical field. A typical IoT system architecturecan be divided into three tier sub-architectures: the applicationlayer in which the data is processed and the service is givento the main user, the transmission layer for remote communi-cation and the perception layer where acquisition, processingand local communication are proceed through wireless sensornetwork (WSNs). In the context of IoTs, there have beennumerous research studies on sleep apnea analysis with sleeppostures. But most of these systems are generally larger, sophisticated and complex. Most of theses systems require to wear or to attach the system to the human body. Thereis a dare need to concentrate and miniaturize all the sensingand hardware related technologies and a quick system to alertcaregivers about the sleeping posture of patients. Hence themain objective of this research is to introduce an intelligent, small and cost effective IoT based system for monitoring sleepactivity of sleep apnea patients.
Our study is divided into three sections. Section III addresses the data setup and collection from participants, section IV illustrates the basic methodology we adapted and sections V and VI show the main results and future work.

A. Data Collection Details
The data we used for sleep posture monitoring is availableon the Physionet website [17]. Physionet is famous for alarger collection of biomedical signals from patients and healthy subjects. As far from our research, PmatData is the first publicly-available dataset of pressure sensor data whichincludes various sleeping postures. The data was collectedunder IRB approval at the University of Texas at Dallas [18] from thirteen participants in different postures. Informedconsents were signed by all individuals before data collectionand all agreed on anonymous publication of their data for future research.

B. Participants
A diverse number of participants has been chosen as controlsubjects to make the dataset useful for other researchers. All the 13 participants in study were healthy with no history ofsleeping problems. The details of all participants are given in Table I. The subjects participated in two types of experiments.

C. Materials and Experiments
Numerous types of pressure mattresses and bedsheets areavailable in the market with thousands of force and pressure sensors. The data we used in our study was collected using Vista Medical FSA SoftFlex 2048 and Vista Medical BodiTrakBT3510 which are Force Sensitive Application (FSA) pressure mapping mattresses. In experiment 1, the data is collected from 13 participants using Vista Medical FSA SoftFlex 2048.The size of mattress is 32ƍƍ×64ƍƍ with each sensor is 1 inch apart. The data is collected at sampling rate of 1 Hz. While inexperiment 2 data is collected using Vista Medical BodiTrakBT3510. The size of pressure mat used is of 27ƍƍ×64ƍƍ. Thedata was collected at sampling rate of 1 Hz.

IV. METHODOLOGY
In this study, we focused on in-bed posture detection forsleep apnea patients using pressure sensors data signals. The block diagram of the overall methodology implemented in this research study is shown in Figure 1. Initially the data collected from pressure mats is pre-processed and filtrationis performed to only keep the data which is relevant foranalysis. We removed unnecessary data such as the zero-values. Later we performed correlation between the sensorsdata (variables in table) to see the relationship between thesamples we collected. After this we labelled our data in formof classes and performed classification using machine learningalgorithms. The final detection and monitoring results can bedirectly exported to provide an alert.

A. Experiment I
In experiment I, the pressure mat is designed of total 2048sensor points with a scan rate of 3072 sensors/second. Thesesensors are equally distributed across32ƍƍ×64ƍƍmat with eachsensor being almost 1 inch apart. The sampling frequency is1 Hz and counts the pressure between 0 to 100 mmHg as in [19]. In experiment I, five standard postures as in [20] werecollected for all 13 individuals as shown in Figure 2. In [14] study the most common postures of 1000 participants wererecognized. According to their results, the right and left fetussleeping position are the most common at around 41%. Theother side lying posture or yearner position i.e. with straightlegs in left or right side accounts for 28% and finally thesupine posture about 8%. Therefore we labeled the collecteddata into five standard and common postures. First of all, weprepared the dataset for the first experiment in which we madea single file for each posture of all 13 participants and thenmerged them into one file for further posture detection andclassification, results of which are shown in Table II. For classifying the standard posture from the labeled data,we used classification learner app of MATLAB [21]. We used multiple machine learning algorithms for detection andmost of them performed very well. The weighted KNN andthe linear classifier gave promising results with accuracy of 98.7%. The results of classified model is illustrated in the form of confusion matrix, receiver operating characteristics (ROC) curves and parallel coordinates plots. The confusion matrixin Figure 3 shows how currently the selected KNN classifierhas performed. It determines where the model has predicted poorly. If we look on the plot (a), the rows show the true classand the columns show the predicted class. We have used 5 fold cross validation. The diagonals emphasize where the true classand the predicted class match. The blue boxes in diagonalsdepict that the classifier has made the classification and theobservations of this true class are classified correctly. Plot   [20] In the second part of the experiment I, we detected thepostures of each single participant and the classifier showedpromising result as it can be seen in table III. This proves thatwe can also identify each type of postures of each individual.

B. Experiment II
In experiment II, 8 participants have been involved. Thistime, the data was collected from air mattress and different postures with different roll-angles were counted to see the difference in classification models, testing also if the type of mattresses makes any difference in accuracy of detection or not. The results from table IV show that the accuracy is decreased, this meaning that air mattress cannot provide accurate results for detection of postures. The highest accuracy achieved is 71.1% using fine KNN algorithm.

V. CONCLUSION
In conclusion, tracking in-bed postures can be a healthyexercise to avoid certain kind of illnesses, especially in case of sleep apnea patients. This research dealt with different posturesand highlighted the most common posture associated withmultiple health issues i.e. sleeping on a supine position. This proves that with slight improvisation in sleeping patterns, onecan avoid several health risks. In this research, the availabledata have been labeled and after pre-processing, we ran itthrough multiple algorithms with the help of classificationlearner app in MATLAB in order to monitor sleep posturessuccessfully with high accuracy rates. Based on the designed classifiers, we could differentiate IoT based pressure sensor mattresses and found that monitoring of sleeping posturesusing air mattresses may not provide promising results. Hencethe type of mattress does matter in detecting postures.

VI. FUTURE WORK
In future, we intend to work on algorithms based on unsupervised learning with the help of other platforms like Python. We also aim to build a system which not only can monitor the sleeping postures but also is capable of tracking records of heart rates to avoid the risk of heart failures while sleeping. Furthermore, we are much interested to base our whole system on IoT to obtain the best results remotely.   Subject S1 S2 S3 S4 S5 S6 S7 S8 S9 S10 S11 S12 S13