The Role of Preprocessing in Chemometrics
Near-infrared (NIR) spectra, particularly chemical and pharmaceutical spectra, are highly complex, often characterized by overlapping absorption bands, baseline offsets, and high-frequency noise. Before fitting quantitative calibration models (like PLS regression), chemometricians must preprocess the raw spectral data. The goal is to strip away physical artifacts—such as scattering from different particle sizes or baseline shifts from changes in light path length—while preserving the chemical signals of interest.
Among the tools in the preprocessing arsenal, the **Savitzky-Golay (SG) algorithm** is the industry standard for smoothing and differentiation. Developed in 1964 by Abraham Savitzky and Marcel J. E. Golay, it remains the foundation of modern chemometric data pipelines.
"Unlike standard moving-average filters which blur spectral features, Savitzky-Golay filtering preserves peak heights, widths, and local shapes by fitting local low-degree polynomials to the data."
How the Savitzky-Golay Algorithm Works
The core concept is to slide a window of a fixed number of data points ($w$, which must be an odd integer) across the spectrum. At each step, a polynomial of degree $k$ (usually $k = 2$ or $3$, representing quadratic or cubic models) is fitted to the data points within the window using linear least squares. The value of the fitted polynomial at the center point of the window becomes the new, smoothed value for that wavelength.
Because the least-squares fitting coefficients depend only on the window size $w$ and polynomial degree $k$, they can be pre-calculated as fixed weights (known as convolutions). This makes the SG filter extremely fast to compute, even for thousands of long spectra.
Derivatives and Baseline Correction
One of the most powerful features of the Savitzky-Golay method is its ability to compute numerical derivatives during the smoothing process. Derivatives are highly effective at correcting baseline offsets and resolving overlapping peaks:
- First Derivative (SG 1st): Removes constant baseline offsets (shifts along the Y-axis) and highlights changes in slope.
- Second Derivative (SG 2nd): Removes linear baseline drift (slopes along the spectrum) and isolates overlapping features. In a second derivative spectrum, absorption peaks appear as downward-pointing troughs, making them easier to identify.
Parameter Selection Guidelines
Setting the correct parameters is crucial to prevent either under-smoothing (retaining noise) or over-smoothing (destroying real peak resolution). The table below outlines standard recommendations based on spectrometer resolution:
| Parameter Set | Window Size ($w$) | Polynomial Order ($k$) | Recommended Application |
|---|---|---|---|
| Mild Smoothing | 5 or 7 points | 2 (Quadratic) | High-resolution gas phase NIR, low-noise systems |
| Standard Baseline Correction | 15 points | 2 (Quadratic, 1st Deriv) | Typical liquid chemical processes, moisture in powders |
| Deep Separation | 25 points | 3 (Cubic, 2nd Deriv) | Highly heterogeneous solids (feed meals, forage crops) |
Implementing SG in the caliX Suite
In the caliX Suite software preprocessing pipeline, the SG algorithm is applied automatically during AutoML model validation. Users can configure the window size and derivative orders in the preprocessing editor, watching the cross-validation error (RMSECV) update in real-time as different settings are tested. This interactive feedback loop guarantees that you choose the mathematical preprocessing parameters that maximize model accuracy and units-to-unit transferability.
References
- Savitzky, A., & Golay, M. J. E. (1964). "Smoothing and Differentiation of Data by Simplified Least Squares Procedures," Analytical Chemistry, 36(8), 1627-1639.
- "Wavelength Selection and Noise Filtering in NIR Spectra using Polynomial Derivatives," Chemometrics and Intelligent Laboratory Systems, 2019.
- "Baseline Correction Protocols for Industrial Process Spectrometers," Applied Spectroscopy Reviews, 2021.