% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/validate_mnirs.R
\name{validate_mnirs}
\alias{validate_mnirs}
\alias{validate_numeric}
\alias{validate_mnirs_data}
\alias{validate_nirs_channels}
\alias{validate_time_channel}
\alias{validate_event_channel}
\alias{estimate_sample_rate}
\alias{validate_sample_rate}
\alias{validate_width_span}
\alias{validate_x_t}
\title{Validate \code{{mnirs}} parameters}
\usage{
validate_numeric(
  x,
  elements = Inf,
  range = NULL,
  inclusive = c("left", "right"),
  integer = FALSE,
  allow_na = FALSE,
  msg1 = "",
  msg2 = ""
)

validate_mnirs_data(data, ncol = 2L)

validate_nirs_channels(
  nirs_channels,
  data,
  verbose = FALSE,
  as_list = FALSE,
  env = rlang::caller_env()
)

validate_time_channel(time_channel, data, env = rlang::caller_env())

validate_event_channel(
  event_channel,
  data,
  required = TRUE,
  env = rlang::caller_env()
)

estimate_sample_rate(x)

validate_sample_rate(data, time_channel, sample_rate, verbose = TRUE)

validate_width_span(width = NULL, span = NULL, verbose = TRUE, msg = "")

validate_x_t(x, t, allow_na = FALSE)
}
\arguments{
\item{x}{A numeric vector.}

\item{elements}{An integer. Default is \code{Inf}. The number of numeric elements
expected in \code{x}.}

\item{range}{A two-element numeric vector giving the valid range for \code{x}.}

\item{inclusive}{A character vector specifying which boundaries of \code{range}
are included. Any of \code{"left"}, \code{"right"} (default is both). Use \code{FALSE} to
exclude both endpoints.}

\item{integer}{Logical. Default is \code{FALSE}. If \code{TRUE}, validate \code{x} as
integer-like values using \code{\link[rlang:is_integerish]{rlang::is_integerish()}}. Otherwise tested as a
numeric value.}

\item{allow_na}{Logical. Default is \code{FALSE}. If \code{TRUE}, allows pass through
of \code{NA} to the returned numeric/integer vector.}

\item{msg1, msg2}{A character string appended to the \code{\link[cli:cli_abort]{cli::cli_abort()}}
message when numeric validation fails.}

\item{data}{A data frame of class \emph{"mnirs"} containing time series data and
metadata.}

\item{nirs_channels}{A character vector giving the names of mNIRS columns to
operate on. Must match column names in \code{data} exactly.
\itemize{
\item If \code{NULL} (default), the \code{nirs_channels} metadata attribute of \code{data} is
used.
}}

\item{verbose}{Logical. Default is \code{TRUE}. Display or silence (if \code{FALSE})
warnings and information messages helpful for troubleshooting. Ad
global default can be set via \code{options(mnirs.verbose = FALSE)}.}

\item{as_list}{Logical. Default is \code{FALSE}. If \code{nirs_channels} is specified
as a list, it will be coerced to a flat character vector and an
information message is displayed (when \code{verbose = TRUE}). If \code{TRUE},
\code{nirs_channels} is returned as-is, i.e. as a list for callers which
require it.}

\item{time_channel}{A character string naming the time or sample column.
Must match a column name in \code{data} exactly.
\itemize{
\item If \code{NULL} (default), the \code{time_channel} metadata attribute of \code{data} is
used.
}}

\item{event_channel}{A character string naming the event/lap column. Must
match a column name in \code{data} exactly.
\itemize{
\item If \code{NULL} (default), the \code{event_channel} metadata attribute of \code{data} is
used.
}}

\item{required}{Logical. Default is \code{TRUE}. \code{event_channel} must be
present or detected in metadata. If \code{FALSE}, \code{event_channel} may be \code{NULL}.}

\item{sample_rate}{A numeric sample rate in Hz.
\itemize{
\item If \code{NULL} (default), the \code{sample_rate} metadata attribute of \code{data} will
be used if detected, or the sample rate will be estimated from
\code{time_channel}.
}}
}
\value{
Returns the validated object (e.g. a resolved \code{time_channel}
string), or invisibly returns \code{NULL} for successful validations. On
failure, an error is thrown via \code{\link[cli:cli_abort]{cli::cli_abort()}}.
}
\description{
Resolve and validate \emph{{mnirs}} metadata and perform basic data quality
checks.
}
\details{
\code{validate_mnirs()} is an internal documentation topic for a set of
validators used throughout the package. These validators:
\itemize{
\item Prefer explicit user-supplied arguments.
\item Fall back to \emph{"mnirs"} metadata attributes when available.
\item Fail fast with informative \code{\link[cli:cli_abort]{cli::cli_abort()}} messages when values are
missing or invalid.
}
}
\keyword{internal}
