Baseline
Purpose
Subtracts a baseline offset from spectra.
Synopsis
- [newspec,b,range] = baseline(spec,freqs,range,options);
- spec = baseline(newspec,freqs,b,options);
Description
This function baselines spectra with a polynomial baseline function. The baseline function is fit to user-specified regions (regions free of peaks), which is then subtracted from the original spectra.
Inputs are (spec) class "double" or "dataset" containing the spectra, (freqs) the wavenumber or frequency axis vector, and (range) which specifies the baselining regions (see below). If (freqs) is omitted and (spec) is a dataset, the axissscale from the dataset will be used; otherwise a linear vector will be used.
(range) can be either an M by 2 matrix which specifies M baselining regions or a logical vector equal in length to the spectra with a 1 (one) at each point to be used as baseline and 0 (zero) elsewhere.
The output (newspec) contains the baselined spectra, (b) the polynomial coefficients, and (range) the baseline regions used as a vector of indices.
If (b) is input instead of (range) with baselined spectra (newspec) then the output (spec) is a matrix of original "unbaselined" spectra.
Inputs
- spec = is the spectra to be baselined, can be either of type "double" or class "dataset".
- freqs = is the wavenumber or frequency axis vector {Default: taken from dataset axisscale or a linear vector}.
- range = is the baseline regions which is either:
- A logical vector (1 by size(spec,2) with a true value at each point to use as baseline and false otherwise {default = logical(ones(1,size(spec,2)) which uses all points for baseline subtraction. Default is same as 'detrending'}.
- A vector of indices to use as baseline.
- An empty vector meaning use all points as baseline (same as a "detrend" operation).
- An m by 2 matrix specifying baseline regions as start/end pairs of indices: [ start_1, end_1; start_2, end_2 ].
- A scalar infinite value meaning:
- -inf = set baseline to the minimum value in each spectrum.
- inf = set baseline to the maximum value in each spectrum.
Outputs
- newspec = is a matrix or dataset of baselined spectra.
- b = is a matrix of regression coefficients. If (b) is passed in place of (range) along with (newspec), a baseline operation can be "undone".
- range = is baseline regions used as a vector of indices.
Options
options = a structure array with the following fields:
- plots: [ {'none'} | 'final' ] governs plotting of results.
- order: positive integer for polynomial order {default = 1}.
The default options can be retreived using: options = baseline('options');.
See Also
baselinew, deresolv, lamsel, lsq2top, med2top,normaliz, polyinterp, savgol, savgolcv, specedit, stdgen, wlsbaseline