base_line: Baseline correction using the baseline package#'

base_lineR Documentation

Baseline correction using the baseline package#'


Estimates baselines for the spectra in the obj object, using the algorithm named in 'method'.


## S4 method for signature 'Spectra'
base_line(object, ...)



an object inheriting from class Spectra


additional arguments to be passed to the baseline function in the baseline package. The main option would be 'method', to switch between the several baseline methods presented in teh details section.


The baseline package implements various algorithms for the baseline correction. The following methods are available:

  • 'als': Baseline correction by 2nd derivative constrained weighted regression

  • 'fillPeaks': An iterative algorithm using suppression of baseline by means in local windows

  • 'irls' (default): An algorithm with primary smoothing and repeated baseline suppressions and regressions with 2nd derivative constraint

  • 'lowpass': An algorithm for removing baselines based on Fast Fourier Transform filtering

  • 'medianWindow': An implementation and extention of Mark S. Friedrichs' model-free algorithm

  • 'modpolyfit': An implementation of Chad A. Lieber and Anita Mahadevan-Jansen's algorithm for polynomial fiting

  • 'peakDetection': A translation from Kevin R. Coombes et al.'s MATLAB code for detecting peaks and removing baselines

  • 'rfbaseline': Wrapper for Andreas F. Ruckstuhl, Matthew P. Jacobson, Robert W. Field, James A. Dodd's algorithm based on LOWESS and weighted regression

  • 'rollingBall': Ideas from Rolling Ball algorithm for X-ray spectra by M.A.Kneen and H.J. Annegarn. Variable window width has been left out

See baseline package documentation for more information and references.

Additionally, the baseline package provides a nice GUI that helps choosing the good baseline method and the good parametrisation. This GUI can be used with the inspectr package. This is demonstrate in the Examples section.


An object of the same class as obj with the continuum removed from its spectra.


Interface to the baseline package by Pierre Roudier, baseline package authored by Kristian Hovde Liland and Bjorn-Helge Mevik


Kristian Hovde Liland and Bjorn-Helge Mevik (2011). baseline: Baseline Correction of Spectra. R package version 1.0-1.

See Also

continuum_removal, snv, rnv


# Loading example data
spectra(australia) <- sr_no ~ ... ~ 350:2500

# Subsample for demo purposes
australia <- australia[1:10,]

# Correction using the default method (irls)
bl <- base_line(australia)

# Specifying another method for baseline calculation
bl2 <- base_line(australia, method = "modpolyfit")

# Using the baseline package independently
# (useful to plot the corrections)
## Not run: 
bl3 <- baseline(spectra(australia), method = 'irls')
class(bl3) # this is a baseline object
# Affecting the baseline-corrected spectra back
# to the SpectraDataFrame object
spectra(australia) <- getCorrected(bl3)

# Using the baselineGUI with inspectr
## When happy with a configuration, clik "Apply to all" and 
## save the results under a name, e.g. "corrected.spectra"
spectra(australia) <- getCorrected(corrected.spectra)

## End(Not run)

spectacles documentation built on July 10, 2023, 1:59 a.m.