% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/preproc_alignSegment.R
\name{align_segment}
\alias{align_segment}
\title{Align NMR Spectra in a Selected Shift Region}
\usage{
align_segment(
  dat,
  shift,
  idx_ref = 1,
  med = TRUE,
  clim = 0.7,
  norm = FALSE,
  lag.max = 20
)
}
\arguments{
\item{dat}{Named list with elements:
\describe{
\item{X}{Numeric matrix (spectra in rows)}
\item{ppm}{Numeric vector of chemical shift values}
\item{meta}{Optional metadata}
}}

\item{shift}{Numeric vector of length 2 specifying ppm region to align.}

\item{idx_ref}{Integer. Row index to use as reference spectrum.}

\item{med}{Logical. Use row-wise median spectrum as reference?}

\item{clim}{Numeric. Minimum correlation threshold.}

\item{norm}{Logical. Z-scale before alignment.}

\item{lag.max}{Integer. Maximum lag allowed.}
}
\value{
Updated \code{dat} list with aligned spectra in selected region.
}
\description{
Aligns spectra within a specified ppm window using cross-correlation.
Only the selected region is aligned; the remainder of the spectra
is unchanged.
}
\examples{
data(hiit_raw)
plot_spec(hiit_raw, shift=c(1.3,1.4))
hiit_aligned <- align_segment(hiit_raw, c(1.3, 1.35))
plot_spec(hiit_aligned, shift=c(1.3,1.4)) # aligned segment
plot_spec(hiit_aligned, shift=c(3, 3.1)) # segment not aligned
}
\seealso{
Other preprocessing: 
\code{\link{align_spectra}()},
\code{\link{binning}()},
\code{\link{calibrate}()},
\code{\link{correct_baseline}()},
\code{\link{correct_lw}()},
\code{\link{pqn}()},
\code{\link{print_preprocessing}()}
}
\concept{preprocessing}
