rapids/1.1/features/add-new-features/index.html

2205 lines
68 KiB
HTML

<!doctype html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="canonical" href="https://www.rapids.science/1.1/features/add-new-features/">
<link rel="icon" href="../../img/logo.png">
<meta name="generator" content="mkdocs-1.1.2, mkdocs-material-7.1.6+insiders-2.9.1">
<title>Add New Features - RAPIDS</title>
<link rel="stylesheet" href="../../assets/stylesheets/main.92048cb8.min.css">
<link rel="stylesheet" href="../../assets/stylesheets/palette.73e53a79.min.css">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700%7CRoboto+Mono&display=fallback">
<style>:root{--md-text-font-family:"Roboto";--md-code-font-family:"Roboto Mono"}</style>
<link rel="stylesheet" href="../../stylesheets/extra.css">
</head>
<body dir="ltr" data-md-color-scheme="default" data-md-color-primary="blue" data-md-color-accent="blue">
<script>function __scope(t,e="../.."){return new URL(e,location).pathname+"."+t}function __get(t,e=localStorage,n){return JSON.parse(e.getItem(__scope(t,n)))}function __set(t,e,n=localStorage,o){try{n.setItem(__scope(t,o),JSON.stringify(e))}catch(t){}}</script>
<script>var palette=__get("__palette");if(palette&&"object"==typeof palette.color)for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)</script>
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
<label class="md-overlay" for="__drawer"></label>
<div data-md-component="skip">
<a href="#add-new-features" class="md-skip">
Skip to content
</a>
</div>
<div data-md-component="announce">
</div>
<div data-md-component="outdated" hidden>
<aside class="md-banner md-banner--warning">
<div class="md-banner__inner md-grid md-typeset">
You're not viewing the latest stable version of RAPIDS.
<a href="https://www.rapids.science/latest/">
<strong> Click here to go to latest. </strong>
</a>
</div>
<script>var el=document.querySelector("[data-md-component=outdated]"),outdated=__get("__outdated",sessionStorage);!0===outdated&&el&&(el.hidden=!1)</script>
</aside>
</div>
<header class="md-header" data-md-component="header">
<nav class="md-header__inner md-grid" aria-label="Header">
<a href="../.." title="RAPIDS" class="md-header__button md-logo" aria-label="RAPIDS" data-md-component="logo">
<img src="../../img/logo.png" alt="logo">
</a>
<label class="md-header__button md-icon" for="__drawer">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2z"/></svg>
</label>
<div class="md-header__title" data-md-component="header-title">
<div class="md-header__ellipsis">
<div class="md-header__topic">
<span class="md-ellipsis">
RAPIDS
</span>
</div>
<div class="md-header__topic" data-md-component="header-topic">
<span class="md-ellipsis">
Add New Features
</span>
</div>
</div>
</div>
<form class="md-header__option" data-md-component="palette">
<input class="md-option" data-md-color-media="" data-md-color-scheme="default" data-md-color-primary="blue" data-md-color-accent="blue" type="radio" name="__palette" id="__palette_1">
<label class="md-header__button md-icon" title="Switch to light mode" for="__palette_2" hidden>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M17 7H7a5 5 0 0 0-5 5 5 5 0 0 0 5 5h10a5 5 0 0 0 5-5 5 5 0 0 0-5-5m0 8a3 3 0 0 1-3-3 3 3 0 0 1 3-3 3 3 0 0 1 3 3 3 3 0 0 1-3 3z"/></svg>
</label>
<input class="md-option" data-md-color-media="" data-md-color-scheme="slate" data-md-color-primary="blue" data-md-color-accent="blue" type="radio" name="__palette" id="__palette_2">
<label class="md-header__button md-icon" title="Switch to dark mode" for="__palette_1" hidden>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M7 10a2 2 0 0 1 2 2 2 2 0 0 1-2 2 2 2 0 0 1-2-2 2 2 0 0 1 2-2m10-3a5 5 0 0 1 5 5 5 5 0 0 1-5 5H7a5 5 0 0 1-5-5 5 5 0 0 1 5-5h10M7 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3h10a3 3 0 0 0 3-3 3 3 0 0 0-3-3H7z"/></svg>
</label>
</form>
<label class="md-header__button md-icon" for="__search">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5z"/></svg>
</label>
<div class="md-search" data-md-component="search" role="dialog">
<label class="md-search__overlay" for="__search"></label>
<div class="md-search__inner" role="search">
<form class="md-search__form" name="search">
<input type="text" class="md-search__input" name="query" aria-label="Search" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required>
<label class="md-search__icon md-icon" for="__search">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5z"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12z"/></svg>
</label>
<nav class="md-search__options" aria-label="Search">
<button type="reset" class="md-search__icon md-icon" aria-label="Clear" tabindex="-1">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"/></svg>
</button>
</nav>
<div class="md-search__suggest" data-md-component="search-suggest"></div>
</form>
<div class="md-search__output">
<div class="md-search__scrollwrap" data-md-scrollfix>
<div class="md-search-result" data-md-component="search-result">
<div class="md-search-result__meta">
Initializing search
</div>
<ol class="md-search-result__list"></ol>
</div>
</div>
</div>
</div>
</div>
<div class="md-header__source">
<a href="https://github.com/carissalow/rapids/" title="Go to repository" class="md-source" data-md-component="source">
<div class="md-source__icon md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81z"/></svg>
</div>
<div class="md-source__repository">
carissalow/rapids
</div>
</a>
</div>
</nav>
</header>
<div class="md-container" data-md-component="container">
<main class="md-main" data-md-component="main">
<div class="md-main__inner md-grid">
<div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--primary" aria-label="Navigation" data-md-level="0">
<label class="md-nav__title" for="__drawer">
<a href="../.." title="RAPIDS" class="md-nav__button md-logo" aria-label="RAPIDS" data-md-component="logo">
<img src="../../img/logo.png" alt="logo">
</a>
RAPIDS
</label>
<div class="md-nav__source">
<a href="https://github.com/carissalow/rapids/" title="Go to repository" class="md-source" data-md-component="source">
<div class="md-source__icon md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81z"/></svg>
</div>
<div class="md-source__repository">
carissalow/rapids
</div>
</a>
</div>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../.." class="md-nav__link">
Home
</a>
</li>
<li class="md-nav__item md-nav__item--section md-nav__item--nested">
<input class="md-nav__toggle md-toggle" data-md-toggle="__nav_2" type="checkbox" id="__nav_2" >
<label class="md-nav__link" for="__nav_2">
Setup
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" aria-label="Setup" data-md-level="1">
<label class="md-nav__title" for="__nav_2">
<span class="md-nav__icon md-icon"></span>
Setup
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../setup/overview/" class="md-nav__link">
Overview
</a>
</li>
<li class="md-nav__item">
<a href="../../workflow-examples/minimal/" class="md-nav__link">
Minimal Example
</a>
</li>
<li class="md-nav__item">
<a href="../../setup/installation/" class="md-nav__link">
Installation
</a>
</li>
<li class="md-nav__item">
<a href="../../setup/configuration/" class="md-nav__link">
Configuration
</a>
</li>
<li class="md-nav__item">
<a href="../../setup/execution/" class="md-nav__link">
Execution
</a>
</li>
<li class="md-nav__item">
<a href="../../citation/" class="md-nav__link">
Citation
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--section md-nav__item--nested">
<input class="md-nav__toggle md-toggle" data-md-toggle="__nav_3" type="checkbox" id="__nav_3" >
<label class="md-nav__link" for="__nav_3">
Data Streams
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" aria-label="Data Streams" data-md-level="1">
<label class="md-nav__title" for="__nav_3">
<span class="md-nav__icon md-icon"></span>
Data Streams
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../datastreams/data-streams-introduction/" class="md-nav__link">
Introduction
</a>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle" data-md-toggle="__nav_3_2" type="checkbox" id="__nav_3_2" >
<label class="md-nav__link" for="__nav_3_2">
Phone
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" aria-label="Phone" data-md-level="2">
<label class="md-nav__title" for="__nav_3_2">
<span class="md-nav__icon md-icon"></span>
Phone
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../datastreams/aware-mysql/" class="md-nav__link">
aware_mysql
</a>
</li>
<li class="md-nav__item">
<a href="../../datastreams/aware-csv/" class="md-nav__link">
aware_csv
</a>
</li>
<li class="md-nav__item">
<a href="../../datastreams/aware-influxdb/" class="md-nav__link">
aware_influxdb (beta)
</a>
</li>
<li class="md-nav__item">
<a href="../../datastreams/mandatory-phone-format/" class="md-nav__link">
Mandatory Phone Format
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle" data-md-toggle="__nav_3_3" type="checkbox" id="__nav_3_3" >
<label class="md-nav__link" for="__nav_3_3">
Fitbit
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" aria-label="Fitbit" data-md-level="2">
<label class="md-nav__title" for="__nav_3_3">
<span class="md-nav__icon md-icon"></span>
Fitbit
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../datastreams/fitbitjson-mysql/" class="md-nav__link">
fitbitjson_mysql
</a>
</li>
<li class="md-nav__item">
<a href="../../datastreams/fitbitjson-csv/" class="md-nav__link">
fitbitjson_csv
</a>
</li>
<li class="md-nav__item">
<a href="../../datastreams/fitbitparsed-mysql/" class="md-nav__link">
fitbitparsed_mysql
</a>
</li>
<li class="md-nav__item">
<a href="../../datastreams/fitbitparsed-csv/" class="md-nav__link">
fitbitparsed_csv
</a>
</li>
<li class="md-nav__item">
<a href="../../datastreams/mandatory-fitbit-format/" class="md-nav__link">
Mandatory Fitbit Format
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle" data-md-toggle="__nav_3_4" type="checkbox" id="__nav_3_4" >
<label class="md-nav__link" for="__nav_3_4">
Empatica
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" aria-label="Empatica" data-md-level="2">
<label class="md-nav__title" for="__nav_3_4">
<span class="md-nav__icon md-icon"></span>
Empatica
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../datastreams/empatica-zip/" class="md-nav__link">
empatica_zip
</a>
</li>
<li class="md-nav__item">
<a href="../../datastreams/mandatory-empatica-format/" class="md-nav__link">
Mandatory Empatica Format
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="../../datastreams/add-new-data-streams/" class="md-nav__link">
Add New Data Streams
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--active md-nav__item--section md-nav__item--nested">
<input class="md-nav__toggle md-toggle" data-md-toggle="__nav_4" type="checkbox" id="__nav_4" checked>
<label class="md-nav__link" for="__nav_4">
Behavioral Features
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" aria-label="Behavioral Features" data-md-level="1">
<label class="md-nav__title" for="__nav_4">
<span class="md-nav__icon md-icon"></span>
Behavioral Features
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../feature-introduction/" class="md-nav__link">
Introduction
</a>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle" data-md-toggle="__nav_4_2" type="checkbox" id="__nav_4_2" >
<label class="md-nav__link" for="__nav_4_2">
Phone
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" aria-label="Phone" data-md-level="2">
<label class="md-nav__title" for="__nav_4_2">
<span class="md-nav__icon md-icon"></span>
Phone
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../phone-accelerometer/" class="md-nav__link">
Phone Accelerometer
</a>
</li>
<li class="md-nav__item">
<a href="../phone-activity-recognition/" class="md-nav__link">
Phone Activity Recognition
</a>
</li>
<li class="md-nav__item">
<a href="../phone-applications-crashes/" class="md-nav__link">
Phone Applications Crashes
</a>
</li>
<li class="md-nav__item">
<a href="../phone-applications-foreground/" class="md-nav__link">
Phone Applications Foreground
</a>
</li>
<li class="md-nav__item">
<a href="../phone-applications-notifications/" class="md-nav__link">
Phone Applications Notifications
</a>
</li>
<li class="md-nav__item">
<a href="../phone-battery/" class="md-nav__link">
Phone Battery
</a>
</li>
<li class="md-nav__item">
<a href="../phone-bluetooth/" class="md-nav__link">
Phone Bluetooth
</a>
</li>
<li class="md-nav__item">
<a href="../phone-calls/" class="md-nav__link">
Phone Calls
</a>
</li>
<li class="md-nav__item">
<a href="../phone-conversation/" class="md-nav__link">
Phone Conversation
</a>
</li>
<li class="md-nav__item">
<a href="../phone-data-yield/" class="md-nav__link">
Phone Data Yield
</a>
</li>
<li class="md-nav__item">
<a href="../phone-keyboard/" class="md-nav__link">
Phone Keyboard
</a>
</li>
<li class="md-nav__item">
<a href="../phone-light/" class="md-nav__link">
Phone Light
</a>
</li>
<li class="md-nav__item">
<a href="../phone-locations/" class="md-nav__link">
Phone Locations
</a>
</li>
<li class="md-nav__item">
<a href="../phone-log/" class="md-nav__link">
Phone Log
</a>
</li>
<li class="md-nav__item">
<a href="../phone-messages/" class="md-nav__link">
Phone Messages
</a>
</li>
<li class="md-nav__item">
<a href="../phone-screen/" class="md-nav__link">
Phone Screen
</a>
</li>
<li class="md-nav__item">
<a href="../phone-wifi-connected/" class="md-nav__link">
Phone WiFI Connected
</a>
</li>
<li class="md-nav__item">
<a href="../phone-wifi-visible/" class="md-nav__link">
Phone WiFI Visible
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle" data-md-toggle="__nav_4_3" type="checkbox" id="__nav_4_3" >
<label class="md-nav__link" for="__nav_4_3">
Fitbit
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" aria-label="Fitbit" data-md-level="2">
<label class="md-nav__title" for="__nav_4_3">
<span class="md-nav__icon md-icon"></span>
Fitbit
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../fitbit-calories-intraday/" class="md-nav__link">
Fitbit Calories Intraday
</a>
</li>
<li class="md-nav__item">
<a href="../fitbit-data-yield/" class="md-nav__link">
Fitbit Data Yield
</a>
</li>
<li class="md-nav__item">
<a href="../fitbit-heartrate-summary/" class="md-nav__link">
Fitbit Heart Rate Summary
</a>
</li>
<li class="md-nav__item">
<a href="../fitbit-heartrate-intraday/" class="md-nav__link">
Fitbit Heart Rate Intraday
</a>
</li>
<li class="md-nav__item">
<a href="../fitbit-sleep-summary/" class="md-nav__link">
Fitbit Sleep Summary
</a>
</li>
<li class="md-nav__item">
<a href="../fitbit-sleep-intraday/" class="md-nav__link">
Fitbit Sleep Intraday
</a>
</li>
<li class="md-nav__item">
<a href="../fitbit-steps-summary/" class="md-nav__link">
Fitbit Steps Summary
</a>
</li>
<li class="md-nav__item">
<a href="../fitbit-steps-intraday/" class="md-nav__link">
Fitbit Steps Intraday
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle" data-md-toggle="__nav_4_4" type="checkbox" id="__nav_4_4" >
<label class="md-nav__link" for="__nav_4_4">
Empatica
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" aria-label="Empatica" data-md-level="2">
<label class="md-nav__title" for="__nav_4_4">
<span class="md-nav__icon md-icon"></span>
Empatica
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../empatica-accelerometer/" class="md-nav__link">
Empatica Accelerometer
</a>
</li>
<li class="md-nav__item">
<a href="../empatica-heartrate/" class="md-nav__link">
Empatica Heart Rate
</a>
</li>
<li class="md-nav__item">
<a href="../empatica-temperature/" class="md-nav__link">
Empatica Temperature
</a>
</li>
<li class="md-nav__item">
<a href="../empatica-electrodermal-activity/" class="md-nav__link">
Empatica Electrodermal Activity
</a>
</li>
<li class="md-nav__item">
<a href="../empatica-blood-volume-pulse/" class="md-nav__link">
Empatica Blood Volume Pulse
</a>
</li>
<li class="md-nav__item">
<a href="../empatica-inter-beat-interval/" class="md-nav__link">
Empatica Inter Beat Interval
</a>
</li>
<li class="md-nav__item">
<a href="../empatica-tags/" class="md-nav__link">
Empatica Tags
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--active">
<input class="md-nav__toggle md-toggle" data-md-toggle="toc" type="checkbox" id="__toc">
<label class="md-nav__link md-nav__link--active" for="__toc">
Add New Features
<span class="md-nav__icon md-icon"></span>
</label>
<a href="./" class="md-nav__link md-nav__link--active">
Add New Features
</a>
<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
Table of contents
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#new-features-for-existing-sensors" class="md-nav__link">
New Features for Existing Sensors
</a>
<nav class="md-nav" aria-label="New Features for Existing Sensors">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#modify-the-configyaml-file" class="md-nav__link">
Modify the config.yaml file
</a>
</li>
<li class="md-nav__item">
<a href="#create-a-feature-provider-script" class="md-nav__link">
Create a feature provider script
</a>
</li>
<li class="md-nav__item">
<a href="#implement-your-feature-extraction-code" class="md-nav__link">
Implement your feature extraction code
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#new-features-for-non-existing-sensors" class="md-nav__link">
New Features for Non-Existing Sensors
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--section md-nav__item--nested">
<input class="md-nav__toggle md-toggle" data-md-toggle="__nav_5" type="checkbox" id="__nav_5" >
<label class="md-nav__link" for="__nav_5">
Visualizations
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" aria-label="Visualizations" data-md-level="1">
<label class="md-nav__title" for="__nav_5">
<span class="md-nav__icon md-icon"></span>
Visualizations
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../visualizations/data-quality-visualizations/" class="md-nav__link">
Data Quality
</a>
</li>
<li class="md-nav__item">
<a href="../../visualizations/feature-visualizations/" class="md-nav__link">
Features
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--section md-nav__item--nested">
<input class="md-nav__toggle md-toggle" data-md-toggle="__nav_6" type="checkbox" id="__nav_6" >
<label class="md-nav__link" for="__nav_6">
Analysis Workflows
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" aria-label="Analysis Workflows" data-md-level="1">
<label class="md-nav__title" for="__nav_6">
<span class="md-nav__icon md-icon"></span>
Analysis Workflows
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../workflow-examples/analysis/" class="md-nav__link">
Complete Example
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--section md-nav__item--nested">
<input class="md-nav__toggle md-toggle" data-md-toggle="__nav_7" type="checkbox" id="__nav_7" >
<label class="md-nav__link" for="__nav_7">
Developers
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" aria-label="Developers" data-md-level="1">
<label class="md-nav__title" for="__nav_7">
<span class="md-nav__icon md-icon"></span>
Developers
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../developers/git-flow/" class="md-nav__link">
Git Flow
</a>
</li>
<li class="md-nav__item">
<a href="../../developers/remote-support/" class="md-nav__link">
Remote Support
</a>
</li>
<li class="md-nav__item">
<a href="../../developers/virtual-environments/" class="md-nav__link">
Virtual Environments
</a>
</li>
<li class="md-nav__item">
<a href="../../developers/documentation/" class="md-nav__link">
Documentation
</a>
</li>
<li class="md-nav__item">
<a href="../../developers/testing/" class="md-nav__link">
Testing
</a>
</li>
<li class="md-nav__item">
<a href="../../developers/test-cases/" class="md-nav__link">
Test cases
</a>
</li>
<li class="md-nav__item">
<a href="../../developers/validation-schema-config/" class="md-nav__link">
Validation schema of config.yaml
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--section md-nav__item--nested">
<input class="md-nav__toggle md-toggle" data-md-toggle="__nav_8" type="checkbox" id="__nav_8" >
<label class="md-nav__link" for="__nav_8">
Others
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" aria-label="Others" data-md-level="1">
<label class="md-nav__title" for="__nav_8">
<span class="md-nav__icon md-icon"></span>
Others
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../migrating-from-old-versions/" class="md-nav__link">
Migrating from an old version
</a>
</li>
<li class="md-nav__item">
<a href="../../code_of_conduct/" class="md-nav__link">
Code of Conduct
</a>
</li>
<li class="md-nav__item">
<a href="../../common-errors/" class="md-nav__link">
Common Errors
</a>
</li>
<li class="md-nav__item">
<a href="../../team/" class="md-nav__link">
Team
</a>
</li>
<li class="md-nav__item">
<a href="../../change-log/" class="md-nav__link">
Change Log
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
Table of contents
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#new-features-for-existing-sensors" class="md-nav__link">
New Features for Existing Sensors
</a>
<nav class="md-nav" aria-label="New Features for Existing Sensors">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#modify-the-configyaml-file" class="md-nav__link">
Modify the config.yaml file
</a>
</li>
<li class="md-nav__item">
<a href="#create-a-feature-provider-script" class="md-nav__link">
Create a feature provider script
</a>
</li>
<li class="md-nav__item">
<a href="#implement-your-feature-extraction-code" class="md-nav__link">
Implement your feature extraction code
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#new-features-for-non-existing-sensors" class="md-nav__link">
New Features for Non-Existing Sensors
</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-content" data-md-component="content">
<article class="md-content__inner md-typeset">
<a href="https://github.com/carissalow/rapids/edit/master/docs/features/add-new-features.md" title="Edit this page" class="md-content__button md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20.71 7.04c.39-.39.39-1.04 0-1.41l-2.34-2.34c-.37-.39-1.02-.39-1.41 0l-1.84 1.83 3.75 3.75M3 17.25V21h3.75L17.81 9.93l-3.75-3.75L3 17.25z"/></svg>
</a>
<h1 id="add-new-features">Add New Features<a class="headerlink" href="#add-new-features" title="Permanent link">&para;</a></h1>
<div class="admonition hint">
<p class="admonition-title">Hint</p>
<ul>
<li>We recommend reading the <a href="../feature-introduction/">Behavioral Features Introduction</a> before reading this page.</li>
<li>You can implement new features in Python or R scripts.</li>
<li>You won&rsquo;t have to deal with time zones, dates, times, data cleaning, or preprocessing. The data that RAPIDS pipes to your feature extraction code are ready to process.</li>
</ul>
</div>
<h2 id="new-features-for-existing-sensors">New Features for Existing Sensors<a class="headerlink" href="#new-features-for-existing-sensors" title="Permanent link">&para;</a></h2>
<p>You can add new features to any existing sensors (see list below) by adding a new provider in three steps:</p>
<ol>
<li><a href="#modify-the-configyaml-file">Modify</a> the <code>config.yaml</code> file </li>
<li><a href="#create-a-feature-provider-script">Create</a> your feature provider script</li>
<li><a href="#implement-your-feature-extraction-code">Implement</a> your features extraction code</li>
</ol>
<p>As a tutorial, we will add a new provider for <code>PHONE_ACCELEROMETER</code> called <code>VEGA</code> that extracts <code>feature1</code>, <code>feature2</code>, <code>feature3</code> with a Python script that requires a parameter from the user called <code>MY_PARAMETER</code>.</p>
<details class="info"><summary>Existing Sensors</summary><p>An existing sensor of any device with a configuration entry in <code>config.yaml</code>:</p>
<p>Smartphone (AWARE)</p>
<ul>
<li>Phone Accelerometer</li>
<li>Phone Activity Recognition</li>
<li>Phone Applications Crashes</li>
<li>Phone Applications Foreground</li>
<li>Phone Applications Notifications</li>
<li>Phone Battery</li>
<li>Phone Bluetooth</li>
<li>Phone Calls</li>
<li>Phone Conversation</li>
<li>Phone Data Yield</li>
<li>Phone Keyboard</li>
<li>Phone Light</li>
<li>Phone Locations</li>
<li>Phone Log</li>
<li>Phone Messages</li>
<li>Phone Screen</li>
<li>Phone WiFI Connected</li>
<li>Phone WiFI Visible</li>
</ul>
<p>Fitbit</p>
<ul>
<li>Fitbit Data Yield</li>
<li>Fitbit Heart Rate Summary</li>
<li>Fitbit Heart Rate Intraday</li>
<li>Fitbit Sleep Summary</li>
<li>Fitbit Sleep Intraday</li>
<li>Fitbit Steps Summary</li>
<li>Fitbit Steps Intraday</li>
</ul>
<p>Empatica</p>
<ul>
<li>Empatica Accelerometer</li>
<li>Empatica Heart Rate</li>
<li>Empatica Temperature</li>
<li>Empatica Electrodermal Activity</li>
<li>Empatica Blood Volume Pulse</li>
<li>Empatica Inter Beat Interval</li>
<li>Empatica Tags</li>
</ul>
</details>
<h3 id="modify-the-configyaml-file">Modify the <code>config.yaml</code> file<a class="headerlink" href="#modify-the-configyaml-file" title="Permanent link">&para;</a></h3>
<p>In this step, you need to add your provider configuration section under the relevant sensor in <code>config.yaml</code>. See our example for our tutorial&rsquo;s <code>VEGA</code> provider for <code>PHONE_ACCELEROMETER</code>:</p>
<details class="example"><summary>Example configuration for a new accelerometer provider <code>VEGA</code></summary><div class="highlight"><pre><span></span><code><span class="nt">PHONE_ACCELEROMETER</span><span class="p">:</span>
<span class="nt">CONTAINER</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">accelerometer</span>
<span class="nt">PROVIDERS</span><span class="p">:</span>
<span class="nt">RAPIDS</span><span class="p">:</span> <span class="c1"># this is a feature provider</span>
<span class="nt">COMPUTE</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">False</span>
<span class="l l-Scalar l-Scalar-Plain">...</span>
<span class="nt">PANDA</span><span class="p">:</span> <span class="c1"># this is another feature provider</span>
<span class="nt">COMPUTE</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">False</span>
<span class="l l-Scalar l-Scalar-Plain">...</span>
<span class="hll"> <span class="nt">VEGA</span><span class="p">:</span> <span class="c1"># this is our new feature provider</span>
</span><span class="hll"> <span class="nt">COMPUTE</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">False</span>
</span><span class="hll"> <span class="nt">FEATURES</span><span class="p">:</span> <span class="p p-Indicator">[</span><span class="s">&quot;feature1&quot;</span><span class="p p-Indicator">,</span> <span class="s">&quot;feature2&quot;</span><span class="p p-Indicator">,</span> <span class="s">&quot;feature3&quot;</span><span class="p p-Indicator">]</span>
</span><span class="hll"> <span class="nt">MY_PARAMTER</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">a_string</span>
</span><span class="hll"> <span class="nt">SRC_SCRIPT</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">src/features/phone_accelerometer/vega/main.py</span>
</span></code></pre></div>
</details>
<table>
<thead>
<tr>
<th>Key&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>[COMPUTE]</code></td>
<td>Flag to activate/deactivate your provider</td>
</tr>
<tr>
<td><code>[FEATURES]</code></td>
<td>List of features your provider supports. Your provider code should only return the features on this list</td>
</tr>
<tr>
<td><code>[MY_PARAMTER]</code></td>
<td>An arbitrary parameter that our example provider <code>VEGA</code> needs. This can be a boolean, integer, float, string, or an array of any of such types.</td>
</tr>
<tr>
<td><code>[SRC_SCRIPT]</code></td>
<td>The relative path from RAPIDS&rsquo; root folder to an script that computes the features for this provider. It can be implemented in R or Python.</td>
</tr>
</tbody>
</table>
<h3 id="create-a-feature-provider-script">Create a feature provider script<a class="headerlink" href="#create-a-feature-provider-script" title="Permanent link">&para;</a></h3>
<p>Create your feature Python or R script called <code>main.py</code> or <code>main.R</code> in the correct folder, <code>src/feature/[sensorname]/[providername]/</code>. RAPIDS automatically loads and executes it based on the config key <code>[SRC_SCRIPT]</code> you added in the last step. For our example, this script is:
<div class="highlight"><pre><span></span><code>src/feature/phone_accelerometer/vega/main.py
</code></pre></div></p>
<h3 id="implement-your-feature-extraction-code">Implement your feature extraction code<a class="headerlink" href="#implement-your-feature-extraction-code" title="Permanent link">&para;</a></h3>
<p>Every feature script (<code>main.[py|R]</code>) needs a <code>[providername]_features</code> function with specific parameters. RAPIDS calls this function with the sensor data ready to process and with other functions and arguments you will need.</p>
<div class="tabbed-set" data-tabs="1:2"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><label for="__tabbed_1_1">Python function</label><div class="tabbed-content">
<div class="highlight"><pre><span></span><code><span class="k">def</span> <span class="p">[</span><span class="n">providername</span><span class="p">]</span><span class="n">_features</span><span class="p">(</span><span class="n">sensor_data_files</span><span class="p">,</span> <span class="n">time_segment</span><span class="p">,</span> <span class="n">provider</span><span class="p">,</span> <span class="n">filter_data_by_segment</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="c1"># empty for now</span>
<span class="k">return</span><span class="p">(</span><span class="n">your_features_df</span><span class="p">)</span>
</code></pre></div>
</div>
<input id="__tabbed_1_2" name="__tabbed_1" type="radio" /><label for="__tabbed_1_2">R function</label><div class="tabbed-content">
<div class="highlight"><pre><span></span><code><span class="p">[</span><span class="n">providername</span><span class="p">]</span>_<span class="n">features</span> <span class="o">&lt;-</span> <span class="nf">function</span><span class="p">(</span><span class="n">sensor_data</span><span class="p">,</span> <span class="n">time_segment</span><span class="p">,</span> <span class="n">provider</span><span class="p">){</span>
<span class="c1"># empty for now</span>
<span class="nf">return</span><span class="p">(</span><span class="n">your_features_df</span><span class="p">)</span>
<span class="p">}</span>
</code></pre></div>
</div>
</div>
<table>
<thead>
<tr>
<th>Parameter&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>sensor_data_files</code></td>
<td>Path to the CSV file containing the data of a single participant. This data has been cleaned and preprocessed. Your function will be automatically called for each participant in your study (in the <code>[PIDS]</code> array in <code>config.yaml</code>)</td>
</tr>
<tr>
<td><code>time_segment</code></td>
<td>The label of the time segment that should be processed.</td>
</tr>
<tr>
<td><code>provider</code></td>
<td>The parameters you configured for your provider in <code>config.yaml</code> will be available in this variable as a dictionary in Python or a list in R. In our example this dictionary contains <code>{MY_PARAMETER:"a_string"}</code></td>
</tr>
<tr>
<td><code>filter_data_by_segment</code></td>
<td>Python only. A function that you will use to filter your data. In R this function is already available in the environment.</td>
</tr>
<tr>
<td><code>*args</code></td>
<td>Python only. Not used for now</td>
</tr>
<tr>
<td><code>**kwargs</code></td>
<td>Python only. Not used for now</td>
</tr>
</tbody>
</table>
<p>The next step is to implement the code that computes your behavioral features in your provider script&rsquo;s function. As with any other script, this function can call other auxiliary methods, but in general terms, it should have three stages:</p>
<details class="info"><summary>1. Read a participant&rsquo;s data by loading the CSV data stored in the file pointed by <code>sensor_data_files</code></summary><div class="highlight"><pre><span></span><code><span class="n">acc_data</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">read_csv</span><span class="p">(</span><span class="n">sensor_data_files</span><span class="p">[</span><span class="s2">&quot;sensor_data&quot;</span><span class="p">])</span>
</code></pre></div>
<p>Note that the phone&rsquo;s battery, screen, and activity recognition data are given as episodes instead of event rows (for example, start and end timestamps of the periods the phone screen was on)</p>
</details>
<details class="info"><summary>2. Filter your data to process only those rows that belong to <code>time_segment</code></summary><p>This step is only one line of code, but keep reading to understand why we need it.
<div class="highlight"><pre><span></span><code><span class="n">acc_data</span> <span class="o">=</span> <span class="n">filter_data_by_segment</span><span class="p">(</span><span class="n">acc_data</span><span class="p">,</span> <span class="n">time_segment</span><span class="p">)</span>
</code></pre></div></p>
<p>You should use the <code>filter_data_by_segment()</code> function to process and group those rows that belong to each of the <a href="../../setup/configuration/#time-segments">time segments RAPIDS could be configured with</a>.</p>
<p>Let&rsquo;s understand the <code>filter_data_by_segment()</code> function with an example. A RAPIDS user can extract features on any arbitrary <a href="../../setup/configuration/#time-segments">time segment</a>. A time segment is a period that has a label and one or more instances. For example, the user (or you) could have requested features on a daily, weekly, and weekend basis for <code>p01</code>. The labels are arbitrary, and the instances depend on the days a participant was monitored for: </p>
<ul>
<li>the daily segment could be named <code>my_days</code> and if <code>p01</code> was monitored for 14 days, it would have 14 instances</li>
<li>the weekly segment could be named <code>my_weeks</code> and if <code>p01</code> was monitored for 14 days, it would have 2 instances.</li>
<li>the weekend segment could be named <code>my_weekends</code> and if <code>p01</code> was monitored for 14 days, it would have 2 instances.</li>
</ul>
<p>For this example, RAPIDS will call your provider function three times for <code>p01</code>, once where <code>time_segment</code> is <code>my_days</code>, once where <code>time_segment</code> is <code>my_weeks</code>, and once where <code>time_segment</code> is <code>my_weekends</code>. In this example, not every row in <code>p01</code>&lsquo;s data needs to take part in the feature computation for either segment <strong>and</strong> the rows need to be grouped differently. </p>
<p>Thus <code>filter_data_by_segment()</code> comes in handy, it will return a data frame that contains the rows that were logged during a time segment plus an extra column called <code>local_segment</code>. This new column will have as many unique values as time segment instances exist (14, 2, and 2 for our <code>p01</code>&lsquo;s <code>my_days</code>, <code>my_weeks</code>, and <code>my_weekends</code> examples). After filtering, <strong>you should group the data frame by this column and compute any desired features</strong>, for example:</p>
<div class="highlight"><pre><span></span><code><span class="n">acc_features</span><span class="p">[</span><span class="s2">&quot;maxmagnitude&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">acc_data</span><span class="o">.</span><span class="n">groupby</span><span class="p">([</span><span class="s2">&quot;local_segment&quot;</span><span class="p">])[</span><span class="s2">&quot;magnitude&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">max</span><span class="p">()</span>
</code></pre></div>
<p>The reason RAPIDS does not filter the participant&rsquo;s data set for you is because your code might need to compute something based on a participant&rsquo;s complete dataset before computing their features. For example, you might want to identify the number that called a participant the most throughout the study before computing a feature with the number of calls the participant received from that number.</p>
</details>
<details class="info"><summary>3. Return a data frame with your features</summary><p>After filtering, grouping your data, and computing your features, your provider function should return a data frame that has:</p>
<ul>
<li>One row per time segment instance (e.g., 14 our <code>p01</code>&lsquo;s <code>my_days</code> example)</li>
<li>The <code>local_segment</code> column added by <code>filter_data_by_segment()</code></li>
<li>One column per feature. The name of your features should only contain letters or numbers (<code>feature1</code>) by convention. RAPIDS automatically adds the correct sensor and provider prefix; in our example, this prefix is <code>phone_accelerometr_vega_</code>.</li>
</ul>
</details>
<details class="example"><summary><code>PHONE_ACCELEROMETER</code> Provider Example</summary><p>For your reference, this our own provider (<code>RAPIDS</code>) for <code>PHONE_ACCELEROMETER</code> that computes five acceleration features</p>
<div class="highlight"><pre><span></span><code><span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="k">def</span> <span class="nf">rapids_features</span><span class="p">(</span><span class="n">sensor_data_files</span><span class="p">,</span> <span class="n">time_segment</span><span class="p">,</span> <span class="n">provider</span><span class="p">,</span> <span class="n">filter_data_by_segment</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="n">acc_data</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">read_csv</span><span class="p">(</span><span class="n">sensor_data_files</span><span class="p">[</span><span class="s2">&quot;sensor_data&quot;</span><span class="p">])</span>
<span class="n">requested_features</span> <span class="o">=</span> <span class="n">provider</span><span class="p">[</span><span class="s2">&quot;FEATURES&quot;</span><span class="p">]</span>
<span class="c1"># name of the features this function can compute</span>
<span class="n">base_features_names</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;maxmagnitude&quot;</span><span class="p">,</span> <span class="s2">&quot;minmagnitude&quot;</span><span class="p">,</span> <span class="s2">&quot;avgmagnitude&quot;</span><span class="p">,</span> <span class="s2">&quot;medianmagnitude&quot;</span><span class="p">,</span> <span class="s2">&quot;stdmagnitude&quot;</span><span class="p">]</span>
<span class="c1"># the subset of requested features this function can compute</span>
<span class="n">features_to_compute</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">requested_features</span><span class="p">)</span> <span class="o">&amp;</span> <span class="nb">set</span><span class="p">(</span><span class="n">base_features_names</span><span class="p">))</span>
<span class="n">acc_features</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">(</span><span class="n">columns</span><span class="o">=</span><span class="p">[</span><span class="s2">&quot;local_segment&quot;</span><span class="p">]</span> <span class="o">+</span> <span class="n">features_to_compute</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">acc_data</span><span class="o">.</span><span class="n">empty</span><span class="p">:</span>
<span class="n">acc_data</span> <span class="o">=</span> <span class="n">filter_data_by_segment</span><span class="p">(</span><span class="n">acc_data</span><span class="p">,</span> <span class="n">time_segment</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">acc_data</span><span class="o">.</span><span class="n">empty</span><span class="p">:</span>
<span class="n">acc_features</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">()</span>
<span class="c1"># get magnitude related features: magnitude = sqrt(x^2+y^2+z^2)</span>
<span class="n">magnitude</span> <span class="o">=</span> <span class="n">acc_data</span><span class="o">.</span><span class="n">apply</span><span class="p">(</span><span class="k">lambda</span> <span class="n">row</span><span class="p">:</span> <span class="n">np</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="n">row</span><span class="p">[</span><span class="s2">&quot;double_values_0&quot;</span><span class="p">]</span> <span class="o">**</span> <span class="mi">2</span> <span class="o">+</span> <span class="n">row</span><span class="p">[</span><span class="s2">&quot;double_values_1&quot;</span><span class="p">]</span> <span class="o">**</span> <span class="mi">2</span> <span class="o">+</span> <span class="n">row</span><span class="p">[</span><span class="s2">&quot;double_values_2&quot;</span><span class="p">]</span> <span class="o">**</span> <span class="mi">2</span><span class="p">),</span> <span class="n">axis</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
<span class="n">acc_data</span> <span class="o">=</span> <span class="n">acc_data</span><span class="o">.</span><span class="n">assign</span><span class="p">(</span><span class="n">magnitude</span> <span class="o">=</span> <span class="n">magnitude</span><span class="o">.</span><span class="n">values</span><span class="p">)</span>
<span class="k">if</span> <span class="s2">&quot;maxmagnitude&quot;</span> <span class="ow">in</span> <span class="n">features_to_compute</span><span class="p">:</span>
<span class="n">acc_features</span><span class="p">[</span><span class="s2">&quot;maxmagnitude&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">acc_data</span><span class="o">.</span><span class="n">groupby</span><span class="p">([</span><span class="s2">&quot;local_segment&quot;</span><span class="p">])[</span><span class="s2">&quot;magnitude&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">max</span><span class="p">()</span>
<span class="k">if</span> <span class="s2">&quot;minmagnitude&quot;</span> <span class="ow">in</span> <span class="n">features_to_compute</span><span class="p">:</span>
<span class="n">acc_features</span><span class="p">[</span><span class="s2">&quot;minmagnitude&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">acc_data</span><span class="o">.</span><span class="n">groupby</span><span class="p">([</span><span class="s2">&quot;local_segment&quot;</span><span class="p">])[</span><span class="s2">&quot;magnitude&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">min</span><span class="p">()</span>
<span class="k">if</span> <span class="s2">&quot;avgmagnitude&quot;</span> <span class="ow">in</span> <span class="n">features_to_compute</span><span class="p">:</span>
<span class="n">acc_features</span><span class="p">[</span><span class="s2">&quot;avgmagnitude&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">acc_data</span><span class="o">.</span><span class="n">groupby</span><span class="p">([</span><span class="s2">&quot;local_segment&quot;</span><span class="p">])[</span><span class="s2">&quot;magnitude&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">mean</span><span class="p">()</span>
<span class="k">if</span> <span class="s2">&quot;medianmagnitude&quot;</span> <span class="ow">in</span> <span class="n">features_to_compute</span><span class="p">:</span>
<span class="n">acc_features</span><span class="p">[</span><span class="s2">&quot;medianmagnitude&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">acc_data</span><span class="o">.</span><span class="n">groupby</span><span class="p">([</span><span class="s2">&quot;local_segment&quot;</span><span class="p">])[</span><span class="s2">&quot;magnitude&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">median</span><span class="p">()</span>
<span class="k">if</span> <span class="s2">&quot;stdmagnitude&quot;</span> <span class="ow">in</span> <span class="n">features_to_compute</span><span class="p">:</span>
<span class="n">acc_features</span><span class="p">[</span><span class="s2">&quot;stdmagnitude&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">acc_data</span><span class="o">.</span><span class="n">groupby</span><span class="p">([</span><span class="s2">&quot;local_segment&quot;</span><span class="p">])[</span><span class="s2">&quot;magnitude&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">std</span><span class="p">()</span>
<span class="n">acc_features</span> <span class="o">=</span> <span class="n">acc_features</span><span class="o">.</span><span class="n">reset_index</span><span class="p">()</span>
<span class="k">return</span> <span class="n">acc_features</span>
</code></pre></div>
</details>
<h2 id="new-features-for-non-existing-sensors">New Features for Non-Existing Sensors<a class="headerlink" href="#new-features-for-non-existing-sensors" title="Permanent link">&para;</a></h2>
<p>If you want to add features for a device or a sensor that we do not support at the moment (those that do not appear in the <code>"Existing Sensors"</code> list above), <a href="../../team">contact us</a> or request it on <a href="http://awareframework.com:3000/">Slack</a> and we can add the necessary code so you can follow the instructions above.</p>
<!-- Add custom comment system integration here -->
<!-- Utterances integration -->
<h2 id="__comments">Comments</h2>
<script type="text/javascript">
var rapids_utterances_theme = false
document.onreadystatechange = function () {
if (document.readyState == "interactive") {
// wait for utterances to load and send it's first message.
addEventListener('message', event => {
if (event.origin !== 'https://utteranc.es' || rapids_utterances_theme == true) {
return;
}
rapids_utterances_theme = true
if(document.body.getAttribute("data-md-color-scheme") == "default")
document.querySelector("iframe.utterances-frame").contentWindow.postMessage({ type: "set-theme", theme: "github-light" },"https://utteranc.es/")
else
document.querySelector("iframe.utterances-frame").contentWindow.postMessage({ type: "set-theme", theme: "photon-dark" },"https://utteranc.es/")
});
document.getElementById('__palette_1').onclick = function(){
document.querySelector("iframe.utterances-frame").contentWindow.postMessage({ type: "set-theme", theme: "github-light" },"https://utteranc.es/")
}
document.getElementById('__palette_2').onclick = function(){
document.querySelector("iframe.utterances-frame").contentWindow.postMessage({ type: "set-theme", theme: "photon-dark" },"https://utteranc.es/")
}
}
}
</script>
<script src="https://utteranc.es/client.js"
repo="carissalow/rapids"
issue-term="pathname"
label="docs comments"
theme="github-light"
crossorigin="anonymous"
async>
</script>
</article>
</div>
</div>
</main>
<footer class="md-footer">
<nav class="md-footer__inner md-grid" aria-label="Footer">
<a href="../empatica-tags/" class="md-footer__link md-footer__link--prev" rel="prev">
<div class="md-footer__button md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12z"/></svg>
</div>
<div class="md-footer__title">
<div class="md-ellipsis">
<span class="md-footer__direction">
Previous
</span>
Empatica Tags
</div>
</div>
</a>
<a href="../../visualizations/data-quality-visualizations/" class="md-footer__link md-footer__link--next" rel="next">
<div class="md-footer__title">
<div class="md-ellipsis">
<span class="md-footer__direction">
Next
</span>
Data Quality
</div>
</div>
<div class="md-footer__button md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 11v2h12l-5.5 5.5 1.42 1.42L19.84 12l-7.92-7.92L10.5 5.5 16 11H4z"/></svg>
</div>
</a>
</nav>
<div class="md-footer-meta md-typeset">
<div class="md-footer-meta__inner md-grid">
<div class="md-footer-copyright">
<div class="md-footer-copyright__highlight">
Released under AGPL
</div>
Made with
<a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
Material for MkDocs Insiders
</a>
</div>
<div class="md-footer-social">
<a href="https://twitter.com/julio_ui" target="_blank" rel="noopener" title="twitter.com" class="md-footer-social__link">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253z"/></svg>
</a>
</div>
</div>
</div>
</footer>
</div>
<div class="md-dialog" data-md-component="dialog">
<div class="md-dialog__inner md-typeset"></div>
</div>
<script id="__config" type="application/json">{"base": "../..", "features": ["navigation.sections", "search.suggest", "search.highlight"], "translations": {"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"}, "search": "../../assets/javascripts/workers/search.df8cae7d.min.js", "version": {"provider": "mike"}}</script>
<script src="../../assets/javascripts/bundle.0c4ae912.min.js"></script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
</body>
</html>