Lucid.Spectra.BaselineCorrection

Baseline correction removes unwanted background noise and drift, to isolate the true analytical peaks.

poly (Polynomial Fitting)

Fits a global polynomial function (e.g., 2nd to 5th degree) across the spectrum using standard linear least squares. Fast, simple, deterministic, and easy to interpret. Sensitive to peaks unless peak-free anchor regions are manually selected. Higher-degree polynomials can cause edge oscillations according to Runge’s phenomenon. Best used for simple, gently curving baselines with easily identifiable peak-free regions.

poly-iter (Iterative Polynomial Fitting)

Fits an initial polynomial, then iteratively replaces spectral points whose intensities sit above the fitted line with the fitted values themselves. Fully automated and eliminates the need to manually choose baseline anchor points. See “Automated Method for Subtraction of Fluorescence from Biological Raman Spectra”, Lieber and Mahadevan-Jansen 2003, Applied Spectroscopy.

unispline (Univariate Spline)

Fits piecewise polynomials anchored at specified regions across the dataset. Highly flexible; adapts to complex, localized baseline curvature. Heavily dependent on manual range selection. Placing ranges too close to peaks or noise features distorts the baseline. Best used for irregular or non-uniform baselines where manual range placement is feasible.

exp (Exponential Background)

Fits a exponential decay functions to the background signal. Models physical decay processes using few parameters. Restricted to model monotonic (rising and falling) baselines. Best used for Spectra with severe initial background decay like Rayleigh scattering tails, thermal emissions, or fluorescence decay at low wavenumbers/frequencies.

log (Logarithmic Background)

Fits logarithmic curves or models the baseline in log-transformed space. Captures steep initial curvature that rapidly plateaus across higher channels. Restricted to non-negative domain values and strict monotonic curvature shapes. Best used for specialized detector response curves or transmission/absorbance optical spectra showing logarithmic background behavior.

rubberband (Rubberband Baseline Fitting)

Computes the lower convex hull of the spectrum, as if stretching an elastic rubber band beneath the data’s local minima. Parameter-free, extremely fast, and guarantees the estimated baseline never exceeds the measured spectrum. Tends to jump across broad peak clusters, underestimating the baseline in dense peak regions. Best used for simple FTIR, Raman, or XRD spectra featuring sharp, isolated peaks separated by clear, flat baseline regions.

als (Asymmetric Least Squares Smoothing)

Combines a second-derivative smoothness penalty (lambda) with asymmetric weights (als_p). Points above the current baseline estimate receive very small weights, while points below receive large weights, forcing the curve underneath peaks. Fully automated, yields smooth baselines, and preserves peak shapes without manual peak detection. Requires tuning two hyperparameters (lambda for smoothness, als_p for asymmetry). Can artificially elevate under very broad overlapping peaks. Best used for smooth, continuous baseline drift. See “Baseline Correction with Asymmetric Least Squares Smoothing”, Eilers and Boelens 2005.

Parameter Tuning

Tune parameters to balance smoothness, responsiveness, peak preservation and baseline tracking.

lambda penalizes changes in the second derivative (curvature) of the baseline. Large lambda values enforce a rigid, more linear baseline and prevents the baseline from curving into broad peaks, but fails to track fast background fluctuations.Small lambda values allow the baseline to bend sharply, but risk hugging the bottom of wide peaks or fitting noise. Scale lambda to your sampling rate and range. lambda operates on the discrete index steps of your array, meaning its physical effect depends heavily on data point density. For high sampling density (many thousands of points per spectrum), increase lambda to values between 10 million and higher. For low sampling density, decrease lambda to values below 10 thousand.

Asymmetry als_p sets the penalty weight ratio between points above and below the baseline estimate. Data points above the baseline get weight als_p, while points below get weight 1 - als_p. Smaller values yield stronger peak suppression. Larger values treat positive and negative residuals more equally.appropriate for noisy signals with weak peaks.

If the baseline dips unnaturally beneath wide peak groups, increase lambda or decrease als_p. If the baseline misses rapid background humps / fluctuations, increase lambda. If the baseline cuts through the bottom of peaks, decrease als_p. If the baseline fits high-frequency noise increase lambda.

arPLS (Asymmetrically Reweighted Penalized Least Squares)

Improves upon standard ALS by replacing the fixed asymmetry factor (als_p) with an adaptive weighting function based on a logistic curve derived from the mean and standard deviation of noise residuals. Automatically ignores peak regions during weighting, eliminating the baseline elevation issue under broad overlapping peaks seen in standard ALS. Computationally more expensive due to iterative weight matrix updates. Best used for complex spectra containing broad, overlapping, or varying-width peaks on fluctuating backgrounds. See “Baseline correction using asymmetrically reweighted penalized least squares smoothing”, Baek et al. 2015, Analyst 140: 250-257.

drPLS (Doubly Reweighted Penalized Least Squares)

Extends reweighted PLS by applying dual weighting: one weight set for peak suppression (asymmetric weighting) and a second weight set based on the first derivative of the signal to protect baseline fidelity along steep gradients. Excellent tracking performance on highly sloped or rapidly shifting backgrounds. Higher computational complexity and additional tuning parameters. Best used for severe baseline conditions, such as high-background Raman imaging. See “Baseline correction method based on doubly reweighted penalized least squares”, Xu et al., Applied Optics 58(14):3913-3920.