Skip to contents

Non-linear baseline correction for NMR spectra based on asymmetric least squares. This function estimates a smooth, non-linear baseline trend for each spectrum. The estimated baseline is then subtracted, returning the corrected spectrum. See asysm for more information on the smoothing parameter lambda.

Usage

bline(X, lambda = 1e+07, iter_max = 30)

bcor(X, lambda = 1e+07, iter_max = 30)

Arguments

X

Numeric matrix or data frame. NMR data with spectra in rows.

lambda

Numeric. Smoothing parameter passed to asysm. Larger values result in smoother baselines.

iter_max

Integer. Maximum number of iterations for the baseline estimation algorithm.

Value

A numeric matrix of the same dimensions as the input, containing the baseline-corrected spectra.

Details

Missing values in X are replaced with zeros before baseline correction.

See also

Examples

data(covid_raw)
X <- covid_raw$X
ppm <- covid_raw$ppm
X_bc <- bcor(X[1, ])

spec(X[1, ], ppm, shift = c(3, 4), interactive = FALSE)
spec(X_bc[1, ], ppm, shift = c(3, 4), col='red', add = TRUE, interactive = FALSE)