airPLSBaseline

src/airPLS.js

Adaptive iteratively reweighted penalized least squares [1]

This function calls ml-airpls

References: [1] Zhang, Z.-M.; Chen, S.; Liang, Y.-Z. Baseline Correction Using Adaptive Iteratively Reweighted Penalized Least Squares. Analyst 2010, 135 (5), 1138–1146. https://doi.org/10.1039/B922045C.

airPLSBaseline(ys: Array<number>, options: object?, function: any): BaselineOutput
Parameters
ys (Array<number>)
options (object? = {}) Options object
Name Description
options.x Array<number>? Optional, Independent axis variable. If not specified, we use a linear grid
options.regression object? Options for the regression
options.regression.maxIterations number (default 100) Maximum number of allowed iterations
options.regression.regressionOptions any? Options for regressionFunction
options.regression.tolerance number (default 0.001) Convergence error tolerance
function (any) §Regression = PolynomialRegression] - Regression class with a predict method
Returns
BaselineOutput:

BaselineOutput

src/index.js
BaselineOutput

Type: Object

Properties
baseline (Array<number>)
correctedSpectrum (Array<number>)

iterativePolynomialBaseline

src/iterativePolynomial.js

Iterative polynomial fitting [1]

Implementation based on ml-baseline-correction-regression

References: [1] Gan, F.; Ruan, G.; Mo, J. Baseline Correction by Improved Iterative Polynomial Fitting with Automatic Threshold. Chemometrics and Intelligent Laboratory Systems 2006, 82 (1), 59–65. https://doi.org/10.1016/j.chemolab.2005.08.009.

iterativePolynomialBaseline(ys: Array<number>, options: object?): BaselineOutput
Parameters
ys (Array<number>)
options (object? = {}) Options object
Name Description
options.x Array<number>? Optional, Independent axis variable. If not specified, we use a linear grid
options.regression Object?
options.regression.maxIterations number (default 100) Maximum number of allowed iterations
options.regression.Regression function (default PolynomialRegression) Regression class with a predict method
options.regression.regressionOptions Object? Options for regressionFunction
options.regression.tolerance number (default 0.001) Convergence error tolerance
options.regression Object?
Returns
BaselineOutput:

rollingAverageBaseline

src/rollingAverage.js
rollingAverageBaseline(ys: Array<number>, options: Object): BaselineOutput
Parameters
ys (Array<number>)
options (Object = {})
Name Description
options.window number? rolling window size, defaults to 10% of the length of the spectrum
Returns
BaselineOutput:

rollingBallBaseline

src/rollingBall.js

Rolling ball baseline correction algorithm. From the abstract of (1): "This algorithm behaves equivalently to traditional polynomial backgrounds in simple spectra, [...] and is considerably more robust for multiple overlapping peaks, rapidly varying background [...]

The baseline is the trace one gets by rolling a ball below a spectrum. Algorithm has three steps: Finding the minima in each window, find maxima among minima and then smooth over them by averaging.

Algorithm described in (1), but in the implementation here the window width does not change.

Reference: (1) Kneen, M. A.; Annegarn, H. J. Algorithm for Fitting XRF, SEM and PIXE X-Ray Spectra Backgrounds. Nuclear Instruments and Methods in Physics Research Section B: Beam Interactions with Materials and Atoms 1996, 109–110, 209–213. https://doi.org/10.1016/0168-583X(95)00908-6. (2) Kristian Hovde Liland, Bjørn-Helge Mevik, Roberto Canteri: baseline. https://cran.r-project.org/web/packages/baseline/index.html

rollingBallBaseline(ys: Array<number>, options: Object): BaselineOutput
Parameters
ys (Array<number>)
options (Object = {})
Name Description
options.windowM Number? width of local window for minimization/maximization, defaults to 4% of the spectrum length
options.windowS Number? width of local window for smoothing, defaults to 8% of the specturm length
Returns
BaselineOutput:

rollingMedianBaseline

src/rollingMedian.js
rollingMedianBaseline(ys: Array<number>, options: Object): BaselineOutput
Parameters
ys (Array<number>)
options (Object = {})
Name Description
options.window number? rolling window size, defaults to 10% of the length of the spectrum
Returns
BaselineOutput: