Skip to contents

This function identifies and removes points in the base segment where melatonin concentrations exceed a specified threshold. It ensures that only the earliest base points remain while maintaining a valid base segment structure.

Usage

truncate_base_segment(profile_data, threshold = 2.3)

Arguments

profile_data

A tibble or dataframe containing the melatonin profile. It must include the columns:

  • datetime (POSIXct) – Timestamps of data points.

  • melatonin (numeric) – Melatonin concentration levels.

  • base (integer, 0 or 1) – Indicator of base segment points.

threshold

Numeric. The melatonin concentration threshold. Any base segment points above this threshold are removed. Default is 2.3.

Value

A modified tibble where invalid base points have been removed. If no valid base points remain, a warning is issued.