The previous article covered critical human behavioural traits about sleep that are often neglected, but vital for a healthy lifestyle. To help us keep a check on these items, sleep trackers are an excellent tool to monitor our sleep patterns and provide adequate feedback for a better lifestyle. But, how do they work? Is it beneficial to a common man? To understand this, let us dive into some technical details about sleep trackers and the algorithms behind their operation.
Building algorithms for automated sleep staging – Perspectives and Challenges
The algorithm development life cycle for sleep staging on a commercial wearable device typically comprises three parts regardless of the measurement modality.
- The first step involves segregation between periods of activity and lying down on the bed.
- The next step involves accurate detection of sleep onset. From a consumer’s perspective, this is one of few things they can relate to almost immediately, which renders it immensely important from a development standpoint.
- Once the sleep regions are accurately determined, the final step is to run the staging algorithm on those particular windows of sleep.
Despite the straightforward requirements, there are multiple considerations to be made before a particular sleep staging algorithm is field-ready.
Looking up to the right reference
Sleep staging is clinically carried out through manual observations on Polysomnogram (PSG) waveforms that is a hodgepodge of multiple biosignals, including the Electroencephalogram (EEG), the Electrooculogram (EOG), Chin Electromyogram (EMG), Electrocardiogram (ECG), etc. It is not hard to imagine why this setup is incredibly obtrusive and unsuitable for regular usage. Among the biosignals, EEG provides the most information when considering stages of sleep but happens to be the least comfortable. For these reasons, our group focuses on developing algorithms to accurately obtain sleep stages from chest belt-based ECG and actigraphy measurements.
Given below is a hypnogram that one might expect from a standard night of PSG recording that describes the stage of sleep for a particular person at any given time. On closer observation, it can be noted that there are high-frequency changes from Deep Sleep to Light Sleep which is what is typically observed in many clinical hypnograms.

However, these changes do not manifest at such high frequencies in other modalities like ECG or actigraphy. Moreover, the commercial utility of discerning such rapid changes in sleep stages is highly unclear. Thus, it is more practical to work with a reference signal as given below after tapering out the extremely rapid changes.

Usage of Machine Learning
The effectiveness of Machine Learning algorithms, more specifically Deep Learning algorithms, is well documented. This has been driven by the availability of data and compute power. Despite this increased adoption, there are significant challenges in translating such models onto the field. For starters, the distinct lack of pre-trained models on biosignals makes it very hard to build upon prior information and often requires training from scratch. This is a significant advantage in the fields of computer vision and NLP, where there is good availability of pre-trained models. Secondly, the subject-specific nature of dependency between Heart Rate and sleep stages renders the modelling even more difficult. Finally, the tradeoff between accuracy and controllability is not good enough to move to an end-to-end Machine Learning driven system as far as sleep staging is concerned. For these reasons, while being primarily data-driven, the final commercial algorithm relies very little on Machine Learning and more on traditional Signal Processing techniques.
The transition from research to the field
While data collected in a clinical setting, using a PSG, can be expected to be clean, there are no such guarantees for data obtained in unmonitored conditions. There is a higher possibility of data loss when the underlying hardware has physical limitations. For example, in a chest belt-based ECG device, the possibility of contact issues occurring for people with low BMI (<18) is pretty high when they are lying down on their sides. This leads to breaks in the raw data obtained.

Multiple white blanks can be observed between the orange HR plot indicating severe contact issues for this specific user. The best approach to avoid such occurrences would be to utilize hardware that does not allow for such issues to occur in the first place. In this case, the user could wear a vest embedded with the ECG electrodes. The tradeoff in this instance is accuracy for comfort. A more practical approach for users who opt to use the belt is to impute the waveform before staging, thus ensuring that the windows of HR obtained are staged, as shown below.

Despite the robust signal processing, the accuracy is expected to take a hit as sleep staging on ECG is sequential. In this instance, comfort is traded-off for accuracy. Building a field-ready solution often involves navigating such tradeoffs and making decisions on a case-by-case basis depending on the requirement.
While the hypnogram conveys a lot of information regarding the person’s sleep, a simpler interpretation of sleep is given by a consolidated sleep score that our team has internally developed. More on that in the following article of this series.
Author
Sricharan Vijayarangan
Leave a Reply