//Logo Image
Author: Chih-Ming Cheng (2007-07-11); recommended: Yeh-Liang Hsu (2007-07-).
Note: This article is Chapter 2 of Chih-Ming Cheng’s PhD thesis “Development of a portable system for tele-monitoring of sleep in a home environment.

Chapter 2. Development of a portable device for tele-monitoring of physical activities during sleep

This chapter describes the development of a “Physical Activity Detecting Mat (PAD-Mat)”, which is designed for long-term monitoring at home based on the PTMS structure. The PAD-Mat on-line monitors physical activities during sleep, which is an indicator of sleep quality. Users and caregivers can access the PAD-Mat for historical monitoring data via the Internet.

This chapter is organized as follows. Section 2.1 describes the structure of the PAD-Mat. Section 2.2 and Section 2.3 presents the algorithm design and network framework of the PAD-Mat. Section 2.4 discusses the validation results of the PAD-Mat. In summary, Section 2.5 describes the applications and benefit of the PAD-Mat.

2.1 Structure the PAD-Mat

Figure 2-1 shows the structure of the PAD-Mat developed in this research. Similar to the PTMS structure in Chapter 1, the core component of the PAD-Mat is a DDS that detects activity signals from upper limb, body and leg, captured by 3 conductive mats.

As described in the previous chapters, the DDS consists of a PIC server mounted on a peripheral application board. The PIC server integrates a PIC microcontroller (PIC18F6722, Microchip), EEPROM (24LC1025, Microchip) and a networking IC (RTL8019AS, Realtek). It provides networking capability and can be used as a web server. The lengths of upper limb movement, body movement and leg movement per minute, are recorded in the Multi-Media-Card (MMC) of the DDS. Authorized remote users can request data from the DDS using an Internet web browser (through an application server) or a VB program (direct access to the DDS).

This portable tele-monitoring device provides a non-constrain and non-conscious approach to monitor physical activities during sleep. The PAD-Mat can be used to monitor motor disturbances, such as restless legs syndrome (RLS) and periodic limb movements during sleep (PLMS), and in-bed detection. Once an object was identified as an object with no activities for 30 minutes, an event-driven message (mobile phone short messages or emails) can be sent to specified caregivers. In addition, using the sleep activity index (SAI) proposed in this research, sleep and awake stages can be classified on-line for further analysis.

Figure 2-1. Structure of the PAD-Mat

2.2     Design of the PAD-Mat

As shown in Figure 2-1, 3 conductive mats placed under the chest, hip, and legs are used in the PAD-Mat to detect the physical activities with the resistance changes of the mats. The signals are analyzed with the physical activity detecting algorithms. The following sections describe the design of conductive mats, the in-bed detecting algorithm, the physical activity evaluating algorithm and sleep/awake identifying algorithm in details.

2.2.1        Design of the conductive mats

The conductive mats are made of conductive fabric [Ming Young Biomedical Corp., Taiwan]. The construction of the conductive mat is inspired by the intestinal villi, which increase the surface area of absorption. Figure 2-2 shows the appearance and the dimensions of the type-A conductive mat, which is designed for monitoring limb activities. In order to detect in-bed subjects, the type-B conductive mat is made of a conductive mat and non-conducting foams (Figure 2-3). The electrical resistance of the type-B conductive mats restores sufficiently after the subject leaves the bed.

As shown in Figure 2-4, The PAD-mat is composed of 2 type-A mats and 1 type-B mat. Two pieces of type-A conductive mats are used for detecting upper limb and leg activities (the “upper limb mat” and the “leg mat”). In the mean time, one piece of type-B conductive mat is used for detecting body activities (the “body mat”). Physical activities are captured as the electrical resistance changes with motion on each mat. Figure 2-5 shows a dividing circuit used in this research, which converts resistance changes of the body mat into voltage changes.

Figure 2-2(a) Appearance of conductive mats (type-A)

Figure 2-2(b) Dimensions of conductive mats (type-A)

Figure 2-3(a) Appearance of conductive mats (type-B)

Figure 2-3(b) Dimensions of conductive mats (type-B)

Figure 2-4. Placement of the PAD-mat

Figure 2-5. A dividing circuit for converting resistance changes into voltage changes

The analog signals are digitized at a sampling frequency of 2KHz with a 10-bit A/D converter in a PIC server. The signals are processed by a series of smoothing procedures and analyzed with the physical activity detecting algorithms. Figure 2-6(a) shows a 4-min record of the body mat input signals. The subject laid on the bed for about 3 minutes and changed body position at the 2nd minute. A series of smoothing and simplifying further processes these signals. A moving average filter with a window size of 20 smoothes the profile of the input voltage values. After that, the signals are further simplified to 10 data points per second to save computational resource in the following detecting algorithms. This procedure is applied to signals from all 3 conductive mats.

Figure 2-6(a). Input voltages of body activities

Figure 2-6(b). Smoothed and simplified values of the input voltage

2.2.2        In-bed detecting algorithm

The body mat is used to detect whether the subject is in bed or not. The input voltage stays at 3.3 V when the bed is empty and decreases when the subject lies on the mat. With a threshold limit 3.2V, a data is coded “1” if the input voltage is below the threshold limit and a “0” if the input voltage is above the threshold limit. Figure 2-7 shows a one-night record of the input voltage of body mat, the subject went to bed at around 2:35 AM, and left bed at around 8:15 AM. Body movements might cause transient increases of voltage which results in rapid switch from “0” to “1”. To avoid that problem, if there are more “1” than “0” in that minute, the minute is coded “1” and vice versa. The PAD-Mat recognizes the input voltage values as a series of “In-bed Codes” and the total in-bed time is 340 minutes.

Figure 2-7. In-bed detection by the body mat

2.2.3        Physical activity evaluating algorithm

After the smoothing and simplifying procedure, the physical activity detecting algorithm analyzes the data and output activity indexes by the following steps:

(1)   Calculate the absolute slope values of activity signals in Figure 2-6(b), as shown in Figure 2-9(a).

(2)   Symbolize a slope value with an activity code “1” if it is above the threshold limit and a “0” if the slope value is under the threshold limit. Figure 2-9(b) shows a 10-second clip of Figure 2-9(a), a body movement was recognized as a series of Activity Codes “1”, using a threshold limit 0.025. The threshold limit for upper limb and leg activities are both 0.02.

(3)   Tally the counts of “1” series each minute as the “Body Activity Index (BAI)”, which represents the length of activities occurred in the past minute. Figure 2-9(c) shows the body activity index versus time of Figure 2-6(a). 3 body movements, lasted 1.5, 1.2, and 1.5 seconds, have been recognized.

Figure 2-9(a). Absolute Slope values of a subject (6 minutes)

Figure 2-9(b). Activity code of a body movement (Threshold limit value=0.02)

Figure 2-9(c). The body activity index versus time

Follow the same procedure, the PAD-Mat also tallies the “Upper Limb Activity Index (ULAI)” and the “Leg Activity Index (LAI)” for each minute. Figure 2-10 shows a 7.5-hour record of the ULAI, BAI and LAI of a subject evaluated by PAD-Mat. ULAI, LAI and BAI, which represent the duration of activities happened in a minute are quantitative indexes for assessing physical activities. These indexes can be used for the diagnosis of motor disturbances that are triggered by sleep such as restless legs syndrome (RLS) and periodic limb movements during sleep (PLMS).

Figure 2-10. Activity indexes of a subject from 0:30 to 8:00 AM

2.2.4        Sleep/awake classification algorithm

In sleep, motor activity is reduced in comparison to the waking state. The frequency of all movements decreases with depth of sleep, with progressive decrease in the number of movements from stage I to stage IV [Chokroverty, et al., 2003].

Since the late 1970s, a growing number of studies have demonstrated the validity of actigraphy in distinguishing between sleep and wakefulness. Jean-Louis et al. [1996] utilized a simple technique for scoring sleep/awake epoches. The epoches containing higher activity than a given threshold were scored as awake and lower activity as sleep. Moreover, arousals lasting 3 minutes or less were rescorded as sleep. Cole et al. [1992] proposed several rules:

(1)    The sleep of 1, 3, or 4 minutes was rescored as wake if it is preceded by at least 4, 10, or 15 minutes of wake, respectively.

(2)    2. The sleep of 6 or 10 minutes surrounded by at least 10 or 20 minutes of awake was rescored as awake, respectively.

Sadeh et al. [1995] used logistic regression analysis for the variables while the sleep/wake classification of PSG acted as the dependent variable in the analysis. Five activity variables were computed for each epoch in the activity signals: original value, mean, standard deviation, number of epoches above a specified activity level, and the natural logarithm. Most actigraphy related devices scored signals using similar algorithms.

Rachwalski et al. [2005] use a pressure pad, placed below a person’s hips, to measure activity in bed. Activity in bed is measured by changes in the pressure measurements. The pressure measurements aggregated into 30-second epoches by averaging the data every 30 seconds. Awakenings (or periods of restlessness) are defined by 3 consecutive minutes of body movements. Choi et al. [2007] designed a bed actigraphy system for distinguishing between sleep and awake. Signals were coded as “1” as the intensity of signals higher than the threshold. If the duration of “1” is longer than 3 seconds in an epoch (30 second length), the epoch is scored as “awake”. To sum up, both the quantity and tendency of physical activity are considered as the character of physical activity and used for the evaluating of level of awakening.

To identify the subject’s sleep condition in real time, ULAI, BAI and LAI detected by the PAD-Mat are used to recognize whether the subject is asleep in this research. To consider the tendency of activity, weighted activity indexes are calculated with activity index of the past minutes. For example, weighted-BAI of the i-th minute is calculated as Equation (2-1). Weighted-ULAI and weighted-LAI are also calculated by the same equation. (Add a paragraph here to explain the meaning of this equation in more details)


To explain the relationship between physical activities and sleep depth, sleep reports from PSG and physical activity data measured by the PAD-Mat were collected from 5 subjects. Sleep depth was based on the PSG report and scored by minute. Sleep depth is coded “0” if PSG recognized 2 epoches (1 minute) as awake, and “1” as 2 sleep epoches were detected. If there were only 1 sleep epoch in the past minute, the sleep depth was coded “0.5”. Regression analyses were operated to explain the relationship between physical activities and sleep depth. Three 80-minute epoches of sleep depth 1, 0.5 and 0 were randomly selected from each subject. Regression analyses were operated with weighted activity indexes and different k values. For example, k=5 means the regression analysis model includes weighted-ULAI, weighted-BAI and weighted-LAI, which were calculated by the raw data of past 5 minutes.

Table 2-1 shows that result of regression analyses. ULAI was found to be non-significant with different k values. Equation (2-2) is the regression equation used in this research, which considers both BAI and LAI for evaluating the depth of sleep and with the k value of 5.

        Sleep Depth =                                     (2-2)

Table 2-1. Regression analyses with different k values

k value






N (P=0.919)

N (P=0.195)

N (P=0.214)


N (P=0.125)

N (P=0.559)

Y (P=0.032)


N (P=0.082)

N (P=0.085)

Y (P=0.079)


N (P=0.087)

Y (P=0.010)

N (P=0.258)


N (P=0.390)

Y (P=0.008)

Y (P=0.002)


N (P=0.165)

Y (P=0.049)

Y (P=0.019)

Figure 2-11 shows a 7.5-hour record of W-BAI, W-LAI and sleep depth calculated by Equation (2-1) and (2-2). In this research, the PAD-Mat calculates sleep depth values and classifies the “Sleep Code” of the past minute as “1” if the sleep depth value is higher than 0.5 and “0” if sleep depth value is under the threshold limit (Figure 2-12).

Figure 2-11. W-BAI, W-LAI and Sleep Depth of a subject from 0:00 to 8:00AM

Figure 2-12 shows an 8-hour record (0:00 to 8:00 AM) of In-bed Codes and Sleep Codes of the same data in Figure 2-11, as well as the PAD-Mat output results classified with these two codes. There are 3 “Sleep States” classified by the PAD-Mat. Sleep state for a minute is coded “2” (Sleep) if both Sleep Code and In-bed Code are “1”. Sleep state for a minute is coded “0” (Empty Bed) if both Sleep Code and In-bed Code are “0”. Sleep state for a minute is coded “1” (Awake) if the Sleep Code is “0” and the In-bed code is “1”. Figure 2-12 shows that this subject went to bed at about 0:34 AM and fell asleep at 0:40 AM. After 6 hours of sleep, the subject woke up at about 6:50 AM and left bed at 6:50 AM.

Figure 2-12. In-bed Code, Sleep Code and States evaluated by the PAD-Mat

2.3     User Interface and Network Framework

Figure 2-13 shows the network framework for the PAD-Mat. Doctors and caregivers can access real-time and historical data via a remote VB program. Figure 3-15 shows the VB interface window designed for the PAD-Mat. After typing an IP address and clicking the “real-time” button, real-time information of physical activities per minute and sleep state of the subject are displayed on the left side of the interface window. Three sleep states, sleep, awake and empty bed will be identified.

Doctors and caregivers can monitor 3 patients on the same window. Selecting one of the IP addresses on the left side, the user can also download historical data from the PAD-Mat at this IP address (select a date and time interval on the right side of the interface window and click the “download” button). Diagnosis reports for time to lie on bed and fall asleep, total time of in-bed and sleep duration, within the selected time interval can be tallied automatically. Charts of activity indexes of upper limb, body and leg per minute versus time, and sleep states versus time can also be drawn for further analysis.

Figure 2-13. A framework for the PAD-Mat

Figure 2-14. VB interface window for the Pad-Mat

2.4 Validation test of the PAD-Mat

A validation test was designed to evaluate the performance of the PAD-Mat. The PAD-Mat was used to detect sleep epoches of 5 normal sleepers and 5 sleepers with arousal in whole-night’s sleep. Sleep states judged by the PAD-Mat with Sleep Codes and In-bed Codes were compared epoch-to-epoch with the diagnosis reports by a PSG. Figure 2-15 shows an example of the sleep states scored by PAD-Mat and PSG of normal group B, and Figure 2-16 shows an example of the sleep states scored by PAD-Mat and PSG of arousal group A. As shown in the figures, the subject in Figure 2-15 did not leave bed until 7 AM, while the subject in figure 2-16 went to bathroom at around 5 AM for about 4 minutes.

Figure 2-15. Sleep States scored via PAD-Mat and PSG (Normal group B)

 Figure 2-16. Sleep States scored via PAD-Mat and PSG (Arousal group A)

In the validation test, a one-minute epoch was coded TP if the PAD-Mat and PSG both classified as sleep epoch, and TN if the PAD-Mat and PSG both classified as non-sleep epoch (awake and empty bed). Similarly, a one-minute epoch was coded FP or FN if only the PAD-Mat or only the PSG recognized the state as sleep. Table 2-1 shows the validation results of locating sleep epoches of a subject. The average sensitivity of locating sleep epoches was 89.5%, the average positive predictive value (PPV) was 94.8%, and the average specificity was 84.3%.

Table 2-1. System performance validation results of locating sleep segments



Sleep Time (min)






Non-Sleep Time (min)





















































































8 subjects










2.5 Summary

Since the discovery of actigraphy, the relationship between physical activities and depth of sleep is clear. A growing number of studies have demonstrated the validity of actigraphy in distinguishing between sleep and awake. The agreement rates between actigraphy and PSG-based minute-by-minute sleep/awake scoring are very promising (above 90%) [Sadeh, et al., 1995]. WristCare, which allows long-term online monitoring of the activity of the user, also reported good agreement percents between the scorings of PSG and WristCare (about 80 %).

A portable device for tele-monitoring of physical activities has been developed in this research to evaluate body movements with quantitative measurement and recognize “sleep”, “awake” and “empty bed” state with the In-Bed Code and Sleep Code in real time. In our validation tests, the Pad-Mat shows good sensitivity and specificity in identifying sleep states, and can be a non-constrain approach to better understand the user’s sleep quality. Furthermore, the sensitivity, positive predictive value and specificity of selecting sleep epoches are no different between normal and arousal subjects.

The PAD-Mat system is designed for long-term monitoring at home based under the PTMS structure. The PAD-Mat on-line monitors physical activities and sleep states. Users and caregivers can access the PAD-Mat for historical monitoring data via the Internet. What sets the PTMS apart from most other systems is the focus on a highly decentralized monitoring model and the portable nature of the system. We believe that this is the approach that is needed to make such systems economically viable and acceptable to the end-users.


Choi, B H., Seo, J. W., Choi, J. M., Shin, H. B., Lee, J. Y., Jeong, D. U. and Park, K. S., “Non-constraining sleep/wake monitoring system using bed actigraphy”, Medical and biological engineering and computing, 2007, v. 45, n. 1, pp. 107-14.

Chokroverty, S., Hening, W.A., and Walters, A.S., Sleep and Movement Disorders, 2003, First ed. Philadelphia, Elsevier Science, 2003.

Cole, R.J., Kripke, D.F., Gruen, W., Mullaney, D.J., Gillin, J.C., “Automatic sleep/wake identification from wrist activity”, Sleep, 1992, v. 15, n. 5, pp. 461-469.

Jean-Louis, G., von Gizycki, H., Zizi, F., Fookson, J., Spielman, A., and Nunes, J., “Determination of Sleep and Wakefulness With the Actigraph Data Analysis Software(ADAS)”, Sleep, 1996, v. 19, n. 9, pp. 739-743.

Rachwalski, T., Irvine, S., Steeper, J.W.T., Inkster, D.R., and Wells, C., “Poor quality of Sseep is a precursor of mobility-related adverse events”, in Proceedings of Evidence-based strategies for Patient Falls and Wandering ‘2005.

Sadeh, A., Hauri, P. J., Kripke, D. F., and Lavie, P., “The role of actigraphy in the evaluation of sleep disorders”, Sleep, 1995, v. 18, pp. 288-302.