Skip to contents

Determines peak onset using a hierarchical set of rules, evaluated in order until one succeeds:

  1. Lowest glucose value between wake time and the peak.

  2. A valley within 30 minutes before the peak.

  3. The inflection point of the ascending slope (>= 30 min of sustained rise).

  4. The nearest local minimum identified by a derivative-sign crossing.

Usage

find_onset(glucose, timestamps, wake_time, peak_index)

Arguments

glucose

Numeric vector, smoothed glucose trace.

timestamps

POSIXct vector, same length as glucose.

wake_time

POSIXct scalar, timestamp of wake onset.

peak_index

Integer, index of the selected peak within glucose.

Value

A list with index, time, and value for the onset point, and method indicating which rule was used.