This function performs baseline correction on the spectral matrix by estimating and removing the continuous background emission using least-squares polynomial curve fitting approach.
Arguments
- x
A matrix or data frame.
- degree
An integer specifying the degree of the polynomial fitting function. The default value is 4.
- tol
A numeric value representing the tolerance for the difference between iterations. The default value is 1e-3.
- max.iter
An integer specifying the maximum number of iterations for the algorithm. The default value is 10.
Value
A list with two elements:
correction
: The baseline-corrected spectral matrix.background
: The fitted background emission.
Details
This function implements the algorithm described in Lieber and Mahadevan-Jansen (2003), which smoothes the spectrum in such a way that peaks are automatically eliminated, leaving only the baseline to be subtracted from the raw spectrum. The basis for this method is a modified least-squares-based polynomial curve-fitting function, such that all data points in the generated curve that have an intensity value higher than their respective pixel value in the input spectrum are automatically reassigned to the original intensity.