% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/scores_nt_fitbit.R
\name{create_block_ranges}
\alias{create_block_ranges}
\title{Identify contiguous sleep episodes.}
\usage{
create_block_ranges(exclusions_df, offset = "12:00", gap)
}
\arguments{
\item{exclusions_df}{tbl. Data frame with columns \code{is_slp}, \code{dtt},
\code{hrate_excluded}, and \code{main_slp}.}

\item{offset}{character. Time of day \code{"HH:MM"} used as the cutoff for
defining the sleep day. Timestamps occuring after this time are assigned to
the next day.}

\item{gap}{numeric. Maximum allowed gap.}
}
\value{
tbl. A dataframe summarized at the sleep-block level, with the
following columns:
\itemize{
\item \code{participant_id}: participant identifier
\item \code{block_id}: identifier for each sleep block
\item \code{block_start}: Start timestamp of each continous sleep block.
\item \code{block_end}: End timestamp of each continous sleep block.
\item \code{main_block}: Logical indicator of whether the block contains any main
sleep.
\item \code{duration_min}: Duration of each sleep block in minutes.
\item \code{sleep_date}:  Sleep-aligned date based on specified \code{offset}.
}
}
\description{
Identifies contiguous sleep episodes based on temporal gaps between valid
sleep minutes.  A new block is begins whenever the time difference between
consecutive sleep records exceeds specified threshold. Function provides
start and end times for each block and indicates whether they contain 'main'
sleep.
}
\note{
\code{exclusions_df}: output of identify_hr_exclusions() or
identify_hr_recovery(); needs exclusion flags
function is specific to extended framework
input: offset sleep data with exclusion flags
}
\keyword{internal}
