Skip to contents

This baseline correction routine iteratively finds the baseline of a spectrum using a polynomial fitting or accepts a manual baseline.

Usage

subtr_baseline(x, ...)

# S3 method for default
subtr_baseline(x, ...)

# S3 method for OpenSpecy
subtr_baseline(
  x,
  type = "polynomial",
  degree = 8,
  raw = FALSE,
  baseline,
  make_rel = TRUE,
  ...
)

Arguments

x

a list object of class OpenSpecy.

type

one of "polynomial" or "manual" depending on whether you want spectra to be corrected with a manual baseline or with polynomial baseline fitting.

degree

the degree of the polynomial. Must be less than the number of unique points when raw is FALSE. Typically a good fit can be found with a 8th order polynomial.

raw

if TRUE, use raw and not orthogonal polynomials.

baseline

an OpenSpecy object containing the baseline data to be subtracted.

make_rel

logical; if TRUE spectra are automatically normalized with make_rel().

...

further arguments passed to poly().

Value

subtr_baseline() returns a data frame containing two columns named "wavenumber" and "intensity".

Details

This is a translation of Michael Stephen Chen's MATLAB code written for the imodpolyfit routine from Zhao et al. 2007.

References

Chen MS (2020). Michaelstchen/ModPolyFit. MATLAB. Retrieved from https://github.com/michaelstchen/modPolyFit (Original work published July 28, 2015)

Zhao J, Lui H, McLean DI, Zeng H (2007). “Automated Autofluorescence Background Subtraction Algorithm for Biomedical Raman Spectroscopy.” Applied Spectroscopy, 61(11), 1225–1232. doi:10.1366/000370207782597003 .

See also

Author

Win Cowger, Zacharias Steinmetz

Examples

data("raman_hdpe")

subtr_baseline(raman_hdpe)
#>      wavenumber   intensity
#>           <num>       <num>
#>   1:    301.040 0.000000000
#>   2:    304.632 0.010833354
#>   3:    308.221 0.008185951
#>   4:    311.810 0.000000000
#>   5:    315.398 0.000000000
#>  ---                       
#> 960:   3187.990 0.037684523
#> 961:   3190.520 0.037684523
#> 962:   3193.060 0.043235847
#> 963:   3195.590 0.043235847
#> 964:   3198.120 0.032133199
#> 
#> $metadata
#>        x     y  user_name spectrum_type spectrum_identity      organization
#>    <int> <int>     <char>        <char>            <char>            <char>
#> 1:     1     1 Win Cowger         Raman              HDPE Horiba Scientific
#>     license                                                        session_id
#>      <char>                                                            <char>
#> 1: CC BY-NC 5728ddde4f649fd71f6f487fc5ad8d80/dc85257201307a131e71d9ec24aaccbf
#>                             file_id
#>                              <char>
#> 1: cb06ce2846b119d932fb6696479a445b