General purpose preprocessing of spectra for predictions
irp_preprocess.Rdirp_preprocess is a function that provides a general-purpose
preprocessing workflow for spectra. The workflow comprises interpolation,
clipping, baseline correction, smoothing (including optionally
derivatization), normalization, binning, and scaling. All these steps are
optionally, but occur on a fixed order that cannot be changed.
Usage
irp_preprocess(
x,
do_interpolate = TRUE,
interpolate_start = NULL,
interpolate_dw = 1,
do_clip = TRUE,
clip_range,
do_interpolate_region = FALSE,
interpolate_region_range,
do_bc = TRUE,
bc_method = "rubberband",
bc_degree = 2,
bc_cutoff = 0,
bc_do_impute = FALSE,
do_smooth = TRUE,
smooth_method = "sg",
smooth_p = 3,
smooth_n = smooth_p + 3 - smooth_p%%2,
smooth_m = 1,
smooth_ts = 0,
smooth_k = 111,
do_normalise = TRUE,
normalise_method = "area",
do_bin = TRUE,
bin_width = 10,
bin_new_x_type = "start",
do_scale = TRUE,
scale_center = TRUE,
scale_scale = TRUE
)Arguments
- x
An object of class
ir(it is assumed thatxis not yet preprocessed).- do_interpolate
A logical value indicating if spectra should be interpolated using
ir::ir_interpolate().- interpolate_start
See
ir_interpolate(parameterstart).- interpolate_dw
See
ir_interpolate(parameterdw).- do_clip
A logical value indicating if spectra should be clipped using
ir::ir_clip().- clip_range
See
ir_clip(parameterrange).- do_interpolate_region
A logical value indicating if spectra should be linearly interpolated in selected regions using
ir::ir_interpolate_region().- interpolate_region_range
See
ir_interpolate_region(parameterrange).- do_bc
A logical value indicating if spectra should be baseline corrected using
ir::ir_bc().- bc_method
See
ir_bc(parametermethod).- bc_degree
See
ir_bc(parameterdegree).- bc_cutoff
A numeric value representing the wavenumber units to remove at the start and end of each spectrum in
xduring baseline correction. This may be done to remove artifacts due to baseline correction.- bc_do_impute
See
ir_bc(parameterdo_impute).- do_smooth
A logical value indicating if spectra should be smoothed using
ir::ir_smooth().- smooth_method
See
ir_smooth(parametermethod).- smooth_p
See
ir_smooth(parameterp).- smooth_n
See
ir_smooth(parametern).- smooth_m
See
ir_smooth(parameterm).- smooth_ts
See
ir_smooth(parameterts).- smooth_k
See
ir_smooth(parameterk).- do_normalise
A logical value indicating if spectra should be normalized using
ir::ir_normalize().- normalise_method
See
ir_normalize(parametermethod).- do_bin
A logical value indicating if spectra should be binned using
ir::ir_bin().- bin_width
See
ir_bin(parameterwidth).- bin_new_x_type
See
ir_bin(parameternew_x_type).- do_scale
A logical value indicating if spectral variables should be scaled using
base::scale().- scale_center
See
scale(parametercenter). To scale each spectral variable independently, provide a vector with length equal to the number of spectral variables returned after preprocessing.- scale_scale
See
scale(parameterscale). To scale each spectral variable independently, provide a vector with length equal to the number of spectral variables returned after preprocessing.
Value
A data frame with spectra in rows and a column for each spectral variable after preprocessing.
Examples
# get sample data
x <- ir::ir_sample_data[1, ]
# example preprocessing
res <-
irpeat::irp_preprocess(
x,
do_interpolate = TRUE,
interpolate_start = NULL,
interpolate_dw = 1,
do_bc = TRUE,
do_clip = FALSE,
do_interpolate_region = FALSE,
bc_method = "rubberband",
bc_cutoff = 10,
bc_do_impute = FALSE,
do_smooth = FALSE,
do_normalise = TRUE,
normalise_method = "area",
do_bin = TRUE,
bin_width = 10,
bin_new_x_type = "start",
do_scale = TRUE,
scale_center = TRUE,
scale_scale = TRUE
)