Integrating Mobile Devices and Wearable Technology for Optimal Sleep Conditions

: As medical technology continues to evolve, the importance of real-time feedback from physiological signals is increasingly being recognized. The advent of the Internet of Things (IoT) has facilitated seamless connectivity between sensors and virtual networks, enabling the integration of thoughtful medical care with real-time feedback capabilities. This project uses cloud storage technology and cloud software algorithms to enable data sharing and real-time feedback. Its main focus is to provide a system for real-time feedback on physiological signals and sleep quality analysis. The sys-tem uses smart wristbands and smart mobile devices to collect, transmit, and analyze physiological data. During sleep, users wear these devices, which capture and analyze their physiological data. The analyzed data are then stored in a cloud-based database. The research involves studying sleep quality and determining optimal sleep quality parameters based on the data stored in the cloud database. These parameters are designed to improve sleep quality. They are then transmitted to a mobile sleep aid device to control light conditions. The sleep aid software used in previous generations of mobile devices is the basis for expanding the integration of the sleep detection system. By combining the software of a mobile device platform with that of a smart wearable device, data can be obtained to monitor the wearer’s movements, such as turning over and heartbeat. The monitoring aspect includes tracking the turning time, distance, and speed, while the heartbeat monitoring includes detecting changes in heart rate, frequency, and interval using photoplethysmography (PPG) and smart wearable devices. Subsequently, artiﬁcial intelligence methods are employed to conduct statistical analysis and categorize the gathered extensive dataset. The system reads the data and provides the user with assessments and suggestions to improve sleep quality and overall sleep condition.


Introduction
Sleep has always been an essential part of human life.Everyone needs sleep, whether a head of state, scientist, politician, doctor, office worker, or anyone else.Sleep deprivation not only affects reaction speed, emotional control, memory, vitality, and physiological lesions [1][2][3][4], but also has a significant impact on the occurrence of traffic accidents and crew deployment [5][6][7].In 2018, a study by David Hillman et al. indicated that inadequate sleep can also lead to additional workplace accidents, increasing the cost of medical care, accident investigations, and lawsuits to over USD 2.48 billion [8].
The quality of sleep is intricately intertwined with the standard of sleep, and the characterization of sleep quality [9] can be delineated by four specific criteria: (1) achieving sleep within 30 min of lying down; (2) experiencing ≤ 1 episode of waking up in the middle of the night, defined as waking up for over 5 min; (3) returning to sleep within 20 min after waking up in the middle of the night; and (4) achieving a sleep efficiency of ≥85%, which denotes the percentage of sleep time divided by the time spent lying in bed.In recent years, research on sleep quality has encompassed several focal points, including stress [10,11], physical activity [12,13], noise [14,15], and light [16][17][18].Light, known to positively impact humans, significantly influences the functioning of cells within the human body.In 2002, American scientists discovered a distinct type of light-sensitive cell [19] termed "intrinsic photosensitive retinal ganglion cells" (IPRGC).Unlike the traditional cone and rod cells responsible for light perception, IPRGC employs melanopsin to sense external light stimuli.The interaction between IPRGC cells and external light governs various physiological adaptations and responses, including melatonin secretion, circadian rhythm phase shifts, and sleep duration adjustments [20,21].Furthermore, IPRGC shares commonalities with cone and rod cells while exerting distinct effects across different wavelengths.IPRGC exhibits heightened sensitivity to short-wavelength blue light, yielding a pronounced physiological response in the human body following exposure [22].Extensive research indicates that exposure to short-wavelength blue light disrupts the physiological secretion of melatonin and cortisol, leading to significant issues such as sleep disorders [23][24][25].
Sleep has become an essential factor in the development of civilization.Studies show that excessive exposure to blue light inhibits melatonin secretion and impairs sleep, while adequate exposure can promote good sleep.In scientific research, some people believe that it is best to sleep in a completely dark environment [26][27][28][29][30][31], but studies on sleeping in bright environments have indicated that different light environments have different effects on sleep.For example, the research results of scientists such as Kozaki in 2005 showed that sleep in an environment with an illumination of 10 lx and a color temperature of 3000 K lasts longer than sleep in an environment with an illumination of 10 lx and a color temperature of 6700 K [32].In 2013, the results of researchers such as CgellappaSL also showed that the use of 3000 K and 6500 K lamps with color temperature and illumination of 40 lx two hours before bedtime causes melatonin to be inhibited, while alertness, happiness, and comfort are increased.In addition, the period of rapid eye movement and N1 are reduced [22].In 2017, Smolders' research results also revealed that people with sleep deprivation showed effects after being irradiated with 6000 K and 500 lx light in both subjective and objective tests [33].According to the latest article published by scientist Yingjian Lu in 2020, light and sound are combined into one product, and brain waves are detected via the ARM module and Wi-Fi module to determine sleep quality.Light and sound are appropriately used to support sleep, a method which has been recognized by users and professional doctors in research and has a specific effect [34].
Sleep health monitoring has been achieved by upgrading hardware equipment and continuously updating physiological information analysis methods.Daily sleep information and physiological data can be stored with simple hardware equipment, and the stored sleep information and physiological data are then sent to medical centers via the Internet.By analyzing the sleep data, more accurate results can be obtained, and appropriate feedback and suggestions for medical care can be given to users.Thus, the way in which they come to know their physical conditions has changed greatly.In the past, assessing sleep quality required orchestrating a hospital admission, where polysomnography (PSG) equipment needed to be affixed, followed by completing and monitoring subjective questionnaires.PSG equipment entailed the intricate connection of multiple cables to capture the subject's physiological metrics, encompassing brain waves, electrocardiogram readings, electromyography signals, eye movements, respiration patterns, etc.This comprehensive data set was subsequently juxtaposed with the subjective questionnaire responses to glean insights into the subjects' sleep patterns and behaviors.However, contemporary advancements have introduced diverse analytical approaches to enhance the arsenal of evaluation techniques.In addition to subjective questionnaires, smart wear devices are used to monitor physiological data using small devices such as watches and headphones, which reduces the inconvenience of wearing PSG cables, and similar results can be obtained.In 2015, Jensen, H.I., and other researchers studied the sleep quality of shift workers using dynamic lighting.Using an ActiGraph sleep wristband, sleep latency, wake times, and overall sleep efficiency were assessed with the help of a sleep diary and saliva samples.Even without PSG equipment, the results showed no significant correlation between melatonin and sleep efficiency, but in the subjective test evaluation, workers in the dynamic control light environment felt better than those in the typical light environment [16].In 2017, Saad, W.H., along with fellow researchers, delved into the impact of the environment on sleep quality.They employed a multifaceted approach encompassing environmental measurements, video recordings, and the utilization of wristbands to capture variables such as physical activity, body temperature, and heart rate.The study's findings unveiled a significant correlation, demonstrating that lower body temperature and a decreased heart rate indicated improved sleep quality in settings characterized by darkness and cooler temperatures [35].Due to devices such as smart wearable devices and environmental sensors [36][37][38][39], assessment methods other than PSG that need to be connected to a large number of biological signal measurement devices have been provided, which can help users to improve their sleep quality more quickly by obtaining the results of sleep condition analysis through simple wearable devices without having to go to the hospital to be examined for a long time, which increases the medical burden.
As per the 2019 research report by Zhu, Jianxiong, et al., wearable devices are being highlighted not only for their significance in the medical field, but also for their role in enhancing the immersion of AR, VR, and various forms of human-machine interaction [40].Surveys conducted by IDC and the report titled "DIGITAL 2020: Global Digital Overview" have unveiled compelling insights into mobile phone and internet user data.Notably, the statistics indicated a remarkable surge in wearable device shipments, from 178 million units in 2018 to an impressive 336.5 million in 2019.This staggering growth rate stands at an impressive 89% [41].Furthermore, a survey of global internet usage in 2020 indicated a 7% growth in user count, rising from 4.22 billion to 4.54 billion, with an average internet usage time of 6 h and 43 min per individual [42].
The insights derived from IDC market research and the DIGITAL 2020 survey allow us to grasp the inseparable relationship between modern individuals and smart mobile devices.This underscores the escalating importance and indispensability of smart mobile devices as they continue to evolve.

Cloud System
A cloud system is a system service that integrates software and hardware and provides users with various services with different requirements via the Internet.Through system models created by developers, users can use any devices and cloud system services in other places.Currently, three leading operators offer cloud system services: Google Cloud Platform, Amazon Web Services, and Microsoft Windows Azure.The architecture of cloud service systems can be divided into three types, namely, infrastructure services, software services, and platform services.Infrastructure as a Service (IaaS) provides online hardware equipment for business rental, such as CPU, GPU, and temporary backup of files.Software as a Service (SaaS) refers to the creation of enterprise software packages by developers and the provision of user services through leasing.Users can use the applications or web browsing services by paying for subscriptions or time of use, such as renting audio and video streaming services and purchasing single-album audio media.Platform as a Service (PaaS) provides a network software service platform for software vendors and provides basic APIs for enterprise users to design, develop, and test information systems online.

Sleep State Analysis Algorithm
Sleep can be categorized into two main phases: rapid eye movement (REM) and non-rapid eye movement (NREM) [43].Typically, a nocturnal sleep cycle encompasses 4 to 5 distinct stages, beginning with the wakeful state and progressing through the rapid eye movement phase, followed by the non-rapid eye movement phase.Subsequently, the cycle reenters the rapid eye movement stage, transitioning into the unconscious phase before once again entering the non-rapid eye movement phase.This cyclical pattern eventually culminates in returning to the wakeful state.The non-rapid eye movement period can be further partitioned into four stages: N1, characterized by shallow sleep; N2, representing deep sleep; and N3 and N4, signifying extended periods of deep slumber [44,45].An 8 h nightly sleep usually includes 4-5 sleep cycles, a sleep cycle generally lasts 90 to 120 min [45], and a good sleep cycle usually occupies 15-20% of the total sleep during deep sleep.During deep sleep, the body is completely relaxed and rested and the brain begins to reorganize its memory, incorporating pre-sleep information into deep memory and other important tasks.Figure 1 shows a typical diagram of the nocturnal sleep cycle [46].distinct stages, beginning with the wakeful state and progressing through the rapid eye movement phase, followed by the non-rapid eye movement phase.Subsequently, the cycle reenters the rapid eye movement stage, transitioning into the unconscious phase before once again entering the non-rapid eye movement phase.This cyclical pattern eventually culminates in returning to the wakeful state.The non-rapid eye movement period can be further partitioned into four stages: N1, characterized by shallow sleep; N2, representing deep sleep; and N3 and N4, signifying extended periods of deep slumber [44,45].An 8 h nightly sleep usually includes 4-5 sleep cycles, a sleep cycle generally lasts 90 to 120 min [45], and a good sleep cycle usually occupies 15-20% of the total sleep during deep sleep.During deep sleep, the body is completely relaxed and rested and the brain begins to reorganize its memory, incorporating pre-sleep information into deep memory and other important tasks.Figure 1 shows a typical diagram of the nocturnal sleep cycle [46].Distinguishing various sleep states relies on EMG analysis during REM and non-REM (NREM) sleep, as well as the collection of other physiological signals such as brainwaves, heart rate fluctuations, and the frequency and intensity of body movements.Physiological data are collected through brainwave analysis to differentiate between sleep states and assess sleep quality.Conductive adhesive electrodes are placed externally on the cerebral cortex, allowing for the recording and analysis of the user's brainwave energy distribution before, during, and after sleep using a physiological signal device.This analysis facilitates the evaluation of sleep state and quality.Electrocardiogram (ECG) measurements capture heart potential signals, enabling the recording and quantitative analysis of physiological parameters such as heartbeat intensity and frequency.This data acquisition provides insight into the subject's relaxed and excited sleep states.
The categorization of sleep stages is rooted in brainwave analysis, which involves examining the transformation of potential brain energy from time to frequency through Fourier transform.When transitioning from wakefulness to sleep, changes in brainwave frequencies occur.During the awake state, alpha (8-13 Hz) and beta (13-30 Hz) brainwaves are more active.The rapid eye movement (REM) phase exhibits significant lowfrequency brainwave signals (2-7 Hz) and heightened EMG activity.In non-REM (NREM) sleep, deep sleep phases (N3 and N4) are characterized by the presence of delta (0.5-4 Hz) and theta (4-7 Hz) waves, which constitute a substantial portion of the overall energy distribution.Notably, deep sleep stage N4 is dominated by delta waves [47].
Analyzing heartbeats during sleep involves the recording of each heartbeat cycle using physiological signal devices.These cycles begin with the electrical impulse of the sinoatrial node, leading to atrial and ventricular contractions.Electrocardiogram (ECG) results are subjected to three methods of analysis: time, frequency, and nonlinearity.Time domain analysis includes metrics such as the mean, standard deviation, and percentiles of the R-wave interval (refer to Figure 2).Frequency domain analysis involves Fourier or Analyzing heartbeats during sleep involves the recording of each heartbeat cycle using physiological signal devices.These cycles begin with the electrical impulse of the sinoatrial node, leading to atrial and ventricular contractions.Electrocardiogram (ECG) results are subjected to three methods of analysis: time, frequency, and nonlinearity.Time domain analysis includes metrics such as the mean, standard deviation, and percentiles of the R-wave interval (refer to Figure 2).Frequency domain analysis involves Fourier or wavelet transform to distinguish energy distribution between sympathetic and parasympathetic nervous activities at both low (0.04-0.15 Hz) and high (0.15-0.4 Hz) frequencies.The nonlinear analysis encompasses graphical and parameter-based methods, with graphical analysis presenting ECG scatter plots that reveal trends in heart rate variability (HRV) [48].
wavelet transform to distinguish energy distribution between sympathetic and parasympathetic nervous activities at both low (0.04-0.15 Hz) and high (0.15-0.4 Hz) frequencies.The nonlinear analysis encompasses graphical and parameter-based methods, with graphical analysis presenting ECG scatter plots that reveal trends in heart rate variability (HRV) [48].

Data Analysis
The algorithm model of data analysis consists of designing the sleep stages in a stepwise manner based on the data results of human brain waves, heartbeat, and turnover measured in the previous step.The collected brainwave activity information is filtered, segmented, and tagged, and the active high-frequency response and gentle low-frequency brainwave activity are quantitatively distinguished to determine the user's actual sleep cycle.Combined with the data results regarding turnover and heartbeat, the sleep stage is divided into three phases: awake, REM, and not REM.The model analyzes each phase of sleep.To confirm the sleep stage by spectral analysis and marking brainwave signals, turnover information is added; the turnover time and intensity recorded by the accelerometer of the Apple Watch are analyzed; and the sleep stages with different power and turnover times are marked.As an illustration, REM sleep typically involves rapid eye movements and muscle paralysis, resulting in a heightened frequency of body movements and position changes.Conversely, during the transition to deep sleep stages within NREM sleep, the frequency of these movements diminishes, reflecting reduced turnover activity.In heartbeat analysis, the frequency and timing characteristics of heart rate variability are extracted by frequency spectral analysis and other processing, then matched with brain wave results to build a sleep stage model.For example, during REM sleep, the Beta and Alpha brain waves are more active, and the analysis results of heart rate variability are also excitatory, while during NREM sleep, the analysis results are relaxed.When the cloud sleep stage analysis algorithm model is updated, the sleep data are uploaded to the system by the user, the sleep stages are analyzed, and the analysis results are sent back to the user.

Brain Wave Analysis
Within the realm of frequency domain analysis, the initial time series data are transformed into the frequency domain by utilizing fast Fourier transform (FFT).This transformation enables the examination of the power spectral density (PSD).FFT enhances the computational efficiency of discrete Fourier transform calculations, expediting the overall

Data Analysis
The algorithm model of data analysis consists of designing the sleep stages in a stepwise manner based on the data results of human brain waves, heartbeat, and turnover measured in the previous step.The collected brainwave activity information is filtered, segmented, and tagged, and the active high-frequency response and gentle low-frequency brainwave activity are quantitatively distinguished to determine the user's actual sleep cycle.Combined with the data results regarding turnover and heartbeat, the sleep stage is divided into three phases: awake, REM, and not REM.The model analyzes each phase of sleep.To confirm the sleep stage by spectral analysis and marking brainwave signals, turnover information is added; the turnover time and intensity recorded by the accelerometer of the Apple Watch are analyzed; and the sleep stages with different power and turnover times are marked.As an illustration, REM sleep typically involves rapid eye movements and muscle paralysis, resulting in a heightened frequency of body movements and position changes.Conversely, during the transition to deep sleep stages within NREM sleep, the frequency of these movements diminishes, reflecting reduced turnover activity.In heartbeat analysis, the frequency and timing characteristics of heart rate variability are extracted by frequency spectral analysis and other processing, then matched with brain wave results to build a sleep stage model.For example, during REM sleep, the Beta and Alpha brain waves are more active, and the analysis results of heart rate variability are also excitatory, while during NREM sleep, the analysis results are relaxed.When the cloud sleep stage analysis algorithm model is updated, the sleep data are uploaded to the system by the user, the sleep stages are analyzed, and the analysis results are sent back to the user.

Brain Wave Analysis
Within the realm of frequency domain analysis, the initial time series data are transformed into the frequency domain by utilizing fast Fourier transform (FFT).This transformation enables the examination of the power spectral density (PSD).FFT enhances the computational efficiency of discrete Fourier transform calculations, expediting the overall process.In this context, x[k] represents the PSD resulting from the conversion from the time domain to the frequency domain, while x[n] signifies the discrete Fourier transform of the signal at n data points.This relationship is represented as follows: Using Formula (1), brain waves can be divided into beta, alpha, theta, and delta waves, and the periodic changes of N1, N2, N3, and N4 from REM and REM can be distinguished by calculating and classifying the characteristic wave generation time of each interval.

HRV Analysis
When delving into the analysis of HRV concerning sympathetic and parasympathetic nervous activity within the time domain, one crucial metric is the standard deviation of NN intervals (SDNN).NN intervals correspond to the intervals between successive R-waves in the ECG signal.The calculation of SDNN can be outlined as follows: In this context, where RR i represents the RR period in milliseconds, N denotes the total count of RR periods, the calculation for SDNN can be presented as: The frequency domain analysis of HRV involves transforming each change in heartbeat interval into the frequency domain, then enabling the evaluation of sympathetic and parasympathetic nerve activities.This information is then expressed as the power frequency density, allowing for the exploration of physiological states across different time intervals.The calculation procedure is illustrated in Formula (1).By employing specific frequency ranges, the indices for sympathetic nerve activity (0.04-0.15 Hz, considered the low-frequency band) that signify wakefulness and heightened activity; parasympathetic nerve activity (0.15-0.4 Hz, categorized as the high-frequency band), which is representative of relaxation; and the sympathetic-to-parasympathetic activity balance index (LF-to-HF power ratio, denoted as LF/HF), which indicates the equilibrium between hyperactivity and relaxation, are derived.

Sleep Turn-Over Analysis
The analysis of sleep turnover states involves the capture of turnover data using an accelerometer, which is worn as a sleep bracelet.The accelerometer can discern movement and acceleration along the X, Y, and Z axes.It records these motion patterns over an extended period during sleep, enabling the inference of the frequency and extent of various sleep stages.Mathematician Leonard Euler introduced the notion that a rigid body's position can be described within a three-dimensional space [49].The definition and computation of this three-dimensional space involve three angles, represented as R (ϕ, θ, ψ), which are outlined as follows: After the coordinate system is decomposed into a single rigid body, in turn, the gap between the current turned position and the original position can be calculated, and the combined calculation is as follows: Appl.Sci.2023, 13, 9921 7 of 14 In this study, software services were adopted.Through the hybrid cloud architecture of Microsoft Windows Azure, according to the functions of data analysis and data storage, Azure Active Directory, Azure Blob Storage, Azure Databricks, and Azure SQL Data Warehouse were established for data integration.They provided users with structured tasks such as an access verification security mechanism, data access, and data analysis and return.Figure 3 shows an architectural diagram of the cloud data analysis system.
After the coordinate system is decomposed into a single rigid body, in turn, the gap between the current turned position and the original position can be calculated, and the combined calculation is as follows: In this study, software services were adopted.Through the hybrid cloud architecture of Microsoft Windows Azure, according to the functions of data analysis and data storage, Azure Active Directory, Azure Blob Storage, Azure Databricks, and Azure SQL Data Warehouse were established for data integration.They provided users with structured tasks such as an access verification security mechanism, data access, and data analysis and return.Figure 3 shows an architectural diagram of the cloud data analysis system.

Experimental Equipment
There were three types of equipment utilized for gathering information on physiological characteristics.The first was the MP150, manufactured by the Biopac Student Lab in the United States.The second was the wGT3X-BT wrist monitor produced by Acti-Graph.Lastly, there is the Apple Watch Series 5, developed by Apple Inc., Cupertino, CA, USA.Among these, the MP150 by the Biopac Student Lab boasts multi-channel physiological recording capabilities.It can capture and record physiological signals like brain waves, electrocardiograms, electromyography, and electrooculograms.These signals can be analyzed using the jointly developed AcqKnowledge® 5.0 software, either within the software itself or via externally developed software (refer to Figure 4).The wGT3X-BT wrist monitor is designed for monitoring daily activities and sleep-related physiological data, including movement thresholds and turnover patterns.The accompanying ActiLife 6.0 software facilitates the analysis and normalization of movement patterns and intensity during wear.It can also assess the turnover frequency and swing during sleep, yielding results such as sleep cycles, latency, and sleep efficiency (as depicted in Figure 5).The Apple Watch Series 5 is a commercial-grade smart wearable with features like news updates, conference alerts, and message notifications.It incorporates advanced optical technology for heart rate recording using the optical volume variation method (Figure 6).

Experimental Equipment
There were three types of equipment utilized for gathering information on physiological characteristics.The first was the MP150, manufactured by the Biopac Student Lab in the United States.The second was the wGT3X-BT wrist monitor produced by ActiGraph.Lastly, there is the Apple Watch Series 5, developed by Apple Inc., Cupertino, CA, USA.Among these, the MP150 by the Biopac Student Lab boasts multi-channel physiological recording capabilities.It can capture and record physiological signals like brain waves, electrocardiograms, electromyography, and electrooculograms.These signals can be analyzed using the jointly developed AcqKnowledge®5.0software, either within the software itself or via externally developed software (refer to Figure 4).The wGT3X-BT wrist monitor is designed for monitoring daily activities and sleep-related physiological data, including movement thresholds and turnover patterns.The accompanying ActiLife 6.0 software facilitates the analysis and normalization of movement patterns and intensity during wear.It can also assess the turnover frequency and swing during sleep, yielding results such as sleep cycles, latency, and sleep efficiency (as depicted in Figure 5).The Apple Watch Series 5 is a commercial-grade smart wearable with features like news updates, conference alerts, and message notifications.It incorporates advanced optical technology for heart rate recording using the optical volume variation method (Figure 6).

Data Identify
This study validated the electrocardiogram (ECG) data, which were measured through the Biopac MP150 system.A two-stage data filtering process was employed to prevent the detection of motion artifacts caused by abnormal heartbeats.For each dataset, the R-R interval was compared to the average of the adjacent data points.If the average difference exceeded 30%, the data point was excluded.Subsequently, the remaining data points underwent a comprehensive average analysis, and a comparison was made with the remaining dataset.If the difference also exceeded 30%, the previous data exclusion process was repeated iteratively until the overall average of the remaining data points no

Data Identify
This study validated the electrocardiogram (ECG) data, which were measured through the Biopac MP150 system.A two-stage data filtering process was employed to prevent the detection of motion artifacts caused by abnormal heartbeats.For each dataset, the R-R interval was compared to the average of the adjacent data points.If the average difference exceeded 30%, the data point was excluded.Subsequently, the remaining data points underwent a comprehensive average analysis, and a comparison was made with the remaining dataset.If the difference also exceeded 30%, the previous data exclusion process was repeated iteratively until the overall average of the remaining data points no

Data Identify
This study validated the electrocardiogram (ECG) data, which were measured through the Biopac MP150 system.A two-stage data filtering process was employed to prevent the detection of motion artifacts caused by abnormal heartbeats.For each dataset, the R-R interval was compared to the average of the adjacent data points.If the average difference exceeded 30%, the data point was excluded.Subsequently, the remaining data points underwent a comprehensive average analysis, and a comparison was made with the remaining dataset.If the difference also exceeded 30%, the previous data exclusion process was repeated iteratively until the overall average of the remaining data points no

Data Identify
This study validated the electrocardiogram (ECG) data, which were measured through the Biopac MP150 system.A two-stage data filtering process was employed to prevent the detection of motion artifacts caused by abnormal heartbeats.For each dataset, the R-R interval was compared to the average of the adjacent data points.If the average difference exceeded 30%, the data point was excluded.Subsequently, the remaining data points underwent a comprehensive average analysis, and a comparison was made with the remaining dataset.If the difference also exceeded 30%, the previous data exclusion process was repeated iteratively until the overall average of the remaining data points no longer differed by more than 30%.If the percentage of excluded data points exceeded 5% of the total dataset, the data for that particular user were entirely excluded and not used for analysis [51,52].

Experiemental Environment
In this study, we arranged a designated sleeping area for conducting the sleep experiments.The sleeping environment entailed a dimly lit room with black flannel fabric devoid of lighting fixtures.A bed measuring 1.8 m in length and 0.6 m in width was provided within the sleeping space.Adjacent to the bed, a Biopac MP150 apparatus was positioned to gather brain wave and electrocardiogram data, as illustrated in Figure 7.
Appl.Sci.2023, 13, x FOR PEER REVIEW 9 of 14 longer differed by more than 30%.If the percentage of excluded data points exceeded 5% of the total dataset, the data for that particular user were entirely excluded and not used for analysis [51,52].

Experiemental Environment
In this study, we arranged a designated sleeping area for conducting the sleep experiments.The sleeping environment entailed a dimly lit room with black flannel fabric devoid of lighting fixtures.A bed measuring 1.8 m in length and 0.6 m in width was provided within the sleeping space.Adjacent to the bed, a Biopac MP150 apparatus was positioned to gather brain wave and electrocardiogram data, as illustrated in Figure 7.

Analysis Results and Discussion of Sleep Data
As shown in Figure 8, the total duration of the sleep analysis was 60 min, and statistical analysis was conducted once every 30 s.A total of 120 pieces of data were obtained, which captured the results of Delta, Theta, Alpha, and Beta brain waves, as well as the accelerometer Gyro.The horizontal axis of the graph was divided into 120 intervals, with each interval representing 30 s of physiological information.Figure 9 shows the HRV analysis results during sleep.Sleep was divided into 11 sections.The first 3 min constituted the baseline, followed by 10 min as the first section.Then, each analysis street continued the previous section of data for 5 min and overlapped for the next 5 min until the end of sleep, for a total of 11 units.The findings revealed that

Analysis Results and Discussion of Sleep Data
As shown in Figure 8, the total duration of the sleep analysis was 60 min, and statistical analysis was conducted once every 30 s.A total of 120 pieces of data were obtained, which captured the results of Delta, Theta, Alpha, and Beta brain waves, as well as the accelerometer Gyro.The horizontal axis of the graph was divided into 120 intervals, with each interval representing 30 s of physiological information.
Appl.Sci.2023, 13, x FOR PEER REVIEW 9 of 14 longer differed by more than 30%.If the percentage of excluded data points exceeded 5% of the total dataset, the data for that particular user were entirely excluded and not used for analysis [51,52].

Experiemental Environment
In this study, we arranged a designated sleeping area for conducting the sleep experiments.The sleeping environment entailed a dimly lit room with black flannel fabric devoid of lighting fixtures.A bed measuring 1.8 m in length and 0.6 m in width was provided within the sleeping space.Adjacent to the bed, a Biopac MP150 apparatus was positioned to gather brain wave and electrocardiogram data, as illustrated in Figure 7.

Analysis Results and Discussion of Sleep Data
As shown in Figure 8, the total duration of the sleep analysis was 60 min, and statistical analysis was conducted once every 30 s.A total of 120 pieces of data were obtained, which captured the results of Delta, Theta, Alpha, and Beta brain waves, as well as the accelerometer Gyro.The horizontal axis of the graph was divided into 120 intervals, with each interval representing 30 s of physiological information.Figure 9 shows the HRV analysis results during sleep.Sleep was divided into 11 sections.The first 3 min constituted the baseline, followed by 10 min as the first section.Then, each analysis street continued the previous section of data for 5 min and overlapped for the next 5 min until the end of sleep, for a total of 11 units.The findings revealed that during the initial 10 min of sleep, sympathetic nerve activity surpassed parasympathetic nerve activity.However, a shift occurred approximately 30 min into sleep, with the parasympathetic nerve activity beginning to outweigh the sympathetic nerve activity.When the sympathetic nerve activity was higher, the subject's physiological condition was more focused and excited, meaning that they had not yet entered sleep at this time.On the contrary, the higher the parasympathetic nerve activity was, the closer became is to the situation during sleep.The analysis results demonstrated a positive correlation between brain waves, heartbeat, and gyroscope during sleep.As the sleep duration extended, the analysis outcomes for heart rate variability post-sleep exhibited a greater sense of relaxation.Moreover, there was an elevation in the presence of Delta waves in the brain wave patterns, coupled with a decrease in the recorded gyroscope response when the body underwent turnovers.
Appl.Sci.2023, 13, x FOR PEER REVIEW 10 of 14 during the initial 10 min of sleep, sympathetic nerve activity surpassed parasympathetic nerve activity.However, a shift occurred approximately 30 min into sleep, with the parasympathetic nerve activity beginning to outweigh the sympathetic nerve activity.When the sympathetic nerve activity was higher, the subject's physiological condition was more focused and excited, meaning that they had not yet entered sleep at this time.On the contrary, the higher the parasympathetic nerve activity was, the closer became is to the situation during sleep.The analysis results demonstrated a positive correlation between brain waves, heartbeat, and gyroscope during sleep.As the sleep duration extended, the analysis outcomes for heart rate variability post-sleep exhibited a greater sense of relaxation.Moreover, there was an elevation in the presence of Delta waves in the brain wave patterns, coupled with a decrease in the recorded gyroscope response when the body underwent turnovers.

Cloud Data Analysis System
The cloud sleep staging system quantified the brain wave, heartbeat, and gyro information through the sleep data of previous research, converted them into a database, and then introduced machine learning to establish a new data analysis model.The function of uploading background data was added by extending the mobile phone Sleep Assist App, developed in the early stages of this research.After the user agreed to collect, analyze, and post-process the physiological data, the data were uploaded and returned to the user's app through online system analysis so that the user could obtain their sleep status results.As shown in Figure 10, the function flow of the sleep aid app and cloud analysis was followed.

Cloud Data Analysis System
The cloud sleep staging system quantified the brain wave, heartbeat, and gyro information through the sleep data of previous research, converted them into a database, and then introduced machine learning to establish a new data analysis model.The function of uploading background data was added by extending the mobile phone Sleep Assist App, developed in the early stages of this research.After the user agreed to collect, analyze, and post-process the physiological data, the data were uploaded and returned to the user's app through online system analysis so that the user could obtain their sleep status results.As shown in Figure 10, the function flow of the sleep aid app and cloud analysis was followed.
Appl.Sci.2023, 13, x FOR PEER REVIEW 10 of 14 during the initial 10 min of sleep, sympathetic nerve activity surpassed parasympathetic nerve activity.However, a shift occurred approximately 30 min into sleep, with the parasympathetic nerve activity beginning to outweigh the sympathetic nerve activity.When the sympathetic nerve activity was higher, the subject's physiological condition was more focused and excited, meaning that they had not yet entered sleep at this time.On the contrary, the higher the parasympathetic nerve activity was, the closer became is to the situation during sleep.The analysis results demonstrated a positive correlation between brain waves, heartbeat, and gyroscope during sleep.As the sleep duration extended, the analysis outcomes for heart rate variability post-sleep exhibited a greater sense of relaxation.Moreover, there was an elevation in the presence of Delta waves in the brain wave patterns, coupled with a decrease in the recorded gyroscope response when the body underwent turnovers.

Cloud Data Analysis System
The cloud sleep staging system quantified the brain wave, heartbeat, and gyro information through the sleep data of previous research, converted them into a database, and then introduced machine learning to establish a new data analysis model.The function of uploading background data was added by extending the mobile phone Sleep Assist App, developed in the early stages of this research.After the user agreed to collect, analyze, and post-process the physiological data, the data were uploaded and returned to the user's app through online system analysis so that the user could obtain their sleep status results.As shown in Figure 10, the function flow of the sleep aid app and cloud analysis was followed.Figure 11 shows the HRV analysis results of the heartbeat data uploaded by the users.The data analysis results demonstrate that the results of professional physiological signal equipment acquisition analyses were similar to the analyses of wearable devices after sleeping for 15 min until waking up.
According to the HRV analysis results in Figures 9 and 11, the tendency of the subjects to relax grew stronger and stronger at 10-20 min, and after sleeping for 45 min, the relaxed states began to slowly end and the subjects gradually returned to an awake state.The analysis results of the professional physiological signal equipment showed sensitivity, with evident relaxation and excitement alternating in the trend, while the analysis results of physiological signals captured by wearing devices changed slightly and tended to be relaxed.The analysis results of intelligent wearable devices were inconsistent with the results of professional physiological signal acquisition equipment before waking up and falling asleep for 20 min.Still, they were highly compatible with the analysis results of professional physiological signal equipment after sleeping for 20 min.Figure 11 shows the HRV analysis results of the heartbeat data uploaded by the users.The data analysis results demonstrate that the results of professional physiological signal equipment acquisition analyses were similar to the analyses of wearable devices after sleeping for 15 min until waking up.According to the HRV analysis results in Figures 9 and 11, the tendency of the subjects to relax grew stronger and stronger at 10-20 min, and after sleeping for 45 min, the relaxed states began to slowly end and the subjects gradually returned to an awake state.The analysis results of the professional physiological signal equipment showed sensitivity, with evident relaxation and excitement alternating in the trend, while the analysis results of physiological signals captured by wearing devices changed slightly and tended to be relaxed.The analysis results of intelligent wearable devices were inconsistent with the results of professional physiological signal acquisition equipment before waking up and falling asleep for 20 min.Still, they were highly compatible with the analysis results of professional physiological signal equipment after sleeping for 20 min.

Conclusions
Prior research has shown that collecting physiological data via polysomnography can lead to wearer discomfort during sleep [53][54][55].In light of this, our study introduces an algorithmic analysis module tailored for the interpretation of physiological data harnessed from intelligent wearable devices.This module harmonizes the acquired physiological data from smart wearables with closely correlated data derived from polysomnography, thereby delineating sleep stages.The primary focus of this investigation revolves around the enhancement of sleep quality, encompassing the following key facets: 1.A novel sleep state algorithm is proffered for interpreting sleep stages using physiological signals from smart wearable devices.The primary objective is to mitigate the reliance on conventional physiological signal acquisition instruments that necessitate direct physical contact with the body.2. Through a comprehensive analysis of cloud-based databases and the uploading of personalized physiological data, our study presents an iterative updating mechanism for personalized and precise sleep algorithms.Each set of individual physiological data is subjected to a secondary analysis compared to the original dataset, facilitating the calibration of individual physiological data algorithms.These refinements con-

Conclusions
Prior research has shown that collecting physiological data via polysomnography can lead to wearer discomfort during sleep [53][54][55].In light of this, our study introduces an algorithmic analysis module tailored for the interpretation of physiological data harnessed from intelligent wearable devices.This module harmonizes the acquired physiological data from smart wearables with closely correlated data derived from polysomnography, thereby delineating sleep stages.The primary focus of this investigation revolves around the enhancement of sleep quality, encompassing the following key facets: 1.
A novel sleep state algorithm is proffered for interpreting sleep stages using physiological signals from smart wearable devices.The primary objective is to mitigate the reliance on conventional physiological signal acquisition instruments that necessitate direct physical contact with the body.

2.
Through a comprehensive analysis of cloud-based databases and the uploading of personalized physiological data, our study presents an iterative updating mechanism for personalized and precise sleep algorithms.Each set of individual physiological data is subjected to a secondary analysis compared to the original dataset, facilitating the calibration of individual physiological data algorithms.These refinements consider variations in physiological markers during periods of inactivity as well as the frequency of bodily movements.

3.
Our research extends beyond prior endeavors in dynamic sleep-inducing illumination [50,[56][57][58], aiming to minimize undue physiological data acquisition and re-shape the paradigm of physiological data analysis from smart wearable devices.Prospective

Figure 1 .
Figure 1.Normal night sleep cycle [46].Distinguishing various sleep states relies on EMG analysis during REM and non-REM (NREM) sleep, as well as the collection of other physiological signals such as brainwaves, heart rate fluctuations, and the frequency and intensity of body movements.Physiological data are collected through brainwave analysis to differentiate between sleep states and assess sleep quality.Conductive adhesive electrodes are placed externally on the cerebral cortex, allowing for the recording and analysis of the user's brainwave energy distribution before, during, and after sleep using a physiological signal device.This analysis facilitates the evaluation of sleep state and quality.Electrocardiogram (ECG) measurements capture heart potential signals, enabling the recording and quantitative analysis of physiological parameters such as heartbeat intensity and frequency.This data acquisition provides insight into the subject's relaxed and excited sleep states.The categorization of sleep stages is rooted in brainwave analysis, which involves examining the transformation of potential brain energy from time to frequency through Fourier transform.When transitioning from wakefulness to sleep, changes in brainwave frequencies occur.During the awake state, alpha (8-13 Hz) and beta (13-30 Hz) brainwaves are more active.The rapid eye movement (REM) phase exhibits significant low-frequency brainwave signals (2-7 Hz) and heightened EMG activity.In non-REM (NREM) sleep, deep sleep phases (N3 and N4) are characterized by the presence of delta (0.5-4 Hz) and theta (4-7 Hz) waves, which constitute a substantial portion of the overall energy distribution.Notably, deep sleep stage N4 is dominated by delta waves [47].Analyzing heartbeats during sleep involves the recording of each heartbeat cycle using physiological signal devices.These cycles begin with the electrical impulse of the sinoatrial node, leading to atrial and ventricular contractions.Electrocardiogram (ECG) results are subjected to three methods of analysis: time, frequency, and nonlinearity.Time domain analysis includes metrics such as the mean, standard deviation, and percentiles of the R-wave interval (refer to Figure2).Frequency domain analysis involves Fourier or wavelet transform to distinguish energy distribution between sympathetic and parasympathetic nervous activities at both low (0.04-0.15 Hz) and high (0.15-0.4 Hz) frequencies.The nonlinear analysis encompasses graphical and parameter-based methods, with graphical analysis presenting ECG scatter plots that reveal trends in heart rate variability (HRV)[48].

Figure 2 .
Figure 2. Schematic diagram of the heartbeat cycle period.

Figure 2 .
Figure 2. Schematic diagram of the heartbeat cycle period.

Figure 3 .
Figure 3. Architecture diagram of the data analysis system.

Figure 3 .
Figure 3. Architecture diagram of the data analysis system.

Figure 8 .
Figure 8. Brain waves measured during sleep and gyro analysis results.

Figure 8 .
Figure 8. Brain waves measured during sleep and gyro analysis results.

Figure 9
Figure9shows the HRV analysis results during sleep.Sleep was divided into 11 sections.The first 3 min constituted the baseline, followed by 10 min as the first section.Then, each analysis street continued the previous section of data for 5 min and overlapped for the next 5 min until the end of sleep, for a total of 11 units.The findings revealed that

Figure 8 .
Figure 8. Brain waves measured during sleep and gyro analysis results.

Figure 10 .
Figure 10.Sleep Assist App expands the functions of cloud analysis.

Figure 10 .
Figure 10.Sleep Assist App expands the functions of cloud analysis.Figure 10.Sleep Assist App expands the functions of cloud analysis.

Figure 10 .
Figure 10.Sleep Assist App expands the functions of cloud analysis.Figure 10.Sleep Assist App expands the functions of cloud analysis.

Figure 11 .
Figure 11.HRV analysis results of heartbeat data uploaded by users.

Figure 11 .
Figure 11.HRV analysis results of heartbeat data uploaded by users.