Determines peak onset using a hierarchical set of rules, evaluated in
order until one succeeds:
Lowest glucose value between wake time and the peak.
A valley within 30 minutes before the peak.
The inflection point of the ascending slope (>= 30 min of
sustained rise).
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.