Preprocess

From Eigenvector Research Documentation Wiki
Revision as of 15:25, 20 November 2018 by imported>Lyle
Jump to navigation Jump to search

Purpose

Selection and application of standard preprocessing methods.

Synopsis

s = preprocess; %Modal GUI to select preprocessing
[s,changed] = preprocess(s); %Modal GUI to modify preprocessing
list = preprocess('initcatalog'); % Gives a list of the available methods
preprocess('keywords'); %Lists valid method names.
s = preprocess('default','methodname'); %Non-GUI interactive preprocessing selection
[datap,sp] = preprocess('calibrate',s,data); %single block calibration of preprocessing
[datap,sp] = preprocess('calibrate',s,xblock,yblock); %multi-block calibration of preprocessing
datap = preprocess('apply',sp,data); %apply to new data
data = preprocess('undo',sp,datap) ; %undo preprocessing
data = preprocess('undo_silent',sp,datap); %undo preprocessing (no warnings)
[datap,s] = preprocess(data); %Modal GUI to preprocess selected data
[datap,s] = preprocess(data,s); %Modal GUI to preprocess selected data

Description

PREPROCESS is a general tool to choose preprocessing steps and to perform the steps on data. It can be used as a graphical interface or as a command-line tool. See Model Building - PreProcessing Methods for a description of the use of the graphical user interface. See User Defined Preprocessing and preprouser for a description on how custom preprocessing can be added to the standard preprocessing options listed below.

From the command line, PREPROCESS can be used to perform four different tasks:

  • 1) Specification of Preprocessing (or preprocessing steps),
  • 2) Estimate preprocessing parameters (calibrate),
  • 3) Apply preprocessing to new data (apply), and
  • 4) Remove the preprocessing previously performed on the data (undo).

Case 1) Specification of Preprocessing

The purpose of the following calls to PREPROCESS is to generate standard preprocessing structure arrays that contain the desired preprocessing steps. The commands are listed here.

s = preprocess;

creates a GUI that allows the user to select preprocessing steps interactively. The output s is a standard preprocessing structure. If multiple preprocessing steps are selected, s is a multi-record structure with each record corresponding to a preprocessing step.

[s,changed] = preprocess(s);

allows the user to interactively edit a previously-built preprocessing structure s. The output s is the edited preprocessing structure. The second output changed is a flag that indicates whether the user clicked "OK" (==1) or "Cancel" (==0) to close the interface. If the user cancels, the output will be the same as the input (no changes have been made.)

s = preprocess('default','methodname');

returns the default preprocessing structure for method methodname. A list of valid method names, methodname, can be obtained using the command:

preprocess('keywords')

The technical description of the different types of preprocessing can be found on the Model Building: Preprocessing Methods page. Below is list of standard methods that can be used for 'methodname':

  • 'abs': takes the absolute value of the data (see abs),
  • 'arithmetic': simple arithmetic operations,
  • 'autoscale': centers columns to zero mean and scales to unit variance (see auto),
  • 'autoscalenomean': variance (std) scaling, scales each variable by its standard deviation without mean-centering,
  • 'baseline: baselining using an iterative weighted least square algorithm (see wlsbaseline),
  • 'whittaker': baselining using an automatic Whittaker filter,
  • 'simple baseline': baselining base on user specified points (see baseline),
  • 'classcenter': centers classes in data to the mean of each class (see classcenter).
  • 'classcentroid': centers data to the centroid of all classes (see classcentroid).
  • 'classcentroidscale': centers data to the centroid of all classes and scales to intra-class variance (see classcentroid).
  • 'derivative': Savitzky-Golay smoothing and derivative across rows (see savgol),
  • 'derivative columns': Savitzky-Golay smoothing and derivative down columns (see savgol),
  • 'detrend': remove a linear trend (see baseline),
  • 'eemfilter': EEM filtering,
  • 'emsc': extended multiplicative scatter correction (see emscorr),
  • 'epo': External Parameter Orthogonalization - remove clutter covariance (see glsw),
  • 'gapsegment': gap segment derivatives (see gapsegment),
  • 'gls weighting': generalized least squares weighting (see glsw),
  • 'gscale': group/block scaling (see gscale),
  • 'holoreact': Kaiser HoloReact Method (see hrmethodreadr),
  • 'logdecay': log decay scaling,
  • 'log10': calculate base 10 logarithm of data(log10),
  • 'mean center': center columns to have zero mean (see mncn),
  • 'median center': center columns to have zero median (see medcn),
  • 'msc': multiplicative scatter correction with offset, the mean is the reference spectrum (see mscorr),
  • 'msc_median': multiplicative scatter correction with offset, the median is the reference spectrum (see mscorr),
  • 'centering': multiway center,
  • 'scaling': multiway scale,
  • 'normalize': normalization of the rows (see normaliz),
  • 'osc': orthogonal signal correction (see osccalc and oscapp),
  • 'pareto': Pareto (sqrt std) scaling, scales each variable by the square root of its standard deviation,
  • 'sqmnsc': Poisson (sqrt mean) scaling, scales each variable by the square root of its mean (see poissonscale),
  • 'referencecorrection': reference/background correction,
  • 'smooth': Savitzky-Golay smoothing (see savgol),
  • 'snv': standard normal deviate (autoscale the rows, see snv),
  • 'specalign': variable alignment via cow and registerspec,
  • 'trans2abs': transmission to absorbance (log(1/T)),
  • 'minmax': min-max scaling, scales each row or column to have a minimum of 0 and a maximum of 1 (see minmax).

Additional methods are available with MIA_Toolbox. The valid method names for 'methodname' follow.

  • 'Image_Flatfield': background subtraction (flatfield),
  • 'Image_Close': close (dilate+erode)],
  • 'Image_Dilate': dilate,
  • 'Image_Erode': erode,
  • 'Image_Max': replaces window of pixels with the max (see box_filter),
  • 'Image_Mean': replaces window of pixels with the mean (see box_filter),
  • 'Image_Median': replaces window of pixels with the median (see box_filter),
  • 'Image_Min': replaces window of pixels with the min (see box_filter),
  • 'Image_Open: open (erode+dilate),
  • 'Image_Smooth': smooth,
  • 'Image_TrimmedMean': replaces window of pixels with the trimmed mean (see box_filter),
  • 'Image_TrimmedMedian': replaces window of pixels with the trimmed median (see box_filter).

The following command generates a multi-record structure of the default preprocessing steps included in PREPROCESS.

list = prprocess('initcatalog');

Case 2) Estimate preprocessing parameters (calibrate)

Many preprocessing methods derive statistics and other numerical values from the calibration data. These values must be stored and used when new data (test or other future data) is going to be preprocessed in the same way as the calibration data. Examples include the mean or variance for each variable of the calibration data.

The objective of the 'calibrate' call to PREPROCESS is to estimate preprocessing parameters, if any, from the calibration data set and perform preprocessing on the data. The I/O format is:

[datap,sp] = preprocess('calibrate',s,data);

The inputs are s a standard preprocessing structure and data the calibration data. The preprocessed data is returned in datap, and preprocessing parameters are returned in a modified preprocessing structure sp. Note that sp is used as an input with the 'apply' and 'undo' commands described below.

Short-cuts for each method can also be used. Examples for 'mean center' and 'autoscale' are

[datap,sp] = preprocess('calibrate','mean center',data);
[datap,sp] = preprocess('calibrate','autoscale',data);

Preprocessing for some multi-block methods (specifically, 'osc' and 'gls weighting') require that the y-block be passed also. The I/O format in these cases is:

[datap,sp] = preprocess('calibrate',s,xblock,yblock);

Case 3) Apply preprocessing to new data (apply)

Once the preprocessing steps have been calibrated on a set of data (see Case 2), the preprocessing can be "applied" to new data. The parameters determined during calibration are now used to preprocess the new data. For example, consider mean-centering. In this case, the parameters correspond to the mean of the calibration set. During 'apply', the new data are centered to the mean of the calibration data.

The following call to PREPROCESS

datap = preprocess('apply',sp,data);

applies the calibrated preprocessing sp to new data data and returns the preprocessed data datap that is class "dataset".

Case 4) Remove preprocessing from preprocessed data (undo)

The inverse operation of applying preprocessing is performed in the following call to PREPROCESS

data = preprocess('undo',sp,datap);

Inputs are sp, the calibrated preprocessing structure (See Case 2 above) and the preprocessed data, datap [class "double" or "dataset"]. The output is the "unpreprocessed" data data.

The 'undo' operation is most often used on y-block predictions in regression models and in missing data replacement algorithms (see mdcheck and replace) in which the data is preprocessed and then an estimate of the data is converted back to the original unpreprocessed form.

Note that some preprocessing can not be undone (for example, 'osc' and 'sg'). In these cases, an inverse does not exist or has not been defined and an 'undo' call will result in a warning. Using 'undo_silent' instead of 'undo' suppresses the warning message. One reason for not defining an inverse, or undo, is because the procedure requires a significant amount of memory storage (e.g., when data sets are large).

See Also

analysis, crossval, pca, pcr, pls, preprocessiterator, preprocatalog, preprouser