Signal Processing

Baseline Correction Methods: Polynomials, SNIP, and Asymmetric Least Squares

ENGPublished July 22, 2026 · 7 min read

In analytical sciences (like Raman spectroscopy, mass spectrometry, and chromatography), baseline drift is a common experimental artifact. It can be caused by fluorescence, detector heating, or sample carrier emissions. To compare peak heights or calculate areas under curves, we must first correct the baseline.

1. Polynomial Baseline Fitting

This is the simplest method. The user selects several points in the peak-free regions, and a polynomial of degree d (typically 2 to 5) is fitted to these points.

  • Pros: Fast, intuitive, easy to implement.
  • Cons: Prone to Runge's phenomenon (wild oscillations at boundaries) and highly sensitive to user point selection.

2. SNIP (Statistics-Sensitive Non-Linear Iterative Peak-Clipping)

SNIP works by iteratively comparing each data point y(i) with the average of its m-step distant neighbors (y(i-m) + y(i+m)) / 2, gradually increasing the window radius m up to a maximum index M. If a point exceeds the local baseline average, it is clipped down. Over iterations, sharp spectral peaks are clipped away, leaving only the underlying baseline envelope.

  • Pros: Fully automatic, requires no manual anchor selection.
  • Cons: Can smooth out broad, overlapping peaks if the iteration count is set incorrectly.

3. Asymmetric Least Squares (ALS)

ALS is a state-of-the-art smoothing algorithm that penalizes baseline points differently depending on whether they lie above or below the signal envelope. It minimizes a cost function balancing smoothness and asymmetry:

$$S = \sum_{i} w_i (y_i - z_i)^2 + \lambda \sum_{i} (\Delta^2 z_i)^2$$

Where y is the raw signal, z is the calculated baseline, and λ (lambda) is the smoothness penalty parameter (larger values yield a stiffer baseline). The asymmetric weight wᵢ is defined as:

$$w_i = \begin{cases} p & \text{if } y_i > z_i \\ 1 - p & \text{if } y_i \le z_i \end{cases}$$

Typically, the asymmetry parameter p is set very small (e.g., 0.001) so data points above the baseline (the peaks) receive near-zero weight, while points below the baseline are strongly penalized to force the baseline underneath the signal.


The AltaiPlot Advantage: Real-time Baseline Tuning

Writing loops in Python to tune the ALS stiffness parameter λ or the asymmetry p is tedious because you cannot see the baseline overlay until the script finishes running. AltaiPlot changes this with the BaselineWizard:

  • Interactive Sliders: Move the stiffness (λ), asymmetry (p), and iteration count sliders and watch the baseline overlay adjust instantly on the chart via live canvas preview.
  • Algorithm Presets: Quick-select presets for common use cases — "XRD/Raman" (AsLS with λ=10⁵, p=0.01), "Strong BG" (λ=10⁴), "Rolling Ball", "SNIP", or "Polynomial".
  • One-Click Subtraction: Once the baseline looks perfect, click "Apply" to instantly subtract it from your active dataset. No coding, no trial-and-error scripts.
  • Multiple Algorithms: Choose from Asymmetric Least Squares (AsLS), AirPLS (auto-scaling), Rolling Ball (morphological opening), SNIP (peak clipping), Polynomial fit, or Linear — all with the same interactive interface.