baselineCorrection {TargetSearch} | R Documentation

## Baseline correction - Chang's method

### Description

Function for baseline correction of GC-MS chromatograms using Chang's method described below.

### Usage

        baselineCorrection(peaks, threshold = 0.5, alpha = 0.95, bfraction = 0.2,
               segments = 100, signalWindow = 10, method = "linear")

### Arguments

`peaks` | Either a matrix object of spectra peak intensities to be baseline corrected, where the rows are retention times and columns are mass traces; or, a named list containing an element called `"Peaks"` which such matrix. The list can be generated by `peakCDFextraction`
`threshold` | A numeric value between 0 and 1. A value of one sets the baseline above the noise, 0.5 in the middle of the noise and 0 below the noise.
`alpha` | The alpha parameter of the high pass filter.
`bfraction` | The percentage of the fragments with the lowest intensities of the filtered signal that are assumed to be baseline signal.
`segments` | The number of segments in which the filtered signal is divided.
`signalWindow` | The window size (number of points) used in the signal windowing step.
`method` | The method used to approximate the baseline. `"linear"` (default) uses linear interpolation. `"spline"` fits a cubic smoothing spline (warning: really slow).

### Details

The baseline correction algorithm is based on the work of Chang et al, and it works as follows. For every mass trace, i.e., columns of matrix `peaks`, the signal intensity is filtered by a first high pass filter: y[i] = alpha * (y[i-1] + x[i] - x[i-1]). The filtered signal is divided into evenly spaced segments (`segments`) and the standard deviation of each segment is calculated. A percentage (`bfraction`) of the segments with the lowest values are assumed to be baseline signal and the standard deviation (stdn) of the points within those segments is calculated.

Once stdn has been determined, the points with absolute filtered values larger than 2 * stdn are considered signal. After that, the signal windowing step takes every one of the points found to be signal as the center of a signal window (`signalWindow)` and marks the points within that window as signal. The remaining points are now considered to be noise.

The baseline signal is obtained by either using linear interpolation (default) or fitting a cubic smoothing spline taking only the noise. The baseline can be shifted up or down by using the parameter (threshold), which is done by the formula: B' = B + 2*(threshold - 0.5)*2*stdn, where B is the fitted spline, stdn the standard deviation of the noise, and `threshold` a value between 0 and 1. Finally, the corrected signal is calculated by subtracting B' to the original signal.

### Value

The output depends on whether the input `peaks` is a matrix or a list. If it is a matrix, then the function returns a matrix of the same dimensions with the baseline corrected intensities. If instead `peaks` is a list, then the element called `"Peaks"` will hold the output.

### Note

This function is intended to be run internally, but it is exported for advanced users.

### Author(s)

Alvaro Cuadros-Inostroza

### References

David Chang, Cory D. Banack and Sirish L. Shah, Robust baseline correction algorithm for signal dense NMR spectra. Journal of Magnetic Resonance 187 (2007) 288-292

### See Also

`RIcorrect`

[Package TargetSearch version 1.50.1 Index]