Emscorr: Difference between revisions

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search
imported>Scott
No edit summary
imported>Neal
No edit summary
Line 5: Line 5:
===Synopsis===
===Synopsis===


:[sx,fx,xref,reg,res] = emscorr(x,xref,options)
:[sx,fx,xref,reg,res] = emscorr(x,''xref'',''options'')


===Description===
===Description===


EMSCORR attempts to remove additive and multiplicative scattering effects in spectra. This can be thought of as a filter where some portions of the signal are passed and some are rejected. The input <tt>x</tt> is a MxN matrix (class "double") of M spectra measured at N channels. Each row of <tt>x</tt> is regressed against input <tt>xref</tt> and the results are used to 'correct' <tt>x</tt>. If <tt>xref</tt> is not input then <tt>mean(x)</tt> is used.
EMSCORR attempts to remove additive and multiplicative scattering effects in spectra. This can be thought of as a filter where some portions of the signal are passed and some are rejected. Each row of input (x) is regressed against input (''xref'') and the results are used to "correct" (x). If (''xref'') is not input then <tt>mean(x)</tt> is used.


There are several options to allow for weighted least squares (i.e. to de-weight channels that should not be included in the regression), including different spectra that should be filtered out, and including spectra that should not be filtered out.
There are several options to allow for weighted least squares (i.e., to de-weight channels that should not be included in the regression), for using different spectra to be filtered out, and for using spectra not to filtered out.
 
The outputs are <tt>sx</tt> the corrected spectra, <tt>fx</tt> the signal that was filtered out, and <tt>xref</tt> the reference spectrum. Outputs <tt>reg</tt> are the regression coefficients and <tt>res</tt> is a MxN matrix of residuals. For non-windowed filtering, <tt>reg</tt> is [number of coefficients] x M. The number of coefficients corresponds to the number of basis vectors included in the correction. The coefficients are ordered according to the following basis: <tt>xbase = [xref, 1 x x2 ..., options.p, options.s]</tt>. If a windowed filter is used, <tt>reg</tt> is [number of coefficients] x N x M. where mode 2 corresponds to the windows.


====Inputs====
====Inputs====
* '''first''' = first input is this.
:x = is a ''M''x''N'' matrix (class "double") of ''M'' spectra measured at ''N'' channels.  


====Optional Inputs====
====Optional Inputs====
* '''second''' = optional second input is this.
:''xref'' = 1x''N'' reference spectrum to regress against. If not input, <tt>mean(x)</tt> is used.
:''options'' = structure array with the following fields:
::order: [ {2} ]  Order of the polynomial filter (positive integer).
::logax: [ {'no'} | 'yes' ]  Use the log of the axisscale, <tt>x.axisscale{2}</tt> as a basis vector to regress against. If the axisscale is not present <tt>log(1:N)</tt> is used. When (options.logax) is used, (options.order) is typically set to zero.
::s: [ ]  ''K''x''N'' spectra to not filter out.
::p: [ ]  ''Kp''x''N'' spectra to filter out.
::algorithm: [ {'cls'} | 'ils' ]  Governs correction model method.
:::'cls' uses Classical Least Squares i.e., EMSC.
:::'ils' uses Inverse Least Squares i.e., EISC.
::win: [ ]  An odd scalar that defines the window width (number of variables) for piece-wise correction. If empty {the default} piece-wise is not used. Note that piece-wise correction can be slow.
::initwt: [ ]  Empty or ''N''x1 vector of initial weights (0<=w<=1). Low weights are used for channels not to be included in the fit.
::condnum: [1e6]  Maximum condition number for <tt>'''Z''''*'''Z''''</tt> used in the least squares estimates (see Algorithm).
::xrefS: [{'no'} | 'yes']  Indicates whether input (xref) includes spectra contained in (options.s). If <tt>'yes'</tt> then the spectra in (options.s) are centered and an SVD estimate of (options.s) is used in EMSCORR.
      robust: [{'none'} | 'lsq2top' ] Governs the use of robust least squares
                if 'lsq2top' is used then "trbflag", "tsqlim", and "stopcrit" are
                also used (see LSQ2TOP for descriptions of these fields).
          res: [] Scalar (required with "lsq2top") this is input (res) to
                the LSQ2TOP function.  
      trbflag: [ 'top' | 'bottom' | {'middle'}] Used only with lsq2top.
      tsqlim: [ 0.99 ] Used only with lsq2top.
    stopcrit: [1e-4 1e-4 1000 360] Used only with lsq2top.
    axisscale: [] 1 by N axis scale for the spectral mode, if empty [1:N] is used.
          mag: [ {'yes'} | 'no' ], performs slope correction when set to 'yes'


====Outputs====
====Outputs====
* '''firstout''' = first output is this.
:sx = the corrected spectra.
:fx = the signal that was filtered out.
:xref = the reference spectrum.
:reg = the regression coefficients. For non-windowed filtering, (reg) is [number of coefficients] x ''M''. The number of coefficients corresponds to the number of basis vectors included in the correction. The coefficients are ordered according to the following: <tt>xbase = [xref, 1 x x2 ..., options.p, options.s]</tt>. If a windowed filter is used, (reg) is [number of coefficients] x ''N'' x ''M'' where mode 2 corresponds to the windows.
:res = ''M''x''N'' matrix of residuals.


===Algorithm===
===Algorithm===
===Options===
options =  a structure array with the following fields:
* '''plots''': [ {'none'} | 'final' ] governs plotting of results, and
* '''order''': positive integer for polynomial order {default = 1}.


===Example===
===Example===
Line 42: Line 59:
===See Also===
===See Also===


[[baselinew]], [[deresolv]]
[[baselinew]], [[deresolv]], [[


[[Category:EMSC_Toolbox]]
[[Category:EMSC_Toolbox]]

Revision as of 11:20, 16 October 2008

Purpose

Extended multiplicative scatter correction (EMSC) preprocessing.

Synopsis

[sx,fx,xref,reg,res] = emscorr(x,xref,options)

Description

EMSCORR attempts to remove additive and multiplicative scattering effects in spectra. This can be thought of as a filter where some portions of the signal are passed and some are rejected. Each row of input (x) is regressed against input (xref) and the results are used to "correct" (x). If (xref) is not input then mean(x) is used.

There are several options to allow for weighted least squares (i.e., to de-weight channels that should not be included in the regression), for using different spectra to be filtered out, and for using spectra not to filtered out.

Inputs

x = is a MxN matrix (class "double") of M spectra measured at N channels.

Optional Inputs

xref = 1xN reference spectrum to regress against. If not input, mean(x) is used.
options = structure array with the following fields:
order: [ {2} ] Order of the polynomial filter (positive integer).
logax: [ {'no'} | 'yes' ] Use the log of the axisscale, x.axisscale{2} as a basis vector to regress against. If the axisscale is not present log(1:N) is used. When (options.logax) is used, (options.order) is typically set to zero.
s: [ ] KxN spectra to not filter out.
p: [ ] KpxN spectra to filter out.
algorithm: [ {'cls'} | 'ils' ] Governs correction model method.
'cls' uses Classical Least Squares i.e., EMSC.
'ils' uses Inverse Least Squares i.e., EISC.
win: [ ] An odd scalar that defines the window width (number of variables) for piece-wise correction. If empty {the default} piece-wise is not used. Note that piece-wise correction can be slow.
initwt: [ ] Empty or Nx1 vector of initial weights (0<=w<=1). Low weights are used for channels not to be included in the fit.
condnum: [1e6] Maximum condition number for Z'*Z' used in the least squares estimates (see Algorithm).
xrefS: [{'no'} | 'yes'] Indicates whether input (xref) includes spectra contained in (options.s). If 'yes' then the spectra in (options.s) are centered and an SVD estimate of (options.s) is used in EMSCORR.
      robust: [{'none'} | 'lsq2top' ] Governs the use of robust least squares
               if 'lsq2top' is used then "trbflag", "tsqlim", and "stopcrit" are
               also used (see LSQ2TOP for descriptions of these fields).
         res: [] Scalar (required with "lsq2top") this is input (res) to
               the LSQ2TOP function. 
     trbflag: [ 'top' | 'bottom' | {'middle'}] Used only with lsq2top.
      tsqlim: [ 0.99 ] Used only with lsq2top.
    stopcrit: [1e-4 1e-4 1000 360] Used only with lsq2top.
   axisscale: [] 1 by N axis scale for the spectral mode, if empty [1:N] is used.
         mag: [ {'yes'} | 'no' ], performs slope correction when set to 'yes'

Outputs

sx = the corrected spectra.
fx = the signal that was filtered out.
xref = the reference spectrum.
reg = the regression coefficients. For non-windowed filtering, (reg) is [number of coefficients] x M. The number of coefficients corresponds to the number of basis vectors included in the correction. The coefficients are ordered according to the following: xbase = [xref, 1 x x2 ..., options.p, options.s]. If a windowed filter is used, (reg) is [number of coefficients] x N x M where mode 2 corresponds to the windows.
res = MxN matrix of residuals.

Algorithm

Example

>>This is an example
Error: does not exist

See Also

baselinew, deresolv, [[