Skip to content

HugoGit39/sia.project.2.sdv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project Status: Active – The project has reached a stable, usable state and is being actively developed.

SiA x SDV Logo

About

This repository contains R scripts for connecting to the Sports Data Valley (SDV) API to retrieve wearable data from users (Fitbit, Garmin) in research groups, quantify missing or incomplete heart rate time series, and provide interactive visualization tools for researchers.

The pipeline is part of the Stress in Action consortium (Research Theme 2), which focuses on reliable real-time measurement of daily life stress and its impact on health using wearable technology.

How to Use This Repository

Step 1: Setup and Authentication

Create a .Renviron file with your API credentials and group ID:

BASE_URL=https://app.sportdatavalley.nl
API_PATH=/api/v1
AUTH_HEADER=Bearer your-token
GROUP_NO=your-group-id

Install required R packages:

install.packages(c("httr", "lubridate", "rjson", "here", "tidyverse", "plotly", "data.table"))

Step 2: Retrieve Group Information

Use the provided function get_group_info() to list all members in your SDV group. This step creates a profile_list object with user IDs and names.

Step 3: Download Activity Data

Fetch all activity data for your group using the get_all_group_rec_act() function. This retrieves recent VDOs (Versioned Data Objects) and parses structured data for:

  • User ID and name
  • Data type (Fitbit or Garmin)
  • Date of measurement (dateTime or calendar_date)
  • Heart rate time series (heart_intra_day for Fitbit or time_offset_heart_rate_samples for Garmin)
  • Versioned Data Object ID
Step 4: Identify Missing or Incomplete Data

The script checks whether:

  • The time series is NULL
  • The length of the series is less than 50% of expected values:
    • Fitbit: (60 × 24) / 2 samples
    • Garmin: (4 × 60 × 24) / 2 samples

Filtered data is saved in filtered_data, grouped by user ID and including:

  • User Info: first name, last name
  • Record Details: date, time series length, dataset ID
Step 5: Visualize Missing Data

The visualize_missing_data.R script creates an interactive Plotly scatter plot:

  • X-axis: Date of measurement
  • Y-axis: Time series length
  • Dropdown menu: Select a user to filter the view
  • Hover details: User name, ID, date, samples, dataset ID
Step 6: Analyze Individual Datasets

Use get_data() to retrieve and explore specific VDOs:

  • Extract heart rate time series
  • Convert to a tidy data frame
  • Generate an interactive line plot of heart rate values over time using Plotly
Example Visualization

An example output is an interactive scatter plot where each point represents a daily record for a user. Researchers can quickly identify:

  • Days with missing time series (0 samples)
  • Days with incomplete coverage
(Add screenshot here after running the pipeline)

API Documentation and Resources

About

This repository provides R scripts to connect with the Sports Data Valley (SDV) API, retrieve Fitbit and Garmin data, detect missing or incomplete heart rate time series, and create interactive visualizations for researchers.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages