% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/preproc_calibrate.R
\name{calibrate}
\alias{calibrate}
\title{Chemical Shift Calibration}
\usage{
calibrate(X, ppm = NULL, type = "tsp")
}
\arguments{
\item{X}{Numeric matrix/vector of spectra or a metabom8 data list.}

\item{ppm}{Numeric chemical shift vector. If \code{X} is a metabom8 list,
this is taken from \code{X$ppm}.}

\item{type}{Character (\code{"tsp"}, \code{"glucose"}, \code{"alanine"}),
or list.}
}
\value{
Calibrated spectra in the same structure as input.
}
\description{
Aligns 1D \eqn{^1}H NMR spectra to a reference signal on the existing ppm grid.
Supports singlet (e.g. TSP or custom range) and predefined doublet references
(glucose, alanine).
}
\details{
In addition to predefined references, custom calibration targets can be supplied
as a list with elements:
\itemize{
\item \code{mode}: \code{"singlet"} or \code{"doublet"}
\item \code{window}: numeric vector of length 2 defining the ppm search region
\item \code{centre}: target ppm position (optional; defaults to mean(window))
\item \code{j}: numeric vector of length 2 specifying expected J-coupling
(required for doublet calibration)
}
Custom doublet calibration requires the expected J-coupling range (\code{j})
in ppm to distinguish the two peaks of the multiplet.

For example:
\preformatted{
calibrate(
  X, ppm,
  list(
    mode   = "doublet",
    window = c(1.2, 1.35),
    j      = c(0.007, 0.009)
  )
)
}
}
\examples{
data("covid_raw")
X=covid_raw$X
ppm=covid_raw$ppm
X_tsp <- calibrate(X, ppm, type = "tsp")
X_glu <- calibrate(X, ppm, type = "glucose")
X_custom <- calibrate(X, ppm, type = c(1.9, 2.1))
}
\seealso{
Other preprocessing: 
\code{\link{align_segment}()},
\code{\link{align_spectra}()},
\code{\link{binning}()},
\code{\link{correct_baseline}()},
\code{\link{correct_lw}()},
\code{\link{pqn}()},
\code{\link{print_preprocessing}()}
}
\concept{preprocessing}
