Baselinew

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search

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