Skip to content

Analytical pipeline and R functions for testing the performance of sleep-tracking technology.

License

Notifications You must be signed in to change notification settings

SRI-human-sleep/sleep-trackers-performance

Repository files navigation

Analytical pipeline and functions for testing the performance of sleep-tracking technology

The repository includes a set of functions based on the R environment that implement the analytical steps described in the article:

Menghini, L., Cellini, N., Goldstone, A., Baker, F. C., & de Zambotti, M. (2021). A standardized framework for testing the performance of sleep-tracking technology: step-by-step guidelines and open-source code. Sleep, 44(2), zsaa170. https://dx.doi.org/10.1093%2Fsleep%2Fzsaa170

Analytical pipeline

The analytical pipeline for applying the functions to a dataset is depicted at this page.

R functions

To use the functions, it is required to (1) download and install R, (2) prepare a dataset of epoch-by-epoch data (as described in the article, and (3) load both the dataset and the functions in R.

  • To read a dataset, functions such as read.csv() can be used depending on the file format (type ?read.csv() in R for details). The command read.csv(file.choose()) allows to open a dialog box presented to the user to browse the file in the computer.
  • To read the functions, the files should be downloaded from the Functions folder in this repository, and pasted in the directory folder used by R (the command getwd() in R allows to visualize the current directory). The command source("function_name.R") allows to read the function file. The command source(file.choose()) allows to open a dialog box presented to the user to browse the file in the computer.
  • The first time that a function is used, it automatically installs all the required packages (might take a while). Alternatively, R packages can be installed using the command install.packages("package_name").

The following functions are included:

  • ebe2sleep.R uses the epoch-by-epoch dataset to generate a dataset of sleep measures
  • indDiscr.R uses the dataset generated by ebe2sleep.R to generate a dataset individual-level discrepancies
  • groupDiscr.R uses the dataset generated with ebe2sleep.R to compute gorup-level discrepancy metrics
  • BAplot.R uses the dataset generated with ebe2sleep.R to generate a Bland-Altman plot for a specific measure
  • errorMatrix.R uses the epoch-by-epoch dataset to compute an error matrix
  • indEBE.R uses the epoch-by-epoch dataset to compute epoch-by-epoch performance metrics for each subject
  • groupEBE.R uses the epoch-by-epoch dataset to compute epoch-by-epoch performance metrics for the whole sample

Updates

  • Sept 8th 2023: Spotted and corrected errors in the computation of prevalence, PPV, and NPV within the groupEBE function. We thank @selectwait and Dr. Satomi Okabe for spotting the errors.

About

Analytical pipeline and R functions for testing the performance of sleep-tracking technology.

Resources

License

Stars

Watchers

Forks

Packages

No packages published