<buttonclass="md-header-nav__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-nav__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">
<p>Every time you see <code>config["KEY"]</code> or <code>[KEY]</code> in these docs we are referring to the corresponding key in the <code>config.yaml</code> file.</p>
<p>If your study only happened in a single time zone, select the appropriate code form this <ahref="https://en.wikipedia.org/wiki/List_of_tz_database_time_zones">list</a> and change the following config key. Double check your timezone code pick, for example US Eastern Time is <code>America/New_York</code> not <code>EST</code></p>
<p>Participant files link together multiple devices (smartphones and wearables) to specific participants and identify them throughout RAPIDS. You can create these files manually or <ahref="#automatic-creation-of-participant-files">automatically</a>. Participant files are stored in <code>data/external/participant_files/pxx.yaml</code> and follow a unified <ahref="#structure-of-participants-files">structure</a>.</p>
<divclass="admonition note">
<pclass="admonition-title">Note</p>
<p>The list <code>PIDS</code> in <code>config.yaml</code> needs to have the participant file names of the people you want to process. For example, if you created <code>p01.yaml</code>, <code>p02.yaml</code> and <code>p03.yaml</code> files in <code>/data/external/participant_files/</code>, then <code>PIDS</code> should be:
<p>Attribute <em>values</em> of the <code>[PHONE]</code> and <code>[FITBIT]</code> sections in every participant file are optional which allows you to analyze data from participants that only carried smartphones, only Fitbit devices, or both.</p>
</div>
<detailsclass="hint"><summary>Optional: Migrating participants files with the old format</summary><p>If you were using the pre-release version of RAPIDS with participant files in plain text (as opposed to yaml), you can run the following command and your old files will be converted into yaml files stored in <code>data/external/participant_files/</code></p>
<h3id="structure-of-participants-files">Structure of participants files<aclass="headerlink"href="#structure-of-participants-files"title="Permanent link">¶</a></h3>
<divclass="admonition example">
<pclass="admonition-title">Example of the structure of a participant file</p>
<p>In this example, the participant used an android phone, an ios phone, and a fitbit device throughout the study between Apr 23<sup>rd</sup> 2020 and Oct 28<sup>th</sup> 2020</p>
<td>An array of the strings that uniquely identify each smartphone, you can have more than one for when participants changed phones in the middle of the study, in this case, data from all their devices will be joined and relabeled with the last 1 on this list.</td>
</tr>
<tr>
<td><code>[PLATFORMS]</code></td>
<td>An array that specifies the OS of each smartphone in <code>[DEVICE_IDS]</code> , use a combination of <code>android</code> or <code>ios</code> (we support participants that changed platforms in the middle of your study!). If you have an <code>aware_device</code> table in your database you can set <code>[PLATFORMS]: [multiple]</code> and RAPIDS will infer them automatically.</td>
</tr>
<tr>
<td><code>[LABEL]</code></td>
<td>A string that is used in reports and visualizations.</td>
</tr>
<tr>
<td><code>[START_DATE]</code></td>
<td>A string with format <code>YYY-MM-DD</code> . Only data collected <em>after</em> this date will be included in the analysis</td>
</tr>
<tr>
<td><code>[END_DATE]</code></td>
<td>A string with format <code>YYY-MM-DD</code> . Only data collected <em>before</em> this date will be included in the analysis</td>
<td>An array of the strings that uniquely identify each Fitbit, you can have more than one in case the participant changed devices in the middle of the study, in this case, data from all devices will be joined and relabeled with the last <code>device_id</code> on this list.</td>
</tr>
<tr>
<td><code>[LABEL]</code></td>
<td>A string that is used in reports and visualizations.</td>
</tr>
<tr>
<td><code>[START_DATE]</code></td>
<td>A string with format <code>YYY-MM-DD</code> . Only data collected <em>after</em> this date will be included in the analysis</td>
</tr>
<tr>
<td><code>[END_DATE]</code></td>
<td>A string with format <code>YYY-MM-DD</code> . Only data collected <em>before</em> this date will be included in the analysis</td>
</tr>
</tbody>
</table>
<h3id="automatic-creation-of-participant-files">Automatic creation of participant files<aclass="headerlink"href="#automatic-creation-of-participant-files"title="Permanent link">¶</a></h3>
<p>You have two options a) use the <code>aware_device</code> table in your database or b) use a CSV file. In either case, in your <code>config.yaml</code>, set <code>[PHONE_SECTION][ADD]</code> or <code>[FITBIT_SECTION][ADD]</code> to <code>TRUE</code> depending on what devices you used in your study. Set <code>[DEVICE_ID_COLUMN]</code> to the name of the column that uniquely identifies each device and include any device ids you want to ignore in <code>[IGNORED_DEVICE_IDS]</code>.</p>
Your CSV file (<code>[SOURCE][CSV_FILE_PATH]</code>) should have the following columns but you can omit any values you don’t have on each column:</p>
<table>
<thead>
<tr>
<th>Column</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>phone device id</td>
<td>The name of this column has to match <code>[PHONE_SECTION][DEVICE_ID_COLUMN]</code>. Separate multiple ids with <code>;</code></td>
</tr>
<tr>
<td>fitbit device id</td>
<td>The name of this column has to match <code>[FITBIT_SECTION][DEVICE_ID_COLUMN]</code>. Separate multiple ids with <code>;</code></td>
</tr>
<tr>
<td>pid</td>
<td>Unique identifiers with the format pXXX (your participant files will be named with this string</td>
</tr>
<tr>
<td>platform</td>
<td>Use <code>android</code>, <code>ios</code> or <code>multiple</code> as explained above, separate values with <code>;</code></td>
</tr>
<tr>
<td>label</td>
<td>A human readable string that is used in reports and visualizations.</td>
</tr>
<tr>
<td>start_date</td>
<td>A string with format <code>YYY-MM-DD</code>.</td>
</tr>
<tr>
<td>end_date</td>
<td>A string with format <code>YYY-MM-DD</code>.</td>
<p>Day segments (or epochs) are the time windows on which you want to extract behavioral features. For example, you might want to process data on every day, every morning, or only during weekends. RAPIDS offers three categories of day segments that are flexible enough to cover most use cases: <strong>frequency</strong> (short time windows every day), <strong>periodic</strong> (arbitrary time windows on any day), and <strong>event</strong> (arbitrary time windows around events of interest). See also our <ahref="#segment-examples">examples</a>.</p>
<p>These segments are computed on every day and all have the same duration (for example 30 minutes). Set the following keys in your <code>config.yaml</code></p>
<p>These segments can be computed every day, or on specific days of the week, month, quarter, and year. Their minimum duration is 1 minute but they can be as long as you want. Set the following keys in your <code>config.yaml</code>.</p>
<spanclass="nt">INCLUDE_PAST_PERIODIC_SEGMENTS</span><spanclass="p">:</span><spanclass="l l-Scalar l-Scalar-Plain">FALSE</span><spanclass="c1"># or TRUE</span>
</code></pre></div>
<p>If <code>[INCLUDE_PAST_PERIODIC_SEGMENTS]</code> is set to <code>TRUE</code>, RAPIDS will consider instances of your segments back enough in the past as to include the first row of data of each participant. For example, if the first row of data from a participant happened on Saturday March 7<sup>th</sup> 2020 and the requested segment duration is 7 days starting on every Sunday, the first segment to be considered would start on Sunday March 1<sup>st</sup> if <code>[INCLUDE_PAST_PERIODIC_SEGMENTS]</code> is <code>TRUE</code> or on Sunday March 8<sup>th</sup> if <code>FALSE</code>.</p>
<p>The file pointed by <code>[DAY_SEGMENTS][FILE]</code> should have the following format and can have multiple rows.</p>
<table>
<thead>
<tr>
<th>Column</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>label</td>
<td>A string that is used as a prefix in the name of your day segments. It has to be <strong>unique</strong> between rows</td>
</tr>
<tr>
<td>start_time</td>
<td>A string with format <code>HH:MM:SS</code> representing the starting time of this segment on any day</td>
</tr>
<tr>
<td>length</td>
<td>A string representing the length of this segment.It can have one or more of the following strings <strong><code>XXD XXH XXM XXS</code></strong> to represent days, hours, minutes and seconds. For example <code>7D 23H 59M 59S</code></td>
</tr>
<tr>
<td>repeats_on</td>
<td>One of the follow options <code>every_day</code>, <code>wday</code>, <code>qday</code>, <code>mday</code>, and <code>yday</code>. The last four represent a week, quarter, month and year day</td>
</tr>
<tr>
<td>repeats_value</td>
<td>An integer complementing <code>repeats_on</code>. If you set <code>repeats_on</code> to <code>every_day</code> set this to <code>0</code>, otherwise <code>1-7</code> represent a <code>wday</code> starting from Mondays, <code>1-31</code> represent a <code>mday</code>, <code>1-91</code> represent a <code>qday</code>, and <code>1-366</code> represent a <code>yday</code></td>
<p>This configuration will create five segments instances (<code>daily</code>, <code>morning</code>, <code>afternoon</code>, <code>evening</code>, <code>night</code>) on any given day (<code>every_day</code> set to 0). The <code>daily</code> segment will start at midnight and will last <code>23:59:59</code>, the other four segments will start at 6am, 12pm, 6pm, and 12am respectively and last for <code>05:59:59</code>. </p>
<p>These segments can be computed before or after an event of interest (defined as any UNIX timestamp). Their minimum duration is 1 minute but they can be as long as you want. The start of each segment can be shifted backwards or forwards from the specified timestamp. Set the following keys in your <code>config.yaml</code>.</p>
<spanclass="nt">INCLUDE_PAST_PERIODIC_SEGMENTS</span><spanclass="p">:</span><spanclass="l l-Scalar l-Scalar-Plain">FALSE</span><spanclass="c1"># or TRUE</span>
</code></pre></div>
<p>The file pointed by <code>[DAY_SEGMENTS][FILE]</code> should have the following format and can have multiple rows.</p>
<td>A string that is used as a prefix in the name of your day segments. If labels are unique, every segment is independent; if two or more segments have the same label, their data will be grouped when computing features like the <code>most frequent contact</code> for calls (the most frequent contact will be computed across all these segments)</td>
<td>A UNIX timestamp that represents the moment an event of interest happened (clinical relapse, survey, readmission, etc.). The corresponding day segment will be computed around this moment using <code>length</code>, <code>shift</code>, and <code>shift_direction</code></td>
<td>A string representing the length of this segment. It can have one or more of the following keys <code>XXD XXH XXM XXS</code> to represent a number of days, hours, minutes, and seconds. For example <code>7D 23H 59M 59S</code></td>
<td>A string representing the time shift from <code>event_timestamp</code>. It can have one or more of the following keys <code>XXD XXH XXM XXS</code> to represent a number of days, hours, minutes and seconds. For example <code>7D 23H 59M 59S</code>. Use this value to change the start of a segment with respect to its <code>event_timestamp</code>. For example, set this variable to <code>1H</code> to create a segment that starts 1 hour from an event of interest (<code>shift_direction</code> determines if it’s before or after).</td>
<td>An integer representing whether the <code>shift</code> is before (<code>-1</code>) or after (<code>1</code>) an <code>event_timestamp</code></td>
</tr>
<tr>
<td>device_id</td>
<td>The device id (smartphone or fitbit) to whom this segment belongs to. You have to create a line in the event segment file for each event of a participant that you want to analyse</td>
<p>This example will create eight segments for a single participant (<code>a748ee1a...</code>), five independent <code>stressX</code> segments with various lengths (1,4,3,7, and 9 hours). Segments <code>stress1</code>, <code>stress3</code>, and <code>stress5</code> are shifted forwards by 5 minutes and <code>stress2</code> and <code>stress4</code> are shifted backwards by 4 hours (that is, if the <code>stress4</code> event happened on March 15<sup>th</sup> at 1pm EST (<code>1584291600000</code>), the day segment will start on that day at 9am and end at 4pm). </p>
<p>The three <code>mood</code> segments are 1 hour, 1 day and 7 days long and have no shift. In addition, these <code>mood</code> segments are grouped together, meaning that although RAPIDS will compute features on each one of them, some necessary information to compute a few of such features will be extracted from all three segments, for example the phone contact that called a participant the most or the location clusters visited by a participant.</p>
<h2id="device-data-source-configuration">Device Data Source Configuration<aclass="headerlink"href="#device-data-source-configuration"title="Permanent link">¶</a></h2>
<p>You might need to modify the following config keys in your <code>config.yaml</code> depending on what devices your participants used and where you are storing your data. You can ignore <code>[PHONE_DATA_CONFIGURATION]</code> or <code>[FITBIT_DATA_CONFIGURATION]</code> if you are not working with either devices.</p>
<spanclass="nt">TYPE</span><spanclass="p">:</span><spanclass="l l-Scalar l-Scalar-Plain">SINGLE</span><spanclass="c1"># SINGLE (MULTIPLE support coming soon)</span>
<spanclass="nt">TYPE</span><spanclass="p">:</span><spanclass="l l-Scalar l-Scalar-Plain">DATABASE</span><spanclass="c1"># DATABASE or FILES (set each [FITBIT_SENSOR][TABLE] attribute with a table name or a file path accordingly)</span>
<spanclass="nt">COLUMN_FORMAT</span><spanclass="p">:</span><spanclass="l l-Scalar l-Scalar-Plain">JSON</span><spanclass="c1"># JSON or PLAIN_TEXT</span>
<spanclass="nt">TYPE</span><spanclass="p">:</span><spanclass="l l-Scalar l-Scalar-Plain">SINGLE</span><spanclass="c1"># Fitbit devices don't support time zones so we read this data in the timezone indicated by VALUE </span>
<td><code>DATABASE</code> or <code>FILES</code> (set each <code>[FITBIT_SENSOR]</code><code>[TABLE]</code> attribute accordingly with a table name or a file path)</td>
<td><code>JSON</code> or <code>PLAIN_TEXT</code>. Column format of the source data. If you pulled your data directly from the Fitbit API the column containing the sensor data will be in <code>JSON</code> format</td>
<td><code>*database_group</code> points to the value defined before in <ahref="#database-credentials">Database credentials</a>. Only used if <code>[TYPE]</code> is <code>DATABASE</code> .</td>
<h2id="sensor-and-features-to-process">Sensor and Features to Process<aclass="headerlink"href="#sensor-and-features-to-process"title="Permanent link">¶</a></h2>
<p>Finally, you need to modify the <code>config.yaml</code> section of the sensors you want to extract behavioral features from. All sensors follow the same naming nomenclature (<code>DEVICE_SENSOR</code>) and parameter structure which we explain in the <ahref="../../features/feature-introduction/">Behavioral Features Introduction</a>. </p>
<divclass="admonition done">
<pclass="admonition-title">Done</p>
<p>Head over to <ahref="../execution/">Execution</a> to learn how to execute RAPIDS.</p>
<scriptsrc="../../assets/javascripts/bundle.d371fdb2.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>