baselineCorrectionCWT: background fitting via penalized least squares algorithm

Description Usage Arguments Value Author(s) See Also Examples

Description

intelligent background-correction algorithm is developed, which simulates manual background-correction procedure of an expert intelligently. It basically consists of works of three aspects: 1) the accurate peak position detection of Raman spectrum by continuous wavelet transform (CWT) with the Mexican Hat wavelet as the mother wavelet; 2) peak widths estimation by enhanced signal-to-noise ratio (SNR) derivative calculation based on CWT but with the Haar wavelet as the mother wavelet; and 3) background fitting using penalized least squares with binary masks.

Usage

1
baselineCorrectionCWT(x,peakWidth,threshold=0.5,lambda=100)

Arguments

x

Raman spectrum

peakWidth

returned by widthEstimationCWT

threshold

the user define peak shape threshold

lambda

lambda is an adjustable parameter, it can be adjusted by user. The larger lambda is, the smoother fitted background will be

differences

an integer indicating the order of the difference of penalties of Whittaker Smoother method, see WhittakerSmooth

Value

the final background

Author(s)

Yizeng Liang ,Zhang Zhimin

See Also

WhittakerSmooth

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
data(raman)
x=m[7,]
scales <-seq(1, 70, 1)
wCoefs <- cwt(x, scales=scales, wavelet='mexh')
image(1:nrow(wCoefs), scales, wCoefs, col=terrain.colors(256), axes=FALSE, xlab='index', ylab='CWT coefficient scale', main='CWT coefficients')
box()
localMax <- getLocalMaximumCWT(wCoefs)
ridgeList <- getRidge(localMax, gapTh=3, skip=2)
plotRidgeList(ridgeList)
majorPeakInfo = identifyMajorPeaks(x, ridgeList, wCoefs, SNR.Th=1,ridgeLength=5)
peakWidth=widthEstimationCWT(x,majorPeakInfo)                                                
backgr = baselineCorrectionCWT(x,peakWidth,lambda=1000,differences=1)
corrected=x-backgr 
plot(xa,x,type='l',ylim=c(min(c(x,corrected)),max(c(x,corrected))),main="The background-correction result of Raman Spectra",xlab=expression("Wavenumber / cm"^-1),ylab="Raman Intensity/Arbitr. Units")
points(xa[majorPeakInfo$peakIndex],x[majorPeakInfo$peakIndex])
lines(xa,backgr,lty=5)
lines(xa,corrected)

zmzhang/baselineWavelet documentation built on Dec. 26, 2019, 8:49 a.m.