2.5 Baseline with Asymmetric Least Squares (Pro)Baseline-with-ALS
Summary
The tool Baseline with Asymmetric Least Squares can be used to find baseline using asymmetric least squares smoothing (ALS) method.
Examples
This tool requires OriginPro. It can be used as an X-Function dialog, or as a theme in Peak Analyzer.
Use as X-Function Dialog
This example shows how to find baseline using X-Function.
Steps
- Open a new workbook. Click the Import Single ASCII button , select the file Raman Baseline.dat in Origin installation folder \\Samples\Spectroscopy.
- Highlight column B, click the Baseline with ALS Method button . In the opened dialog, set Threshold 0.02, Smoothing Factor 5.5, and click Preview button. The preview graph will look like as below:
- Click OK button, and two columns for baseline data will be created.
Use as Theme in Peak Analyzer
This example shows how to find baseline using ALS method in Peak Analyzer.
Steps
- Use same data in the above example. Highlight column B, and select Analysis: Peaks and Baseline: Peak Analyzer from Origin menu. Click right button on the right of Dialog Theme in the dialog, and choose ALS Baseline.
- Click Next button. In the Baseline Mode page, LabTalk script is used to call baseline_als X-Function in Before Formula Script box in the theme. Parameters for baseline_als X-function can be adjusted in Before Formula Script box.
- Click Next button twice, and click Finish button. Four columns for baseline data and baseline subtracted data will be created.
| You can also use this theme or custom a theme in Peak Analyzer for batch analysis if your data have similar baselines.
|
Detect Baseline with Asymmetric Least Squares Smoothing Method Dialog Box
Input Data
Select data to find baseline.
Settings
Specify parameters for Asymmetric Least Squares Smoothing (ALS) method.
Asymmetric Factor [0-1]
|
Specify weight of points above the baseline in each iteration.
For positive peaks it should be close to 0, and close to 1 for negative peaks. The asymmetric factor must be between 0 and 1.
The smaller the asymmetric factor is, the less effect points above the baseline have on baseline in next iteration.
|
Threshold (%)
|
Specify the threshold to determine points above the baseline (for positive peaks) or below the baseline (for negative peaks).
The threshold is defined by the ratio of a critical distance of point to baseline to that of peak to baseline. A point whose distance to baseline is greater than the threshold will be considered above the baseline (for positive peaks). And the threshold must be between 0 and 1 (not equal to 1).
The smaller the threshold is, the more points above the baseline (for positive peaks) will be excluded to determine the baseline in next iteration.
|
Smoothing Factor
|
Specify the smoothness of the baseline.
The smoothing factor must be greater than 0, and the typical value is 2 and 9.
The larger the smoothing factor is, the smoother the baseline will be.
|
Number of Iterations
|
Specify number of iterations.
The typical value is 10. In each iteration, it will find a baseline, and determine which points will be considered as points above the baseline for next iteration.
|
Baseline
Specify whether to output baseline and columns for baseline output.
Baseline Subtracted
Specify whether to output baseline subtracted data and columns for output.
Preview
Auto Preview
|
Specify whether to auto preview once settings are changed.
|
Preview
|
Click it to update the preview manually.
|
Show/Hide Preview
|
Specify whether to show preview panel.
|
baseline_als X-Function (Pro)
Command Line Usage
- baseline_als iy:=2 loglam:=5;
- baseline_als iy:=2 loglam:=5 oy:=<optional> oys:=<new>;
Variables
Display Name
|
Variable Name
|
I/O and Type
|
Default Value
|
Description
|
Input Data
|
iy
|
Input
XYRange
|
<active>
|
Select data to find baseline.
|
Asymmetric Factor [0-1]
|
p
|
Input
double
|
1e-3
|
Specify weight of points above the baseline in each iteration.
|
Threshold (%)
|
th
|
Input
double
|
0.05
|
Specify the threshold to determine points above the baseline (for positive peaks) or below the baseline (for negative peaks).
|
Smoothing Factor
|
loglam
|
Input
double
|
4
|
Specify the smoothness of the baseline.
|
Number of Iterations
|
iter
|
Input
int
|
10
|
Specify number of iterations.
|
Baseline
|
oy
|
Output
XYRange
|
<new>
|
Specify columns for baseline output.
|
Baseline Substracted
|
oys
|
Output
XYRange
|
<new>
|
Specify columns for baseline subtracted data.
|
Algorithm
Asymmetric least squares smoothing (ALS) method is used to find the baseline so that:
- Baseline is smooth.
- Baseline is faithful to the original curve.
It is implemented by minimizing the sum of two terms: distances between points and baseline, 2nd derivatives of baseline. The sum can be expressed as:
where y is original data, is calculated baseline, is weight for each point, is a factor to balance the residual and the 2nd derivative, and smoothing factor in X-Function is the log of this value.
Iteration procedures are introduced as below:
- In the first iteration, is used, and once baseline is calculated, asymmetric factor p will be applied on points above baseline (for positive peaks) as the weight, and weight for remaining points is 1-p.
- In the next iteration, use calculated weights in the last iteration to calculate the new baseline and update weight.
- Repeat the above procedure until the specified number of iterations reaches.
Reference
- P.H.C. Eilers and H.F.M. Boelens. Baseline correction with asymmetric least squares smoothing, Leiden University Medical Centre Report, 2005.
|