<buttonclass="md-header__button md-icon"title="Switch to light mode"aria-label="Switch to light mode"data-md-option="palette"data-md-color-scheme="default"data-md-color-primary="blue"data-md-color-accent="blue"data-md-state="hidden">
<buttonclass="md-header__button md-icon"title="Switch to dark mode"aria-label="Switch to dark mode"data-md-option="palette"data-md-color-scheme="slate"data-md-color-primary="blue"data-md-color-accent="blue"data-md-state="hidden">
<navclass="md-nav md-nav--secondary"aria-label="Table of contents">
<labelclass="md-nav__title"for="__toc">
<spanclass="md-nav__icon md-icon"></span>
Table of contents
</label>
<ulclass="md-nav__list"data-md-scrollfix>
<liclass="md-nav__item">
<ahref="#rapids-provider"class="md-nav__link">
RAPIDS provider
</a>
</li>
<liclass="md-nav__item">
<ahref="#price-provider"class="md-nav__link">
PRICE provider
</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<divclass="md-content">
<articleclass="md-content__inner md-typeset">
<ahref="https://github.com/carissalow/rapids/edit/master/docs/features/fitbit-sleep-intraday.md"title="Edit this page"class="md-content__button md-icon">
<td>Database table name or file path where the sleep intraday data is stored. The configuration keys in <ahref="../../setup/configuration/#device-data-source-configuration">Device Data Source Configuration</a> control whether this parameter is interpreted as table or file.</td>
</tr>
</tbody>
</table>
<p>The format of the column(s) containing the Fitbit sensor data can be <code>JSON</code> or <code>PLAIN_TEXT</code>. The data in <code>JSON</code> format is obtained directly from the Fitbit API. We support <code>PLAIN_TEXT</code> in case you already parsed your data and don’t have access to your participants’ Fitbit accounts anymore. If your data is in <code>JSON</code> format then summary and intraday data come packed together. </p>
<p>We provide examples of the input format that RAPIDS expects, note that both examples for <code>JSON</code> and <code>PLAIN_TEXT</code> are tabular and the actual format difference comes in the <code>fitbit_data</code> column (we truncate the <code>JSON</code> example for brevity).</p>
<detailsclass="example"><summary>Example of the structure of source data with Fitbit’s sleep API Version 1</summary><divclass="tabbed-set"data-tabs="1:2"><inputchecked="checked"id="__tabbed_1_1"name="__tabbed_1"type="radio"/><labelfor="__tabbed_1_1">JSON</label><divclass="tabbed-content">
<p>All columns are mandatory, however, all except <code>device_id</code>, <code>local_date_time</code> and <code>duration</code> can be empty if you don’t have that data. Just have in mind that some features might be inaccurate or empty as <code>type_episode_id</code>, <code>level</code>, <code>is_main_sleep</code>, and <code>type</code> are used for sleep episodes extraction. <code>type_episode_id</code> is based on where it is extracted: if it is extracted from the 1<sup>st</sup>“minutesData” block, the <code>type_episode_id</code> field will be 0. Similarly, the kth block will be k-1. Actually, you only need to make sure rows extracted from the same “minutesData” block are assigned with the same unique <code>type_episode_id</code> value.</p>
<table>
<thead>
<tr>
<th>device_id</th>
<th>type_episode_id</th>
<th>local_date_time</th>
<th>duration</th>
<th>level</th>
<th>is_main_sleep</th>
<th>type</th>
</tr>
</thead>
<tbody>
<tr>
<td>a748ee1a-1d0b-4ae9-9074-279a2b6ba524</td>
<td>0</td>
<td>2020-10-07 15:55:00</td>
<td>60</td>
<td>awake</td>
<td>0</td>
<td>classic</td>
</tr>
<tr>
<td>a748ee1a-1d0b-4ae9-9074-279a2b6ba524</td>
<td>0</td>
<td>2020-10-07 15:56:00</td>
<td>60</td>
<td>awake</td>
<td>0</td>
<td>classic</td>
</tr>
<tr>
<td>a748ee1a-1d0b-4ae9-9074-279a2b6ba524</td>
<td>0</td>
<td>2020-10-07 15:57:00</td>
<td>60</td>
<td>restless</td>
<td>0</td>
<td>classic</td>
</tr>
</tbody>
</table>
</div>
</div>
</details>
<detailsclass="example"><summary>Example of the structure of source data with Fitbit’s sleep API Version 1.2</summary><divclass="tabbed-set"data-tabs="2:2"><inputchecked="checked"id="__tabbed_2_1"name="__tabbed_2"type="radio"/><labelfor="__tabbed_2_1">JSON</label><divclass="tabbed-content">
<p>All columns are mandatory, however, all except <code>device_id</code>, <code>local_date_time</code> and <code>duration</code> can be empty if you don’t have that data. Just have in mind that some features might be inaccurate or empty as <code>type_episode_id</code>, <code>level</code>, <code>is_main_sleep</code>, and <code>type</code> are used for sleep episodes extraction. <code>type_episode_id</code> is based on where it is extracted: if it is extracted from the 1<sup>st</sup>“data” and “shortData” block, the <code>type_episode_id</code> field will be 0. Similarly, the kth block will be k-1. Actually, you only need to make sure rows extracted from the same “minutesData” block are assigned with the same unique <code>type_episode_id</code> value.</p>
<td>Set to <code>True</code> to extract <code>FITBIT_SLEEP_INTRADAY</code> features from the <code>RAPIDS</code> provider</td>
</tr>
<tr>
<td><code>[FEATURES]</code></td>
<td>Features to be computed from sleep intraday data, see table below</td>
</tr>
<tr>
<td><code>[SLEEP_LEVELS]</code></td>
<td>Fitbit’s sleep API Version 1 only provides <code>CLASSIC</code> records. However, Version 1.2 provides 2 types of records: <code>CLASSIC</code> and <code>STAGES</code>. <code>STAGES</code> is only available in devices with a heart rate sensor and even those devices will fail to report it if the battery is low or the device is not tight enough. While <code>CLASSIC</code> contains 3 sleep levels (<code>awake</code>, <code>restless</code>, and <code>asleep</code>), <code>STAGES</code> contains 4 sleep levels (<code>wake</code>, <code>deep</code>, <code>light</code>, <code>rem</code>). To make it consistent, RAPIDS grouped them into 2 <code>UNIFIED</code> sleep levels: <code>awake</code> (<code>CLASSIC</code>: <code>awake</code> and <code>restless</code>; <code>STAGES</code>: <code>wake</code>) and <code>asleep</code> (<code>CLASSIC</code>: <code>asleep</code>; <code>STAGES</code>: <code>deep</code>, <code>light</code>, and <code>rem</code>).</td>
</tr>
<tr>
<td><code>[SLEEP_TYPES]</code></td>
<td>Types of sleep to be included in the feature extraction computation. Fitbit provides 2 types of sleep: <code>main</code>, <code>nap</code>.</td>
</tr>
<tr>
<td><code>[INCLUDE_SLEEP_LATER_THAN]</code></td>
<td>All resampled sleep rows (bin interval: one minute) that started after this time will be included in the feature computation. It is a number ranging from 0 (midnight) to 1439 (23:59) which denotes the number of minutes after midnight. If a segment is longer than one day, this value is for every day.</td>
</tr>
<tr>
<td><code>[REFERENCE_TIME]</code></td>
<td>The reference point from which the <code>[ROUTINE]</code> features are to be computed. Chosen from <code>MIDNIGHT</code> and <code>START_OF_THE_SEGMENT</code>, default is <code>MIDNIGHT</code>. If you have multiple time segments per day it might be more informative to set this flag to <code>START_OF_THE_SEGMENT</code>.</td>
</tr>
</tbody>
</table>
<p>Features description for <code>[FITBIT_STEPS_INTRADAY][PROVIDERS][RAPIDS][LEVELS_AND_TYPES]</code>:</p>
<td>Number of <code>[LEVEL][TYPE]</code>sleep episodes. <code>[LEVEL]</code>is one of <code>[SLEEP_LEVELS]</code> (e.g. awake-classic or rem-stages) and <code>[TYPE]</code> is one of <code>[SLEEP_TYPES]</code> (e.g. main). Both <code>[LEVEL]</code>and <code>[TYPE]</code> can also be <code>all</code> when <code>LEVELS_AND_TYPES_COMBINING_ALL</code> is True, which ignores the levels and groups by sleep types.</td>
</tr>
<tr>
<td>sumduration<code>[LEVEL][TYPE]</code></td>
<td>minutes</td>
<td>Total duration of all <code>[LEVEL][TYPE]</code>sleep episodes. <code>[LEVEL]</code>is one of <code>[SLEEP_LEVELS]</code> (e.g. awake-classic or rem-stages) and <code>[TYPE]</code> is one of <code>[SLEEP_TYPES]</code> (e.g. main). Both <code>[LEVEL]</code> and <code>[TYPE]</code>can also be <code>all</code> when <code>LEVELS_AND_TYPES_COMBINING_ALL</code> is True, which ignores the levels and groups by sleep types.</td>
</tr>
<tr>
<td>maxduration<code>[LEVEL][TYPE]</code></td>
<td>minutes</td>
<td>Longest duration of any <code>[LEVEL][TYPE]</code>sleep episode. <code>[LEVEL]</code>is one of <code>[SLEEP_LEVELS]</code> (e.g. awake-classic or rem-stages) and <code>[TYPE]</code> is one of <code>[SLEEP_TYPES]</code> (e.g. main). Both <code>[LEVEL]</code> and <code>[TYPE]</code>can also be <code>all</code> when <code>LEVELS_AND_TYPES_COMBINING_ALL</code> is True, which ignores the levels and groups by sleep types.</td>
</tr>
<tr>
<td>minduration<code>[LEVEL][TYPE]</code></td>
<td>minutes</td>
<td>Shortest duration of any <code>[LEVEL][TYPE]</code>sleep episode. <code>[LEVEL]</code>is one of <code>[SLEEP_LEVELS]</code> (e.g. awake-classic or rem-stages) and <code>[TYPE]</code> is one of <code>[SLEEP_TYPES]</code> (e.g. main). Both <code>[LEVEL]</code> and <code>[TYPE]</code>can also be <code>all</code> when <code>LEVELS_AND_TYPES_COMBINING_ALL</code> is True, which ignores the levels and groups by sleep types.</td>
</tr>
<tr>
<td>avgduration<code>[LEVEL][TYPE]</code></td>
<td>minutes</td>
<td>Average duration of all <code>[LEVEL][TYPE]</code>sleep episodes. <code>[LEVEL]</code>is one of <code>[SLEEP_LEVELS]</code> (e.g. awake-classic or rem-stages) and <code>[TYPE]</code> is one of <code>[SLEEP_TYPES]</code> (e.g. main). Both <code>[LEVEL]</code> and <code>[TYPE]</code>can also be <code>all</code> when <code>LEVELS_AND_TYPES_COMBINING_ALL</code> is True, which ignores the levels and groups by sleep types.</td>
</tr>
<tr>
<td>medianduration<code>[LEVEL][TYPE]</code></td>
<td>minutes</td>
<td>Median duration of all <code>[LEVEL][TYPE]</code>sleep episodes. <code>[LEVEL]</code>is one of <code>[SLEEP_LEVELS]</code> (e.g. awake-classic or rem-stages) and <code>[TYPE]</code> is one of <code>[SLEEP_TYPES]</code> (e.g. main). Both <code>[LEVEL]</code> and <code>[TYPE]</code>can also be <code>all</code> when <code>LEVELS_AND_TYPES_COMBINING_ALL</code> is True, which ignores the levels and groups by sleep types.</td>
</tr>
<tr>
<td>stdduration<code>[LEVEL][TYPE]</code></td>
<td>minutes</td>
<td>Standard deviation duration of all <code>[LEVEL][TYPE]</code>sleep episodes. <code>[LEVEL]</code>is one of <code>[SLEEP_LEVELS]</code> (e.g. awake-classic or rem-stages) and <code>[TYPE]</code> is one of <code>[SLEEP_TYPES]</code> (e.g. main). Both <code>[LEVEL]</code> and <code>[TYPE]</code>can also be <code>all</code> when <code>LEVELS_AND_TYPES_COMBINING_ALL</code> is True, which ignores the levels and groups by sleep types.</td>
</tr>
</tbody>
</table>
<p>Features description for <code>[FITBIT_STEPS_INTRADAY][PROVIDERS][RAPIDS]</code> RATIOS <code>[ACROSS_LEVELS]</code>:</p>
<td>Ratio between the <strong>count</strong> of episodes of a single sleep <code>[LEVEL]</code> and the <strong>count</strong> of all episodes of all levels during both <code>main</code> and <code>nap</code> sleep types. This answers the question: what percentage of all <code>wake</code>, <code>deep</code>, <code>light</code>, and <code>rem</code> episodes were <code>rem</code>? (e.g., <spanclass="arithmatex">\(countepisode[remstages][all] / countepisode[all][all]\)</span>)</td>
</tr>
<tr>
<td>ratioduration<code>[LEVEL]</code></td>
<td>-</td>
<td>Ratio between the <strong>duration</strong> of episodes of a single sleep <code>[LEVEL]</code> and the <strong>duration</strong> of all episodes of all levels during both <code>main</code> and <code>nap</code> sleep types. This answers the question: what percentage of all <code>wake</code>, <code>deep</code>, <code>light</code>, and <code>rem</code> time was <code>rem</code>? (e.g., <spanclass="arithmatex">\(sumduration[remstages][all] / sumduration[all][all]\)</span>)</td>
</tr>
</tbody>
</table>
<p>Features description for <code>[FITBIT_STEPS_INTRADAY][PROVIDERS][RAPIDS]</code> RATIOS <code>[ACROSS_TYPES]</code>:</p>
<td>Ratio between the <strong>count</strong> of all <code>main</code> episodes (independently of the levels inside) divided by the <strong>count</strong> of all <code>main</code> and <code>nap</code> episodes. This answers the question: what percentage of all sleep episodes (<code>main</code> and <code>nap</code>) were <code>main</code>? We do not provide the ratio for <code>nap</code> because is complementary. (<spanclass="arithmatex">\(countepisode[all][main] / countepisode[all][all]\)</span>)</td>
</tr>
<tr>
<td>ratiodurationmain</td>
<td>-</td>
<td>Ratio between the <strong>duration</strong> of all <code>main</code> episodes (independently of the levels inside) divided by the <strong>duration</strong> of all <code>main</code> and <code>nap</code> episodes. This answers the question: what percentage of all sleep time (<code>main</code> and <code>nap</code>) was <code>main</code>? We do not provide the ratio for <code>nap</code> because is complementary. (<spanclass="arithmatex">\(sumduration[all][main] / sumduration[all][all]\)</span>)</td>
</tr>
</tbody>
</table>
<p>Features description for <code>[FITBIT_STEPS_INTRADAY][PROVIDERS][RAPIDS]</code> RATIOS <code>[WITHIN_LEVELS]</code>:</p>
<td>Ratio between the <strong>count</strong> of episodes of a single sleep <code>[LEVEL]</code> during <code>main</code> sleep divided by the <strong>count</strong> of episodes of a single sleep <code>[LEVEL]</code> during <code>main</code><strong>and</strong><code>nap</code>. This answers the question: are <code>rem</code> episodes more frequent during <code>main</code> than <code>nap</code> sleep? We do not provide the ratio for <code>nap</code> because is complementary. (<spanclass="arithmatex">\(countepisode[remstages][main] / countepisode[remstages][all]\)</span>)</td>
<td>Ratio between the <strong>duration</strong> of episodes of a single sleep <code>[LEVEL]</code> during <code>main</code> sleep divided by the <strong>duration</strong> of episodes of a single sleep <code>[LEVEL]</code> during <code>main</code><strong>and</strong><code>nap</code>. This answers the question: is <code>rem</code> time more frequent during <code>main</code> than <code>nap</code> sleep? We do not provide the ratio for <code>nap</code> because is complementary. (<spanclass="arithmatex">\(countepisode[remstages][main] / countepisode[remstages][all]\)</span>)</td>
</tr>
</tbody>
</table>
<p>Features description for <code>[FITBIT_STEPS_INTRADAY][PROVIDERS][RAPIDS]</code> RATIOS <code>[WITHIN_TYPES]</code>:</p>
<td>Ratio between the <strong>count</strong> of episodes of a single sleep <code>[LEVEL]</code> and the <strong>count</strong> of all episodes of all levels during either <code>main</code> or <code>nap</code> sleep types. This answers the question: what percentage of all <code>wake</code>, <code>deep</code>, <code>light</code>, and <code>rem</code> episodes were <code>rem</code> during <code>main</code>/<code>nap</code> sleep time? (e.g., <spanclass="arithmatex">\(countepisode[remstages][main] / countepisode[all][main]\)</span>)</td>
<td>Ratio between the <strong>duration</strong> of episodes of a single sleep <code>[LEVEL]</code> and the <strong>duration</strong> of all episodes of all levels during either <code>main</code> or <code>nap</code> sleep types. This answers the question: what percentage of all <code>wake</code>, <code>deep</code>, <code>light</code>, and <code>rem</code> time was <code>rem</code> during <code>main</code>/<code>nap</code> sleep time? (e.g., <spanclass="arithmatex">\(sumduration[remstages][main] / sumduration[all][main]\)</span>)</td>
</tr>
</tbody>
</table>
<p>Features description for <code>[FITBIT_STEPS_INTRADAY][PROVIDERS][RAPIDS][ROUTINE]</code>:</p>
<table>
<thead>
<tr>
<th>Feature</th>
<th>Units</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>starttimefirstmainsleep</td>
<td>minutes</td>
<td>Start time (in minutes since <code>REFERENCE_TIME</code>) of the first main sleep episode after <code>INCLUDE_EPISODES_LATER_THAN</code>.</td>
</tr>
<tr>
<td>endtimelastmainsleep</td>
<td>minutes</td>
<td>End time (in minutes since <code>REFERENCE_TIME</code>) of the last main sleep episode after <code>INCLUDE_EPISODES_LATER_THAN</code>.</td>
</tr>
<tr>
<td>starttimefirstnap</td>
<td>minutes</td>
<td>Start time (in minutes since <code>REFERENCE_TIME</code>) of the first nap episode after <code>INCLUDE_EPISODES_LATER_THAN</code>.</td>
</tr>
<tr>
<td>endtimelastnap</td>
<td>minutes</td>
<td>End time (in minutes since <code>REFERENCE_TIME</code>) of the last nap episode after <code>INCLUDE_EPISODES_LATER_THAN</code>.</td>
<li>Deleting values from <code>[SLEEP_LEVELS]</code> or <code>[SLEEP_TYPES]</code> will only change the features you receive from <code>[LEVELS_AND_TYPES]</code>. For example if <code>STAGES</code> only contains <code>[rem, light]</code> you will not receive <code>countepisode[wake|deep][TYPE]</code> or sum, max, min, avg, median, or std <code>duration</code>. These values will not influence <code>RATIOS</code> or <code>ROUTINE</code> features.</li>
<li>Any <code>[LEVEL]</code> grouping is done within the elements of each class <code>CLASSIC</code>, <code>STAGES</code>, and <code>UNIFIED</code>. That is, we never combine <code>CLASSIC</code> or <code>STAGES</code> types to compute features when <code>LEVELS_AND_TYPES_COMBINING_ALL</code> is True or when computing <code>RATIOS</code>.</li>
<td>Set to <code>True</code> to extract <code>FITBIT_SLEEP_INTRADAY</code> features from the <code>PRICE</code> provider</td>
</tr>
<tr>
<td><code>[FEATURES]</code></td>
<td>Features to be computed from sleep intraday data, see table below</td>
</tr>
<tr>
<td><code>[SLEEP_LEVELS]</code></td>
<td>Fitbit’s sleep API Version 1 only provides <code>CLASSIC</code> records. However, Version 1.2 provides 2 types of records: <code>CLASSIC</code> and <code>STAGES</code>. <code>STAGES</code> is only available in devices with a heart rate sensor and even those devices will fail to report it if the battery is low or the device is not tight enough. While <code>CLASSIC</code> contains 3 sleep levels (<code>awake</code>, <code>restless</code>, and <code>asleep</code>), <code>STAGES</code> contains 4 sleep levels (<code>wake</code>, <code>deep</code>, <code>light</code>, <code>rem</code>). To make it consistent, RAPIDS grouped them into 2 <code>UNIFIED</code> sleep levels: <code>awake</code> (<code>CLASSIC</code>: <code>awake</code> and <code>restless</code>; <code>STAGES</code>: <code>wake</code>) and <code>asleep</code> (<code>CLASSIC</code>: <code>asleep</code>; <code>STAGES</code>: <code>deep</code>, <code>light</code>, and <code>rem</code>).</td>
</tr>
<tr>
<td><code>[DAY_TYPE]</code></td>
<td>The features of this provider can be computed using daily averages/standard deviations that were extracted on <code>WEEKEND</code> days only, <code>WEEK</code> days only, or <code>ALL</code> days</td>
</tr>
<tr>
<td><code>[GROUP_EPISODES_WITHIN]</code></td>
<td>This parameter contains 2 values: <code>[START_TIME]</code> and <code>[LENGTH]</code>. Only <code>main</code> sleep episodes that intersect or contain the period between [<code>START_TIME</code>, <code>START_TIME</code> + <code>LENGTH</code>] are taken into account to compute the features described below. Both <code>[START_TIME]</code> and <code>[LENGTH]</code> are in minutes. <code>[START_TIME]</code> is a number ranging from 0 (midnight) to 1439 (23:59) which denotes the number of minutes after midnight. <code>[LENGTH]</code> is a number smaller than 1440 (24 hours).</td>
</tr>
</tbody>
</table>
<p>Features description for <code>[FITBIT_STEPS_INTRADAY][PROVIDERS][PRICE]</code>:</p>
<td>Average duration of daily <code>LEVEL</code> sleep episodes. You can include daily average that were computed on weekend days, week days or both depending on the value of the <code>DAY_TYPE</code> flag.</td>
<td>Average ratio between daily <code>LEVEL</code> time and in-bed time inferred from <code>main</code> sleep episodes. <code>LEVEL</code> is one of <code>SLEEP_LEVELS</code> (e.g. awake-classic or rem-stages). In-bed time is the total duration of all <code>main</code> sleep episodes for each day. You can include daily ratios that were computed on weekend days, week days or both depending on the value of the <code>DAY_TYPE</code> flag.</td>
<td>Average start time of the first <code>main</code> sleep episode of each day in a time segment. You can include daily start times from episodes detected on weekend days, week days or both depending on the value of the <code>DAY_TYPE</code> flag.</td>
<td>Average end time of the last <code>main</code> sleep episode of each day in a time segment. You can include daily end times from episodes detected on weekend days, week days or both depending on the value of the <code>DAY_TYPE</code> flag.</td>
<td>Average mid time between the start of the first <code>main</code> sleep episode and the end of the last <code>main</code> sleep episode of each day in a time segment. You can include episodes detected on weekend days, week days or both depending on the value of the <code>DAY_TYPE</code> flag.</td>
<td>Standard deviation of start time of the first <code>main</code> sleep episode of each day in a time segment. You can include daily start times from episodes detected on weekend days, week days or both depending on the value of the <code>DAY_TYPE</code> flag.</td>
<td>Standard deviation of end time of the last <code>main</code> sleep episode of each day in a time segment. You can include daily end times from episodes detected on weekend days, week days or both depending on the value of the <code>DAY_TYPE</code> flag.</td>
<td>Standard deviation of mid time between the start of the first <code>main</code> sleep episode and the end of the last <code>main</code> sleep episode of each day in a time segment. You can include episodes detected on weekend days, week days or both depending on the value of the <code>DAY_TYPE</code> flag.</td>
<td>Same as <code>avgstarttimeofepisodemain[DAY_TYPE]</code> but the average is computed over the squared differences of each pair of consecutive start times.</td>
</tr>
<tr>
<td>meanssdendtimeofepisodemain</td>
<td>minutes squared</td>
<td>Same as <code>avgendtimeofepisodemain[DAY_TYPE]</code> but the average is computed over the squared differences of each pair of consecutive end times.</td>
</tr>
<tr>
<td>meanssdmidpointofepisodemain</td>
<td>minutes squared</td>
<td>Same as <code>avgmidpointofepisodemain[DAY_TYPE]</code> but the average is computed over the squared differences of each pair of consecutive mid times.</td>
</tr>
<tr>
<td>medianssdstarttimeofepisodemain</td>
<td>minutes squared</td>
<td>Same as <code>avgstarttimeofepisodemain[DAY_TYPE]</code> but the median is computed over the squared differences of each pair of consecutive start times.</td>
</tr>
<tr>
<td>medianssdendtimeofepisodemain</td>
<td>minutes squared</td>
<td>Same as <code>avgendtimeofepisodemain[DAY_TYPE]</code> but the median is computed over the squared differences of each pair of consecutive end times.</td>
</tr>
<tr>
<td>medianssdmidpointofepisodemain</td>
<td>minutes squared</td>
<td>Same as <code>avgmidpointofepisodemain[DAY_TYPE]</code> but the median is computed over the squared differences of each pair of consecutive mid times.</td>
<li>These features are based on descriptive statistics computed across daily values (start/end/mid times of sleep episodes). This is the reason why they are only available on time segments that are longer than 24 hours (we need at least 1 day to get the average).</li>
<li>Even though Fitbit provides 2 types of sleep episodes (<code>main</code> and <code>nap</code>), only <code>main</code> sleep episodes are considered.</li>
<li>
<p>How do we assign sleep episodes to specific dates?</p>
<p><code>START_TIME</code> and <code>LENGTH</code> control the dates that sleep episodes belong to. For a pair of <code>[START_TIME]</code> and <code>[LENGTH]</code>, sleep episodes (blue boxes) can only be placed at the following places:</p>
<figcaption>Relationship between sleep episodes and the given times<code>([START_TIME], [LENGTH])</code></figcaption>
</figure></p>
<ul>
<li>
<p>If the end time of a sleep episode is before <code>[START_TIME]</code>, it will belong to the day before its start date (e.g. sleep episode #1).</p>
</li>
<li>
<p>if (1) the start time or the end time of a sleep episode are between (overlap) <code>[START_TIME]</code> and <code>[START_TIME] + [LENGTH]</code> or (2) the start time is before <code>[START_TIME]</code> and the end time is after <code>[START_TIME] + [LENGTH]</code>, it will belong to its start date (e.g. sleep episode #2, #3, #4, #5).</p>
</li>
<li>
<p>If the start time of a sleep episode is after <code>START_TIME] + [LENGTH]</code>, it will belong to the day after its start date (e.g. sleep episode #6).</p>
</li>
</ul>
<p>Only <code>main</code> sleep episodes that intersect or contain the period between <code>[START_TIME]</code> and <code>[START_TIME] + [LENGTH]</code> will be included in the feature computation. If we process the following <code>main</code> sleep episodes: </p>
<p><code>[INCLUDE_EPISODES_INTERSECTING][LENGTH]</code> = 720 (tomorrow’s 10:00, or 22:00 + 12 hours)</p>
</li>
</ul>
<p>Only sleep episodes 2, 3,and 5 would be considered.</p>
</li>
<li>
<p>Time related features represent the number of minutes between the start/end/midpoint of sleep episodes and the assigned day’s midnight.</p>
</li>
<li>
<p>All <code>main</code> sleep episodes are chunked within the requested <ahref="../../setup/configuration/#time-segments">time segments</a> which need to be at least 24 hours or more long (1, 2, 3, 7 days, etc.). Then, daily features will be extracted and averaged across the length of the time segment, for example:</p>
<p>The daily features extracted on 2021-02-01 will be:</p>
<ul>
<li>
<p>starttimeofepisodemain (bedtime) is <code>21 * 60</code> (episode 2 start time 2021-02-01 21:00)</p>
</li>
<li>
<p>endtimeofepisodemain (wake time) is <code>32 * 60</code>(episode 3 end time 2021-02-02 08:00 + 24)</p>
<scriptsrc="../../assets/javascripts/bundle.d4cf0930.min.js"></script><scriptid="__lang"type="application/json">{"clipboard.copy":"Copy to clipboard","clipboard.copied":"Copied to clipboard","search.config.lang":"en","search.config.pipeline":"trimmer, stopWordFilter","search.config.separator":"[\\s\\-]+","search.placeholder":"Search","search.result.placeholder":"Type to start searching","search.result.none":"No matching documents","search.result.one":"1 matching document","search.result.other":"# matching documents","search.result.more.one":"1 more on this page","search.result.more.other":"# more on this page","search.result.term.missing":"Missing"}</script>