% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/scores_nt_fitbit.R
\name{compute_block_counts}
\alias{compute_block_counts}
\title{Compute count of valid main sleep episodes per participant-day}
\usage{
compute_block_counts(data, main_dur)
}
\arguments{
\item{data}{tbl. Sleep block-level dataset containing at minimum:
\code{participant_id}, \code{sleep_date}, \code{main_block}, and \code{duration_min}.}

\item{main_dur}{numeric. Minimum block duration (in minutes) required for a
sleep block to be considered a main sleep period.}
}
\value{
tbl. A summarized data frame at the participant-day level with:
\itemize{
\item \code{n}: Number of main sleep blocks meeting the minimum duration threshold.
\item \code{single_block}: Logical indicator of whether exactly one valid main sleep
episode is present.
}
}
\description{
This function evaluates sleep blocks and identifies whether each sleep day
contains a single valid main sleep episode based on a minimum duration
threshold.
}
\details{
The function is used to assess sleep fragmentation at the block level by
counting how many blocks satisfy both the \code{main_block} flag and the
minimum duration requirement. This is commonly used in extended sleep
pipelines to distinguish consolidated sleep from fragmented sleep patterns.
}
\keyword{internal}
