View source: R/rebound_events.R
| rebound_events | R Documentation |
Detects rebound hypoglycemia (Rhypo) and rebound hyperglycemia (Rhyper) as derived events built from cgmguru Level 1 event starts and a later opposite-threshold crossing within a configurable time window.
Rhypo is a Level 1 hyperglycemic event (>180 mg/dL for at least
15 minutes) followed by any glucose value <70 mg/dL within
rebound_minutes. Rhyper is a Level 1 hypoglycemic event
(<70 mg/dL for at least 15 minutes) followed by any glucose value
>180 mg/dL within rebound_minutes. The later rebound side
only needs a single qualifying threshold crossing.
These rebound hypoglycemia and hyperglycemia definitions are documented by Hansen and Bibby (2024); cgmguru applies them on its own event-preprocessed CGM grid.
rebound_events(df, type = c("all", "hypo", "hyper"),
data_source = c("raw", "preprocessed"), reading_minutes = NULL,
sort_time = FALSE, inter_gap = 45, rebound_minutes = 120,
return_interpolated = TRUE)
df |
A dataframe containing continuous glucose monitoring (CGM) data
with columns |
type |
Rebound direction to return. |
data_source |
Source interpretation for |
reading_minutes |
Time interval between readings in minutes. Can be a
scalar, a vector matching |
sort_time |
Logical. If |
inter_gap |
Maximum gap in minutes to interpolate across when
|
rebound_minutes |
Maximum bridge interval in minutes from the initial Level 1 event end to the later rebound threshold crossing. Defaults to 120. |
return_interpolated |
Logical. If |
A list containing:
events_total: Tibble with id, type,
total_episodes, and avg_ep_per_day.
events_detailed: Tibble with bridge boundaries
(start_time, end_time, indices, and glucose values), the
initial Level 1 event boundaries, rebound threshold crossing fields, and
minutes_to_rebound.
interpolated_data: The preprocessed event grid used for
rebound detection, included by default when
return_interpolated = TRUE, with columns id, time,
and gl.
Hansen, K. W., and Bibby, B. M. (2024). Rebound hypoglycemia and hyperglycemia in type 1 diabetes. Journal of Diabetes Science and Technology, 18(6), 1392-1398.
detect_all_events, detect_hyperglycemic_events, detect_hypoglycemic_events, interpolate_cgm
df <- data.frame(
id = "A",
time = as.POSIXct("2026-01-01 00:00:00", tz = "UTC") + 0:8 * 5 * 60,
gl = c(190, 195, 200, 170, 165, 160, 65, 100, 110)
)
rebound_events(df, type = "hypo", reading_minutes = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.