Skip to contents

This function launches a Shiny app that allows users to interactively explore and modify sleep cycle detection parameters using the Dude algorithm. The app visualizes Non-REM Periods (NREMP) REM Periods (REMP) while allowing users to adjust key parameters that control how sleep cycles are detected.

Usage

run_sleepcycles_app(sleepcycles_obj)

Arguments

sleepcycles_obj

A SleepCycle object created using sleepcycles_from_hypnogram() with method = "dude".

Value

A Shiny app that runs interactively for adjusting Dude algorithm parameters.

Details

The Dude algorithm identifies sleep cycles based on density thresholds and temporal continuity rules. This app allows users to adjust the following NREMP and REMP parameters:

  • Density variable: The EEG feature or sleep stage combination used to measure Non-REM density.

  • Density threshold: A cutoff value (0.1 - 1.0) that defines what constitutes a Non-REM Period. Increasing this value increase specificity but may lower sensitivity.

  • Minimum gap: The minimum duration (in epochs) between two separate NREMP/REMPs. If two NREMPs are closer than this, they are merged into one.

  • Minimum size: The shortest duration allowed (in epochs) to count as an NREMP/REMP.

Requirements

  • The input must be a SleepCycle object created using the Dude algorithm.

Examples

if (interactive()) {
  data("hypnogram_grouped")
  run_sleepcycles_app(
   sleepcycles_from_hypnogram(
     hypnogram_grouped,
     epoch_col = "epoch",
     stage_col = "stage",
     id_col = "id",
     verbose = FALSE
   )
 )
}