Fog Computing for Personal Health: Case Study for Sleep Apnea Detection Ace Dimitrievski1, Snezana Savoska2 and Vladimir Trajkovik3 1, 3 Faculty of Computer Science and Engineering Ss. Cyril and Methodius University, Skopje, Republic of N. Macedonia 2 Faculty of Information and Communication Technologies, St. Kliment Ohridski University, Bitola, Republic of N. Macedonia 1ace.dimitrievski@gmail.com,2snezana.savoska@uklo.edu.mk, 3vladimir.trajkovikg@finki.ukim. mk Abstract. The recent trends in healthcare as e-health and electronic hospital health services pushed healthcare systems to a patient-centric concept, collecting a large amount of data in Electronic or Personal Health Records, providing evidence- based medicine and data analysis. This concept, together with the pervasive health care environments, can generate recommendations and suggestions for preventive intervention, depending on some measured parameters of the patient at home. This can improve the healthcare service from home, based on the health conditions, disease history, and data gained from vital sign sensors according to the Internet of Things Smart living concept. From the technical point of view, a remote monitoring system can provide remote consultation as a part of Assistive technology trends. We used cloud and fog computing for experiment with noninvasive sensors that can follow humans’ sleeping activities towards detecting sleep apnea, to demonstrate the fog-based data processing. With this case study, we have shown the applicability of fog computing and ability trough preprocessing to accomplish computational and bandwidth savings, protecting sensitive data privacy. Keywords: ambient assisted leaving, fog computing, noninvasive sensors, sleep apnea, pervasive computing. 1. Introduction The precision medicine, creating digital records for the patient as Electronic health records (EHR) or Personal Health Records (PHR), changed everyday life, pushing healthcare organizations to adopt computer science and information systems as tools to collect and analyze healthcare data according to evidence- based medicine [1]. Patients change their need for healthcare services toward e-health, providing a medical care from everywhere. Data connected with Copyright © 2020 for this paper by 51 its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0). patients’ diagnoses, treatments, and patient care are more valuable as the concept of evidence-based medicine is widely used. The second emerging technology taken into consideration is Ambient Assisted living, connected with implementation of Internet of Things Smart leaving and enabled by wearable sensors and other IoT technologies that measure vital sign of living and health-connected parameters [2]. The third part of the story is the emerging trend of cross-connected healthcare data that tackle the influence of environmental factors as exposome [3], enabling health risk assessment for each person taking into consideration the genotype, phenotype, diseases and environmental exposure [4]. All these facts pointed out that these large data amount produced in short time can burdening data traffic and sometime producing bottlenecks in the operation of such systems. We pointed out the recent trends in healthcare supporting systems of development of patient-centric pervasive environments in addition to the hospital-centric one [5]. Pervasive health care takes steps to design, develop, and evaluate computer technologies that help citizens participate more closely in their healthcare [6]. A typical example is an algorithm that generates recommendations and suggestions for preventive intervention instead of emergency care and hospital admissions [7]. The algorithm can recommend performing a specific activity that will improve the user’s health, based on his health condition and set of knowledge derived from the history of the user and users with similar attitudes to him/her [4]. Pervasive healthcare focuses explicitly on the use of pervasive computing technology for developing tools and procedures that put the patient at the center of the health care process. From a technological standpoint, it includes remote monitoring, remote consultation, and assistive technologies [9]. The rapid progress of mobile technologies, sensors, Internet of Things, cloud and fog computing, provides the necessary infrastructure for such systems to be developed [2][12]. This paper describes a case study that demonstrates fog-based data processing within an ambient assisted living system. The data processing deals with data from noninvasive sensors capable of following of sleeping activities of humans in order to detect sleep apnea. An apnea event is described as a reduction in the magnitude of respiration movement to less than 5% of the normal value for a certain amount of time during breathing. This makes it suitable for different types of sensor-based detections. The next section of the paper describes the settings of our case study. Sections 3 presents the obtained results. Section 4 elaborates findings, while section 5 concludes the paper and describes future work. 52 2. Case Study In this case study, we will gather real-life sensor data and infer the applicability of fog computing data preprocessing in order to accomplish computational and bandwidth savings, together with the benefits of local or edge processing. This case study covers the data gathering and edge-computing layers of the architectural model present in [10]. We will consider a data flow model that is generated to detect sleep apnea using noninvasive sensors, which is illustrated in Fig. 1. The first phase is to preprocess the data by identifying body movements. As described in [11], sleep apnea is accompanied by body or leg movement, which can be detected by noninvasive sensors. To detect movement in bed, we have used multiple PIR sensors and piezoelectric based sensors placed under the mattress, as shown in Fig. 2. We have used commercial products intended for use in baby cribs and have determined that it is suitable for use by adults. This sensor generates an electrical charge that is then transferred to the control panel using 3:5mm jack. More details on the sensor deployment can be found in [12]. Fig. 1. Data Flow use case. 53 Fig. 2. Placement of PIR sensors and piezoelectric based sensors placed under the mattress. The PIR sensors are positioned using a sensor case, which we 3D print, in order to provide repeatability of the experiment as the position is fixed and set at a predetermined angle [13]. The sensor module is then positioned above the bed and connected via power and signal outlets to the control panel of the lab. An electronic circuit amplifies the electrical charge generated by this sensor, and the output is relayed to the microcontroller that samples the data on every 30 milliseconds time interval. The maximum voltage level does not have any useful information, and it depends on the characteristics of the amplifier. As we are only interested in the distribution, we normalize the data in the interval from value 0 to value 1. 3. Data analyzes Upon analyzing the data, we found that 99% of the samples have a value close to zero (see Table 1). This is due to the fact of low instances of extensive movement during the sleep. The reason that most of the positive samples have value > 0.97 is that the amplifier quickly goes to saturation. The values between 0.03 and 0.97 are mostly data sampled before and after the voltage from the amplifier goes to saturation. Fig. 3 shows the histogram for the charge levels with a resolution of 100. 54 Fig. 3. Piezoelectric sensor charge level histogram 0.03 ¡ x ¡ 0.97. Similar to the data from the piezoelectric sensor for movement in the bed, 96.24% of the time, all five sensors were at state 0. If we look at the sensor data individually, as presented in Table II, the sensor facing away from the sleeping person (PIR1) was instead different then 0, only 0.98 % of the time (see Table 2). From the data shown above, we can calculate the transmission data size, without the overhead. If we encode the piezoelectric sensor with a resolution of one byte, the total size would be 913kB. However, since we do not need the values less than 0.03, as they indicate no charge generated due to body movement, we do not need to transmit them. As this data represents time series, we would need to encode the address using four bytes and the value using one byte. For the values greater than 0.03, this would require 46kB (data saving of 95%). As this is low data rate in situations where the experiment is done in a lab with a fast Internet connection. There is no benefit of introducing the fog network just to save bandwidth, but in the realistic scenario where the data would be transferred with mobile data, possibly via smart-phone, or via metropolitan IoT network such as LoRAWAN the addition of edge node closer to the patient is needed. If we plot the activation of the PIR sensors, we see a graph, as shown in Fig. 4. On the X-axis is the time series index and Y-axis represents the number of PIR sensors that are active or sum of the values of the PIR sensors. We can 55 see that as the sensor was positioned directly over the bed most of the time; all sensors were active when the sleeping person moved in bed. The data collection starts when the person went to bed and ended when the person woke up. From the intensity of the movement, we notice that it took 25 minutes for the person to fall asleep. When we plot the data from the piezoelectric sensor, shown in Fig. 4b, on top of which we overlay the graph of PIR sensors with at least one active sensor, the correlation between them is evident. In order to investigate further, we zoom on one hour during sleep time, in our case, 04:35, from the start of the data recording. In Figure 5a, we show the plot of the count of active PIR sensors. In Figure 5b, we show the plot of the electrical charge of the piezoelectric sensor. Here we notice an excellent correlation in six events. However, two instances only appear at around 04:48:30 and 05:01:30; they are shown by the thinnest lines and are shortest. We assume it might be a leg movement under the blanket and therefore it is not registered on the PIR sensors. Fig. 4. a) PIR sensor activation (over 8-hour sleep). 56 Fig. 4. b) PIR and Piezo sensor activation (over 8-hour sleep). Fig. 5. a) Active PIR sensors from 04:35 to 05:35. 57 Fig. 5. b) Piezoelectric sensor charge (normalized) from 04:35 to 05:35. Next, we isolate and zoom on the event between those two lines at 04:58. We select the 30-second range from 04:58:30 to 04:59:00. Figure 6a shows the count of the active PIR sensors for that period. Fig. 6b shows the detected electrical charge from the piezoelectric sensor in the same period. Aside from the established correlation, we notice that PIR sensors are activated one after another. For the fourth sensor to activate, it takes a longer time. The other sensors activate faster and deactivate more slowly. We can see that some PIR sensors remain active after the piezoelectric sensor no longer detects movement. This is a property of the PIR sensor; they have a potentiometer that sets the signal delay, which keeps the sensor at a positive state for a short period after the motion is no longer detected. This feature enables detection when the sampling rate is lower. Fig. 6. a) Active PIR sensors from 04:58:30 to 04:59:00. 58 Fig. 6. b) Piezoelectric sensor charge (normalized) from 04:58:30 to 04:59:00. When motion is detected, the sensor data from multiple noninvasive sensors is processed on the edge node. The local machine-learning model is run, and the possible occurrence of sleep apnea is diagnosed. To label the data set, periodical sessions can be conducted that will include more invasive sensors to detect sleep apnea using well established medical diagnostic tools [14], including observations by medical professionals. After anonymization of the data, it is packaged and sent to the cloud for additional processing. The data model on the cloud side is run to verify the outcome for the received data. If the model present in the cloud makes positive detection for the received data and if the data was previously labeled with the negative result by the edge node, then the updated model is sent back to the edge node, which in turn processes the data against the updated model. Sensor data that does not suggest reliable negative results are marked for further labeling if additional data such as monitoring from medical equipment or video, that can be analyzed by trained professional, if available. Such feedback is periodically included in building the cloud model continuously. 4. Discussion As we have seen from the results of the experiment, sensor-generated data requires preprocessing. We have shown that even without compression, we can save 95% of the data payload. We can use a sum of the PIR sensors states instead of individual states to show a specific movement. In addition, we have seen that piezoelectric sensor data does not require full information. From this, we can infer that even if we use lossy compression, we can still detect the events. The sensor data does not carry personally identifiable information. However, in the situation where data is directly uploaded to the cloud care receivers might be identified by the origin, like their source IP address [15]. Edge nodes with sufficient storage 59 capacity might keep the data and periodically send in chunks to the cloud. New ML models can be run against old data, and if the fitting of data has a significant offset from previous runs, the e-health gateway will upload previously kept data to the cloud. Nevertheless, if no such benefit were detected, the data would not be sent, therefore protecting user privacy when no more significant benefit is estimated. As some lower-powered microcontrollers do not possess processing power to use encryption protocols such as TLS, this would be offloaded to the e-health gateway. In our experiments, the sensors were connected to Arduino boards that are not capable of TLS even with the network shield. Since the edge nodes will have a copy of the latest obtained ML models, they will be able to evaluate and react even in the absence of cloud connectivity. 5. Conclusion and Future Work As personal health become a more pervasive part of daily life, and as the data generated by it increases in volume, Fog computing offers a solution for many critical issues. In this paper, we have shown the applicability of fog computing and its ability trough preprocessing to accomplish computational and bandwidth savings, and to protect care receivers’ privacy. The added flexibility of the fog architecture enables better placement of computing and network resources. Smarter data flow could protect personal data; bandwidth cost could be reduced, and the whole system can be more scalable, and secure. In the future, we will add additional noninvasive sensors and body sensors such as pulse oximeter and/or ECG for reference and machine learning model training. We will also conduct experiments in parallel with multiple individuals and analyze the privacy implications when data is anonymized to investigate the possibility of identifying the patient from medical data. This extraction of data according to healthcare established standards is important and have to be taken into consideration [16]. Acknowledgement This work is partially financed by the Faculty of Computer Science and Engineering at the Ss. Cyril and Methodius University, Skopje, North Macedonia 60 References [1] Roehrs A. and all, Personal Health Records: A Systematic Literature Review, Journal of Medical Internet Research, 2017; 19(1):e13, doi:10.2196/jmir.5876 [2] Dimitrievski A. et al., “Data Processing within Ambient Assisted Living System” In International conference on Applied Internet and Information Technologies (AIIT), Zrenjanin, Serbia, October 3-4, 2019. [3] Savoska S. et al., “Towards Integration Exposome Data and Personal Health Records in the Age of IoT”, In the 11th ICT Innovations Conference 2019 Web Proceedings, EMBNet Workshop, Ohrid, Republic of North Macedonia, October 2019, pp. 237-246, ISSN 1857-7288. [4] Lopez-Campos G. and all, Biomedical Informatics and the Digital Component of the Exposeome, MEDINFO 2017, doi: 10.3233/978-1-61499-830-3-496 [5] Mountford N., et al., “Connected Health in Europe: Where are we today?”. University College Dublin. 2016. [6] Koceska N. et al., “A telemedicine robot system for assisted and independent living’, Sensors, 19(4), p.834, 2019. [7] Kulev I. et al., “Development of a novel recommendation algorithm for collaborative health: Care system model”, Computer Science and Information Systems, 10(3), pp.1455-1471, 2013. [8] Vlahu-Gjorgievska E. et al., “Connected-health algorithm: development and evaluation. Journal of medical systems”, 40(4), p.109, 2016. [9] Aleksov V., Savoska S., Trajkovik V., “Applications of pervasive computing and mobile services in health care”, In Information Systems and Grid Technologies (ISGT) Conference, Sofia, Bulgaria, November 16-17, 2018. [10] Goleva R., et al, “AAL and ELE Platform Architecture” in Ambient Assisted Living and Enhanced Living Environments: Principles, Technologies and Control, Elsevier, 2016. [11] Somers V.K. et al., “Sympathetic neural mechanisms in obstructive sleep apnea.” Journal of Clinical Investigation, vol. 96, no. 4, p. 1897, 1995. [12] Dimitrievski A., et al., “Addressing Privacy and Security in Connected Health with Fog Computing”, In Proceedings of the 5th EAI International Conference on Smart Objects and Technologies for Social Good, pp. 255-260, September 2019. [13] Dimitrievski A. et al., “Towards application of noninvasive environmental sensors for risks and activity detection,” in Intelligent Computer Communication and Processing (ICCP), 2016 IEEE 12th International Conference on. IEEE, pp. 27–33, 2016. [14] V’azquez J.C. et al., “Automated analysis of digital oximetry in the diagnosis of obstructive sleep apnea,” Thorax, vol. 55, no. 4, pp. 302–307, 2000. [15] Zhou B., Pei J., and Luk W., “A brief survey on anonymization techniques for privacy preserving publishing of social network data,” ACM Sigkdd Explorations Newsletter, vol. 10, no. 2, pp. 12–22, 2008. [16] Kaloyanova K., Krastev E., Mitreva E., Extracting Data from General Practitioners’ XML Reports in Bulgarian Healthcare to Comply with ISO/EN 13606. BCI’19: Proceedings of the 9th Balkan Conference on Informatics, September 2019, Article No.: 3, Pages 1–5, https://doi. org/10.1145/3351556.3351578 61