Identifying waking time in 24-h accelerometry data in adults using an automated algorithm

ABSTRACT As accelerometers are commonly used for 24-h measurements of daily activity, methods for separating waking from sleeping time are necessary for correct estimations of total daily activity levels accumulated during the waking period. Therefore, an algorithm to determine wake and bed times in 24-h accelerometry data was developed and the agreement of this algorithm with self-report was examined. One hundred seventy-seven participants (aged 40–75 years) of The Maastricht Study who completed a diary and who wore the activPAL3™ 24 h/day, on average 6 consecutive days were included. Intraclass correlation coefficient (ICC) was calculated and the Bland–Altman method was used to examine associations between the self-reported and algorithm-calculated waking hours. Mean self-reported waking hours was 15.8 h/day, which was significantly correlated with the algorithm-calculated waking hours (15.8 h/day, ICC = 0.79, P = < 0.001). The Bland–Altman plot indicated good agreement in waking hours as the mean difference was 0.02 h (95% limits of agreement (LoA) = −1.1 to 1.2 h). The median of the absolute difference was 15.6 min (Q1–Q3 = 7.6–33.2 min), and 71% of absolute differences was less than 30 min. The newly developed automated algorithm to determine wake and bed times was highly associated with self-reported times, and can therefore be used to identify waking time in 24-h accelerometry data in large-scale epidemiological studies.


Introduction
A growing number of studies have used accelerometers for objective assessments of sedentary behaviour and physical activity (Bassett, 2012;Chen & Bassett, 2005;Lee & Shiroma, 2014). Traditionally, participants are instructed to remove the device before going to bed and during water-based activities, and replace the device afterwards. However, when using this method potentially important behaviours, such as sleep, will not be collected. Furthermore, data on the waking period could be missed when participants forget to replace the device, which could result in an underestimation of total daily activity . Thus, to improve compliance and obtain more accurate assessment of total daily activity, studies should ideally use an accelerometer that can be worn 24 h per day without removing the device at any time.
The activPAL™ physical activity monitor (PAL Technologies, Glasgow, UK) is a small and lightweight accelerometer that can be made waterproof and can be attached to the skin (PAL Technologies Ltd., 2010). Consequently, this device can be worn continuously for a period of multiple days, providing complete assessments of all daily performed activity.
Although the 24-h measurement overcomes the issues of incomplete assessments, it results in the challenge of how to identify the waking time in the 24-h period. As the activPAL™ has shown to be highly accurate in determining sedentary time and distinguish this from standing and stepping time (Godfrey, Culhane, & Lyons, 2007;Kozey-Keadle, Libertine, Lyden, Staudenmayer, & Freedson, 2011), the posture allocation will classify both periods of sitting and lying, and thus also sleeping periods, as sedentary time. It is therefore important to identify waking time and separate this from the sleeping period (time in bed) in order to correctly estimate the amount of sedentary time and physical activity accumulated during the waking period.
Currently used methods to identify waking time include a fixed-time window (for example time between 7.00 h and 23.00 h) (De Decker et al., 2013;Smith, Thomas, Bell, & Hamer, 2014;Smith et al., 2015), a diary, or manual (visual) assessment of wake and bed times when analysing the data (Dowd, Harrington, Bourke, Nelson, & Donnelly, 2012). However, using a fixed-time window could easily result in over-or under-estimation of the waking period, and/or misclassification of sleeping time as waking (sedentary) time or vice versa, resulting in incorrect estimations of sedentary behaviour and physical activity. Using diaries increases burden for participants as well as researchers, and manual assessments of wake and bed times are not feasible in studies with a large sample size. In addition, a recently published study in children (such data is not available in an adult population) demonstrated that estimations of the amount of sedentary behaviour differ considerably depending on which of these methods was used (Meredith-Jones, Williams, Galland, Kennedy, & Taylor, 2015).
Methods for identifying sleep have been described for wrist-worn (Marino et al., 2013;Ray et al., 2014;Tracy et al., 2014) and hip- (Kinder et al., 2012;Ray et al., 2014) or waistworn devices Hjorth et al., 2012;Tracy et al., 2014;Tudor-locke, Barreira, Schuna, Mire, & Katzmarzyk, 2014). However, a valid method to determine wake and bed times for identifying waking time or time in bed has not yet been developed for accelerometers that are worn on the lower body, such as the activPAL™. Furthermore, automatic methods to identify waking time on an individual level, e.g., for each day for each participant, are necessary for the analysis of large-scale datasets. Therefore, an automated algorithm was developed to determine wake and bed times in 24-h accelerometry data assessed with the activPAL3™. In this study the agreement of this algorithm to determine wake and bed times with self-report was examined and this algorithm was compared with a fixed-time window, using a subsample of The Maastricht Study.

Study sample
For this study, a subsample of The Maastricht Study was used. The Maastricht Study is an observational prospective population-based cohort study. The rationale and methodology have been described elsewhere (Schram et al., 2014). In short, the study focuses on the causes, pathophysiology, complications and comorbidities of type 2 diabetes mellitus and is characterised by an extensive phenotyping approach. Eligible for participation were all individuals aged between 40 and 75 years and living in the southern part of The Netherlands. The present study included participants who were asked to wear an accelerometer for eight consecutive days and complete a diary for wake and bed times between April and July 2013 (n = 199). After excluding participants who did not wear the accelerometer at least 3 days or who did not complete the diary for at least 3 days, a total of 177 participants were included.
The study has been approved by the Institutional Medical Ethical Committee (NL31329.068.10) and the Minister of Health, Welfare and Sports of The Netherlands, on the basis of the Health Council's opinion (Permit 131088-105234-PG). All participants gave written informed consent.

Measures
The activPAL3™ is a small (53 × 35 × 7 mm), lightweight (15 g) triaxial accelerometer that records movement in the vertical, anteroposterior and mediolateral axes, and also determines posture (sitting/lying, standing, stepping) based on acceleration information. The activPAL3™ was attached directly to the skin on the front right thigh with transparent 3 M Tegaderm™ tape, after the device was waterproofed using a nitrile sleeve. Participants were asked to wear the accelerometer for eight consecutive days, without removing the device at any time. To avoid inaccurate identification of non-wear time, participants were asked not to replace the device once removed. Data were uploaded using the activPAL™ software and processed using customised software written in MATLAB® R2013b (MathWorks. Natick, MA, USA). Data of the first day were excluded from analysis because participants performed physical function tests at the research centre after the device was attached (Schram et al., 2014). In addition, data of the final wear day providing <14 h of data were excluded from analysis.
In addition, participants were asked to write down the exact time (hh:mm) they went to bed (bed time) and the time they got out of bed (wake time) in a diary on each day when wearing the accelerometer.

Algorithm-determined wake and bed times
To automatically determine wake and bed times on an individual level on multiple days (i.e., different wake and bed times, for each day, for each participant), an algorithm written for MATLAB® was developed, using the activPAL3™ events file, that indicates every event (a continuous period of time in which one type of activity is executed, e.g., sitting/lying, standing or one step) of any time duration. Rules and thresholds used in the final version of the algorithm were accomplished by visually comparing output of our algorithm with manually assessed output using the activPAL™ software on which the algorithm was further developed. This procedure was repeated multiple times using different subsets (n = 500) of The Maastricht Study dataset, other than the sample used in the current study. Further, we tested our algorithm by generating sample data in order to evaluate the algorithm's performance, and this demonstrated that our algorithm treated all data as expected (e.g., correctly determined wake and bed times). The algorithm is available for other researchers and can be obtained from the authors. A brief description of the algorithm is given below.
Bed time was based on sedentary bouts of sitting/lying time (sed-bout). At first, the software identified five consecutive sedbouts of any duration (minimum 1 s) using a moving window between 19:00 h and 12:00 h (noon). Next, the duration of each individual bout (sed-bout 1sed-bout 5 ) as well as the sum of duration of sed-bout 1-2 , sed-bout 1-3 , sed-bout 1-4 or sed-bout 1-5 was determined. These values were compared with the pre-set cut-off points (see Table 1). If sed-bout 1 exceeded a cut-off point, bed time was set at the start time of sed-bout 1 . If sedbout 1-2 exceeded a cut-off point, bed time was set at the start time of sed-bout 1 , if the duration of sed-bout 1 >1 h. However, when the duration of sed-bout 1 <1 h, bed time was set at start time of sed-bout 2 . If sed-bout 1-3 or sed-bout 1-4 or sed-bout 1-5 exceeded a cut-off point and all the sed-bouts had a duration >1 h, bed time was set at start time of sed-bout 1 . If one of the sed-bouts had a duration <1 h, the software repeated the procedure by identifying sed-bout 2-6 and further, until bed time was determined. When no following sed-bouts were available, bed time was set at the start time of the first sed-bout of the final five sed-bouts that were identified. When no five sed-bouts were available at all, the sum of the duration of the available sed-bouts was calculated, and when this sum was ≥4 h, bed time was set at the start time of the first sed-bout. When the sum of the sed-bouts was <4 h, no bed time was determined. The algorithm was adapted to the following exceptions: (1) short periods of standing or stepping during the night (for example toileting) were allowed if the total duration <6 min; (2) standing or stepping with a duration ≥15 min which occur before 01:00 h and after a sed-bout ≥2.5 h (e.g., watching TV before going to bed) were classified as waking time.
Wake time was based on bouts of standing or stepping time (act-bout). At first, five sed-bouts starting from 00:00 h were identified, of which the sum of the total duration must be ≥4 h. Then, the start time of sed-bout 1 was determined, and from that point, act-bouts were identified. Next, the act-bouts were tested against 10 pre-set cut-off points for total duration of act-bouts, as well as the duration of act-bouts as percentage of the total time in which these act-bouts occurred (sum of duration of act-bouts and duration of sed-bout, which occurred in-between the act-bouts) (see Table 1). The start time of the first act-bout that exceeded one of the 10 cut-off points, was set as wake time. When no act-bout exceeded a cut-off point, wake time was set at the end time of the five sed-bouts. The algorithm was adapted to the following exception: act-bouts between 03:00 h and 06:00 h which were followed by a sed-bout ≥2 h, were classified as sleeping time.
Waking time was calculated as the time between wake time and bed time.

Self-reported wake and bed times
A diary was used to obtain self-reported wake and bed times. Waking time was calculated as the time between wake time and bed time.

Fixed wake and bed times
The activPAL3™ data was also processed with customised software written in MATLAB® that set for each participant their daily wake time and bed time at 07:00 h and 23:00 h. According to this method, waking time was 16 h for each participant on each day.

Sedentary time
Sedentary time was based on the posture data (sitting/lying), and determined as the total time spent in a sedentary position between wake time and bed time. Sedentary time and percentage sedentary time of total waking time were calculated for both algorithm-determined and fixed-time window methods.

Other variables
Of the 177 participants, the following variables were obtained as described elsewhere (Schram et al., 2014): sex, age (at first day of wearing the activPAL3™), and level of education. Level of education was categorised as low, medium, and high. Weight and height were measured without shoes and wearing light clothing using a scale and stadiometer to the nearest 0.5 kg or 0.1 cm (Seca, Hamburg, Germany). Body mass index (BMI) was calculated as kilogram per meter squared (kg·m −2 ).

Statistical analysis
Descriptive characteristics of the study sample, and their provided self-reported and accelerometry data were summarised as mean and standard deviation (SD) or percentages. The absolute differences between wake times and bed times derived from the algorithm-determined, self-report and fixedtime window methods were calculated and described by range, mean and SD, and median and interquartile range. Absolute differences can provide more useful insights in differences between two methods than mean differences as the latter may result in a value around 0 when over-and underestimations balance each other out.
Waking time was described (range, mean, SD) for all three methods (algorithm-determined, self-report and fixed-time window), and the association between algorithm-determined and self-reported waking time was examined by calculating intraclass correlation coefficients (ICC). Absolute differences and absolute percentage differences in waking time between the algorithm-determined method and the self-report or fixedtime window method were calculated and described by range, mean and SD, and median and interquartile range. The Bland--Altman method was used to determine level of agreement between algorithm-determined and self-reported waking time.
Total amount of sedentary time and percentage sedentary time as determined with the algorithm-determined and the fixed-time window methods were described by range, mean and SD, and median and interquartile range. The absolute differences and absolute percentage differences in sedentary time and percentage sedentary time between these methods were calculated and described by range, mean and SD, and median and interquartile range. The Bland--Altman method was used to determine level of agreement between sedentary time as determined by algorithm and fixed-time window methods. All analyses were conducted with IBM SPSS Statistics 22.0 (IBM Corp. Armonk, NY, USA).

Results
A total of 177 participants completed a diary and wore the accelerometer on average 6 days. Other general characteristics of the study sample are shown in Table 2. This study sample was similar with regard to sex, age, level of education and BMI, compared to The Maastricht Study sample that consists of 3451 participants who completed the baseline survey between November 2010 and September 2013. Table 3 shows the absolute differences between the wake and bed times derived from the algorithm-determined, self-report and fixed-time window methods. The median of the absolute differences between the self-reported and algorithm-determined wake time was 12 min, which indicates that in half of the participants the algorithm-determined wake time differed less than 12 min from their self-reported wake time. For bed times, the algorithm-determined method differed less than 25 min from the self-reported bed times in half of the participants. As presented in Table 4, mean (SD) waking time per day was 15.8 h (0.9) when using the algorithm-determined method, which was comparable with and statistically significantly correlated to the self-reported waking time (15.8 h (0.9); ICC = 0.79; P < 0.001). The median of the absolute differences in waking hours between the algorithm-determined and selfreport methods was 16 min (Q1 -Q3 = 7.6 -33.2 min), and 71% of these absolute differences in all participants was less than 30 min. Further, the median of the absolute percentage difference was 1.7% (Q1 -Q3 = 0.8 -3.5%). Finally, the Bland--Altman plot indicates good agreement between the algorithm-determined and self-reported waking hours, with a mean difference of 0.02 h (1.2 min) and limits of agreement of −1.1 to 1.2 h (Figure 1).

Algorithm-determined versus fixed-time window methods
The fixed-time window method determined wake time at 7:00 h and bed time at 23:00 h for each participant on each day, thus mean waking hours was 16.0 h. Table 4 shows that the median of the absolute differences in waking hours between the algorithm-determined and fixed-time window methods was 32 min (Q1 -Q3 = 17.2 -64.2 min), and the median of the absolute percentage difference was 3.4% (Q1 -Q3 = 1.8 -6.4%). However, Table 3 shows substantial differences in the absolute differences between wake and bed times determined with both methods: the median of the absolute differences was 1 h for wake times, and 51 min for bed times. Furthermore, 26% of the algorithm-determined wake times was before 7:00 h, and 69% of the algorithmdetermined bed times was after 23:00 h (data not tabulated). These results indicate that although the estimated total amount of waking time of 16 h by the fixed-time window method was comparable with the algorithm-determined waking time (i.e., 15.8 h), the determination of the waking period 27.1 (4.6) Number of days with self-reported data 6.9 (0.6) Number of days with accelerometry data 6.7 (0.7) Values are mean (SD), unless stated otherwise. BMI, body mass index. *N = 173.  during the day differed substantially between the methods as illustrated in Figure 2. The figure shows that when, for example, wake time was before 7:00 h and bed time was before 23:00 h, the fixed-time window method misclassified waking time as sleeping time, and sleeping time as waking (sedentary) time. Similar misclassifications could occur with all wake and bed times other than 7:00 h and 23:00 h. Consequently, the amount of sedentary time and the percentage sedentary time were overestimated by the fixed-time window method in comparison with the algorithm-determined sedentary time, because standing/stepping time before 7:00 h and after 23:00 h was classified as sleeping time and therefore excluded from analysis (Table 4 and Figure 3).

Discussion
This study describes the development of an algorithm to automatically determine wake and bed times in 24-h accelerometry data assessed using the activPAL3™ accelerometer. The algorithm achieved high levels of agreement in determining wake times (median of the absolute difference was 12 min) as well as bed times (median of the absolute difference was 25 min) when compared to self-reported diary times. In addition, the algorithm-calculated waking time was highly correlated with the self-reported time, and the mean difference was 0.02 h (1.2 min). Furthermore, 71% of the absolute differences in waking time was less than 30 min, and the median of the absolute percentage difference was 1.7%. These results indicate that the algorithm can be used as an accurate method to automatically identify the waking period and separate this from the sleeping period in 24-h activPAL™ accelerometry data, in middle-aged and older adults when compared to a self-reported method. Consequently, when using the algorithm the amounts of sedentary time and physical activity accumulated during waking time can be estimated correctly, which is of importance for examining associations between sedentary behaviour or physical activity and health outcomes. As there currently is no other method available to automatically separate the waking from the sleeping period for data assessed with the activPAL™, the algorithm is based on rules and thresholds developed in subsets of The Maastricht Study dataset.
Further, the algorithm was compared to a fixed-time window for wake (07:00 h) and bed (23:00 h) times. The results showed considerable differences in determined wake and bed times between the methods, as the median of the absolute difference was 1 h for wake, and 51 min for bed times. However, calculated waking time was comparable (16 vs 15.8 h) between the methods. This indicates that the determination of the waking period during the day differs highly  To date, a method to identify waking time in 24-h data provided by an accelerometer that is worn on the lower body, has not been developed. Methods to determine sleep or time in bed using hip-worn or waist-worn accelerometers have been described before Hjorth et al., 2012;Kinder et al., 2012;Marino et al., 2013;Ray et al., 2014;Tracy et al., 2014;Tudor-locke et al., 2014), and some methods have been shown to be fairly accurate Tracy et al., 2014). Only Barreira and colleagues reported mean differences, and these were larger than the observed mean differences in this study (i.e., 7 ± 29 min). Further, these methods were validated in children and were developed for the ActiGraph accelerometer, based on counts per minute, and could therefore not be used in adults and for data on posture assessed with the activPAL™. Another possibility to identify waking time is using a fixed-time window, which have been used in studies with a 24 h wear time protocol (De Decker et al., 2013;Smith et al., 2014Smith et al., , 2015. However, this study shows that a fixed-time window could result in misclassifications of waking and/or sleeping time, and in overestimations of sedentary time. Other methods include the use of diaries or manual assessment of the waking period (Dowd et al., 2012), but these methods are not appropriate for large-scale studies because of the burden for participants as well as researchers to collect, enter and clean the data. The algorithm overcomes these disadvantages as it allows automatic identification of waking time on each day and for each participant, which reduces time for analysis considerably. Consequently, accurate assessment of 24-h measurements of sedentary behaviour and/or physical activity using the activPAL™ becomes feasible in large-scale studies when using the algorithm.
A strength of this study was the use of data on posture provided by the activPAL3™ to develop the algorithm. As the device uses posture rather than movement, the accuracy for detecting a lying position is increased, which is essential for a more precise identification of time spent in bed. Another strength was that almost all participants (93%) provided 6 days with self-reported and accelerometry data, which enables us to examine our algorithm in several participants on multiple days.
A few limitations of this study should also be mentioned. The algorithm is not able to determine wake and/or bed times when the accelerometer was worn for only a few hours on a day. For example, no wake time could be determined if the accelerometer was removed shortly after the actual wake time, because of a lack of data to process. Further, wake time and bed times could be determined incorrectly as the rules used in the algorithm were not appropriate for each individual. For example, when only short amounts of time with activity (standing or stepping) were accumulated after the actual wake time, or when several periods of activity were accumulated after the actual bed time, the algorithm determined wake or bed times at a later time than the actual time. This resulted in an absolute difference between self-reported and algorithm-determined times of at most 3.5 h. The algorithm may therefore not be applicable for extremely sedentary individuals or individuals with considerable amounts of activity (standing or stepping) during the night. Another limitation is that the self-report method to obtain wake and bed times, which we have used as a reference method, could have been subject to recall bias or were incomplete. However, self-report is a commonly used method in epidemiological studies, and is considered as a standard method to obtain data about the sleeping period (Devine, Hakim, & Green, 2005). Nevertheless, to further validate the algorithm it should be tested against direct observation or polysomnography, although the latter provides estimates of actual sleep rather than the time between participants went to bed and went out of bed. Finally, applicability of the algorithm in other populations (e.g., children and youth), and to other accelerometers should be examined in future studies.

Conclusions
This study showed that a newly developed algorithm to automatically determine wake and bed times on an individual level in 24h accelerometer data was highly associated with self-reported wake and bed times. Therefore, the algorithm could be used as an accurate method to identify waking time when compared to self-reported methods, which overcomes issues of incomplete assessments (differentiate wear time from non-wear time) and could improve compliance for obtaining appropriate assessments. As a result, using an accelerometer with a 24-h wear time protocol becomes feasible, even in large-scale epidemiological studies.

Acknowledgement
The researchers are indebted to the participants for their willingness to participate in the study.