custom.baseline {baseline} | R Documentation

## 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, ...)

### 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.

### Details

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

### Value

`baseline` | Estimated custom baselines.
`corrected` | Spectra corrected by custom baselines.
`spectra.scaled` | Re-scaled spectra.
`baseline.scaled` | Estimated baselines of re-scaled spectra.

### Author(s)

Kristian Hovde Liland and Bjørn-Helge Mevik

### References

Kristian Hovde Liland et al.: Customized baseline correction

### Examples

    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)
    ## Not run:
    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)

    ## End(Not run)

[Package baseline version 1.2-1 Index]