Skip to contents

Identifies candidate peaks in a smoothed glucose trace using dynamically adjusted prominence and minimum-distance criteria, restricted to values that exceed the corrected baseline by a minimum rise and an absolute floor.

Usage

detect_candidate_peaks(
  glucose,
  baseline,
  glucose_sd,
  min_rise = 10,
  abs_floor = 70
)

Arguments

glucose

Numeric vector, smoothed glucose trace (see sg_smooth()).

baseline

Numeric scalar, corrected baseline (see correct_baseline()).

glucose_sd

Numeric scalar, glucose standard deviation used to set dynamic prominence/distance thresholds.

min_rise

Numeric, minimum rise above baseline required for a peak to be considered valid. Default 10 (mg/dL).

abs_floor

Numeric, absolute minimum glucose value for a valid peak. Default 70 (mg/dL).

Value

A data frame of candidate peaks with columns index, time (if timestamps are supplied downstream), and value.

Details

Thresholds follow the manuscript pipeline:

  • Prominence: max(2, glucose_sd) mg/dL

  • Distance: 4 points if glucose_sd < 10, else 5 points

  • Validation tolerance: max(5, glucose_sd) mg/dL