Learn R Programming

baseline (version 1.3-5)

custom.baseline: Customized baseline correction

Description

This function rescales spectrum abscissa by use of breaks and gaps before baseline correction. The effect is that the chosen baseline correction algorithm and paramters will have varying effects along the spectra, effectively giving local control of the amount of rigidity/flexibility of the estimated baseline.

Usage

custom.baseline(spectra, breaks, gaps, trans.win = NULL, just.plot = FALSE, method, ...)

Value

baseline

Estimated custom baselines.

corrected

Spectra corrected by custom baselines.

spectra.scaled

Re-scaled spectra.

baseline.scaled

Estimated baselines of re-scaled spectra.

Arguments

spectra

Matrix with spectra in rows.

breaks

Vector of locations of break points between sections of varying baseline flexibility (given as abscissa numbers).

gaps

Vector giving the abscissa spacing between each instance of breaks (and endpoints if not specified in breaks).

trans.win

Optional width of transition window around break points used for smoothing rough breaks by LOWESS (default = NULL).

just.plot

Plot the rescaled spectra instead of applying the customized baseline correction if just.plot=TRUE (default = FALSE).

method

Baseline correction method to use (class character).

...

Additional named arguments to be passed to the baseline correction method.

Author

Kristian Hovde Liland and Bjørn-Helge Mevik

Details

This is an implementation of the customized baseline correction suggested by Liland et al. 2011 for local changes in baseline flexibility.

References

Kristian Hovde Liland et al.: Customized baseline correction

Examples

Run this code
data(milk)
spectrum1  <- milk$spectra[1,1:10000,drop=FALSE]
ordinary   <- baseline(spectrum1, method="als", lambda=6, p=0.01)
customized <- custom.baseline(spectrum1, 2900, c(1,20), trans.win=100, 
	just.plot=FALSE, method="als", lambda=6, p=0.01)
if (FALSE) {
plot(1:10000,spectrum1, type='l')
lines(1:10000,getBaseline(ordinary), lty=2, col=2, lwd=2)
lines(1:10000,customized$baseline, lty=3, col=3, lwd=2)
}

Run the code above in your browser using DataLab