% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/features_ppick.R
\name{ppick}
\alias{ppick}
\title{Find Local Extrema in NMR Spectra (Peak Picking)}
\usage{
ppick(X, ppm, fil_p = 3, fil_n = 5, type = "max")
}
\arguments{
\item{X}{Numeric matrix. NMR data with spectra in rows and chemical shifts in columns.}

\item{ppm}{Numeric vector. Chemical shift values corresponding to columns in \code{X}.}

\item{fil_p}{Integer. Polynomial order of the Savitzky–Golay filter.}

\item{fil_n}{Integer. Filter length (must be odd) of the Savitzky–Golay filter.}

\item{type}{Character. Type of extrema to return: \code{"max"}, \code{"min"}, or \code{"both"}.}
}
\value{
A list of data frames, one per spectrum. Each data frame contains:
\itemize{
\item \code{idc}: Index of the detected peak.
\item \code{ppm}: Chemical shift at the peak.
\item \code{Int}: Intensity at the peak.
\item \code{Etype}: Extrema type: \code{1} for minima, \code{-1} for maxima.
}
}
\description{
Identifies local maxima, minima, or both from smoothed NMR spectra using Savitzky–Golay filtering.
}
\details{
The spectra are smoothed using a Savitzky–Golay filter to reduce noise. Extrema are then detected by identifying sign changes in the first derivative of the smoothed signal.
}
\examples{
data(covid)
X <- covid$X
ppm <- covid$ppm

peaklist <- ppick(X, ppm)
plot_spec(X[1, ], ppm, shift = c(1.2, 1.4), backend='base')
points(peaklist[[1]]$ppm, peaklist[[1]]$Int, col = 'cyan')

}
\seealso{
\code{\link{ppick2}}
}
