IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
pre_bc_asls.m
Go to the documentation of this file.
1 %> @brief Asymmetric Least-Squares Baseline Correction
2 %>
3 %> you can vary the values of 'lambda' and 'p' to see the effect on
4 %> smoothness, also the base line
5 %>
6 %> <h3>Reference:</h3>
7 %> Baseline Correction with Asymmetric Least Squares Smoothing. Paul H. C. Eilers, Hans F.M. Boelens. October 21, 2005
8 %>
9 %> @sa uip_pre_bc_asls.m
10 classdef pre_bc_asls < pre_bc
11  properties
12  %> =0.001. Recommended: 0.001 <= @p p <= 0.1
13  p = 0.001;
14  %> =1e5. Recommended: 10^2 <= @p lambda <= 10^9
15  lambda = 1e5;
16  %> =10
17  no_iterations = 10;
18  end;
19 
20 
21  methods
22  function o = pre_bc_asls(o)
23  o.classtitle = 'Asymmetric Least-Squares Smoothing';
24  o.short = 'BCALSM';
25  end;
26  end;
27 
28  methods(Access=protected)
29 
30 
31  %> Applies block to dataset
32  function data = go_use(o, data)
33  X = data.X;
34 
35  for j = 1:data.no
36  aa = X(j, :)';
37 
38  %> Estimate baseline with asymmetric least squares
39  m = length(aa);
40  D = diff(speye(m), 2);
41  w = ones(m, 1);
42 
43  for it = 1:o.no_iterations
44  W = spdiags(w, 0, m, m);
45  C = chol(W + o.lambda * D' * D);
46  z = C \ (C' \ (w .* aa));
47  w = o.p * (aa > z) + (1 - o.p)*(aa < z);
48  end
49 
50  X(j,:) = aa-z;
51  end
52 
53  data.X = X;
54  end;
55  end;
56 end
Base Block class.
Definition: block.m:2
Baseline Correction base class.
Definition: pre_bc.m:2
Asymmetric Least-Squares Baseline Correction.
Definition: pre_bc_asls.m:10