Baselinew: Difference between revisions

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search
imported>Neal
imported>Jeremy
 
(10 intermediate revisions by 3 users not shown)
Line 9: Line 9:
===Description===
===Description===


BASELINEW fits a polynomial "baseline" to the bottom (or top) of a curve (e.g. a spectrum) by recursively calling LSQ2TOP. It can be called to use or not use a windowed approach and can be considered a filter or baseline (low frequency) removal algorithm. The window width required depends on the frequency of the low frequency component (baseline). Wide windows and low order polynomials are often used. See LSQ2TOP for more details on the polynomial fit algorithm.
BASELINEW fits a polynomial "baseline" to the bottom (or top) of a curve (e.g., a spectrum) by recursively calling LSQ2TOP. It can be called to use or not use a windowed approach and can be considered a filter or baseline (low frequency) removal algorithm. The window width required depends on the frequency of the low frequency component (baseline). Wide windows and low order polynomials are often used. See LSQ2TOP for more details on the polynomial fit algorithm.


Inputs include the curve(s) to be fit (dependent variable) y, the axis to fit against (the independent variable) x [e.g. y = P(x)], the window width width (an odd integer), the polynomial order order, and an approximate noise level in the curve res. Note that y can be ''M''x''N'' where x is ''1''x''N''. The optional input options is discussed below.
the polynomial order order, and an approximate noise level in the curve res. Note that y can be ''M''x''N'' where x is ''1''x''N''.  


Output y_b is a ''M''x''N'' matrix of ROW vectors that have had the baselines removed, and output b_b is a matrix of baselines. Therefore, y_b is the high frequency component and b_b is the low frequency component.
Output y_b is a ''M''x''N'' matrix of ROW vectors that have had the baselines removed, and output b_b is a matrix of baselines. Therefore, y_b is the high frequency component and b_b is the low frequency component.


====Inputs====
INPUTS


* '''y''' = matrix of ROW vectors to be baselined, MxN [class double].
:y = matrix of ROW vectors to be baselined, ''M''x''N'' [class double].


* '''x''' = axis scale, 1xN vector {if empty it is set to 1:N}.
:x = axis scale, 1x''N'' vector {if empty it is set to 1:N}. It is the axis to fit against [the independent variable] x [e.g., y = P(x)].


* '''width''' = window width specifying the number of points in the filter {if (width) is empty no windowing is used}.
:width = window width specifying the number of points in the filter (an odd integer). If (width) is empty [ ] no windowing is used.


* '''order''' = order of polynomial [scalar] to fit {if (order) is empty (options.p) must not be empty; see below}.
:order = order of polynomial [scalar] to fit. If (order) is empty (options.p) must not be empty (see below).


* '''res''' = approximate fit residual [scalar] {if empty it is set to 5Found of fit of all data to x}.
:res = approximate fit residual [scalar]. If empty it is set to 5% of the fit of all data to (x).


===Examples===
The optional input (''options'') is discussed below.
 
===Options===
 
options  = structure array with the following fields:
 
*'''display''' :  [ 'off' | {'on'} ] governs level of display to command window.
 
*'''p''': [ ], if not empty, (options.p) is a NxK matrix of basis vectors and it supersedes input (order).
 
*'''smooth''': [], if >0 this adds smoothing by adding a penalty to the magnitude of the 2nd derivative. (empty or <=0 means no smooth)


If y is a 5 by 100 matrix then


:y_b = baselinew(y,[],25,3,0.01);
*'''trbflag''' : [ 'top' | {'bottom'} ] top or bottom flag, tells algorithm to fit the polynomials, y = P(x), to the top or bottom of the data cloud.


gives a 5 by 100 matrix y_b of row vectors that have had the baseline removed using a 25-point cubic polynomial fit of each row of y.
*'''tsqlim''': [ 0.99 ] limit that governs whether a data point is significantly outside the fit residual defined by input (res).


If y is a 2 by 100 matrix then
*'''stopcrit''': [1e-4 1e-4 1000 360] stopping criteria, iteration is continued until one of the stopping criterion is met: [(relative tolerance) (absolute tolerance) (maximum number of iterations) (maximum time [seconds])].


:y_b = baselinew(y,x,51,3,0.01);
*'''initwt''': []; empty or 1xN vector of initial weights (0<=w<=1).


gives a 2 by 100 matrix y_b of row vectors that have had the baseline removed using a 51-point second order polynomial fit of each row of y to x.
===Examples===


===Options===
If (y) is a 5 by 100 matrix then


* '''options'''  = structure array with the following fields:
:y_b = baselinew(y,[],25,3,0.01);


* '''display''' :  [ 'off' | {'on'} ] governs level of display to command window.
gives a 5 by 100 matrix (y_b) of row vectors that have had the baseline removed using a 25-point cubic polynomial fit of each row of (y).


* '''trbflag''' : [ 'top' | {'bottom'} ] top or bottom flag, tells algorithm to fit the polynomials, y = P(x), to the top or bottom of the data cloud.
If (y) is a 2 by 100 matrix then


* '''tsqlim''': [ 0.99 ] limit that governs whether a data point is significantly outside the fit residual defined by input res.
:y_b = baselinew(y,x,51,3,0.01);


* '''stopcrit''': [1e-4 1e-4 1000 360] stopping criteria, iteration is continued until one of the stopping criterion is met: [(relative tolerance) (absolute tolerance) (maximum number of iterations) (maximum time [seconds])].
gives a 2 by 100 matrix (y_b) of row vectors that have had the baseline removed using a 51-point second order polynomial fit of each row of (y) to (x).


===See Also===
===See Also===


[[baseline]], [[lamsel]], [[lsq2top]], [[mscorr]], [[savgol]], [[stdfir]], [[wlsbaseline]]
[[baseline]], [[lamsel]], [[lsq2top]], [[lsq2topb]], [[mscorr]], [[savgol]], [[stdfir]], [[wlsbaseline]]

Latest revision as of 15:13, 9 June 2014

Purpose

Baseline using windowed (and non-windowed) polynomial filter.

Synopsis

[y_b,b_b]= baselinew(y,x,width,order,res,options)

Description

BASELINEW fits a polynomial "baseline" to the bottom (or top) of a curve (e.g., a spectrum) by recursively calling LSQ2TOP. It can be called to use or not use a windowed approach and can be considered a filter or baseline (low frequency) removal algorithm. The window width required depends on the frequency of the low frequency component (baseline). Wide windows and low order polynomials are often used. See LSQ2TOP for more details on the polynomial fit algorithm.

the polynomial order order, and an approximate noise level in the curve res. Note that y can be MxN where x is 1xN.

Output y_b is a MxN matrix of ROW vectors that have had the baselines removed, and output b_b is a matrix of baselines. Therefore, y_b is the high frequency component and b_b is the low frequency component.

INPUTS

y = matrix of ROW vectors to be baselined, MxN [class double].
x = axis scale, 1xN vector {if empty it is set to 1:N}. It is the axis to fit against [the independent variable] x [e.g., y = P(x)].
width = window width specifying the number of points in the filter (an odd integer). If (width) is empty [ ] no windowing is used.
order = order of polynomial [scalar] to fit. If (order) is empty (options.p) must not be empty (see below).
res = approximate fit residual [scalar]. If empty it is set to 5% of the fit of all data to (x).

The optional input (options) is discussed below.

Options

options = structure array with the following fields:

  • display : [ 'off' | {'on'} ] governs level of display to command window.
  • p: [ ], if not empty, (options.p) is a NxK matrix of basis vectors and it supersedes input (order).
  • smooth: [], if >0 this adds smoothing by adding a penalty to the magnitude of the 2nd derivative. (empty or <=0 means no smooth)


  • trbflag : [ 'top' | {'bottom'} ] top or bottom flag, tells algorithm to fit the polynomials, y = P(x), to the top or bottom of the data cloud.
  • tsqlim: [ 0.99 ] limit that governs whether a data point is significantly outside the fit residual defined by input (res).
  • stopcrit: [1e-4 1e-4 1000 360] stopping criteria, iteration is continued until one of the stopping criterion is met: [(relative tolerance) (absolute tolerance) (maximum number of iterations) (maximum time [seconds])].
  • initwt: []; empty or 1xN vector of initial weights (0<=w<=1).

Examples

If (y) is a 5 by 100 matrix then

y_b = baselinew(y,[],25,3,0.01);

gives a 5 by 100 matrix (y_b) of row vectors that have had the baseline removed using a 25-point cubic polynomial fit of each row of (y).

If (y) is a 2 by 100 matrix then

y_b = baselinew(y,x,51,3,0.01);

gives a 2 by 100 matrix (y_b) of row vectors that have had the baseline removed using a 51-point second order polynomial fit of each row of (y) to (x).

See Also

baseline, lamsel, lsq2top, lsq2topb, mscorr, savgol, stdfir, wlsbaseline