Title: | Pre-Processing XY Data from Experimental Methods |
---|---|
Description: | A lightweight, dependency-free toolbox for pre-processing XY data from experimental methods (i.e. any signal that can be measured along a continuous variable). This package provides methods for baseline estimation and correction, smoothing, normalization, integration and peaks detection. Baseline correction methods includes polynomial fitting as described in Lieber and Mahadevan-Jansen (2003) <doi:10.1366/000370203322554518>, Rolling Ball algorithm after Kneen and Annegarn (1996) <doi:10.1016/0168-583X(95)00908-6>, SNIP algorithm after Ryan et al. (1988) <doi:10.1016/0168-583X(88)90063-8>, 4S Peak Filling after Liland (2015) <doi:10.1016/j.mex.2015.02.009> and more. |
Authors: | Nicolas Frerebeau [aut, cre] (<https://orcid.org/0000-0001-5759-4944>, Université Bordeaux Montaigne), Brice Lebrun [ctb] (<https://orcid.org/0000-0001-7503-8685>, Logo designer), Université Bordeaux Montaigne [fnd], CNRS [fnd] |
Maintainer: | Nicolas Frerebeau <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.2.0 |
Built: | 2024-10-31 20:31:46 UTC |
Source: | CRAN |
Baseline estimation with asymmetric least squares smoothing.
baseline_asls(x, y, ...) ## S4 method for signature 'numeric,numeric' baseline_asls(x, y, p = 0.01, lambda = 10^4, stop = 100) ## S4 method for signature 'ANY,missing' baseline_asls(x, p = 0.01, lambda = 10^4, stop = 100)
baseline_asls(x, y, ...) ## S4 method for signature 'numeric,numeric' baseline_asls(x, y, p = 0.01, lambda = 10^4, stop = 100) ## S4 method for signature 'ANY,missing' baseline_asls(x, p = 0.01, lambda = 10^4, stop = 100)
x , y
|
A |
... |
Currently not used. |
p |
A length-one |
lambda |
A length-one |
stop |
An |
Returns a list
with two components x
and y
.
P. H. C. Eilers and H. F. M. Boelens (original Matlab code)
Eilers, P. H. C. & Boelens, H. F. M. (2005). Baseline Correction with Asymmetric Least Squares Smoothing.
Other baseline estimation methods:
baseline_linear()
,
baseline_peakfilling()
,
baseline_polynomial()
,
baseline_rollingball()
,
baseline_rubberband()
,
baseline_snip()
## X-ray diffraction data("XRD") ## Subset from 20 to 70 degrees XRD <- signal_select(XRD, from = 20, to = 70) ## Plot spectrum plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") ## Polynomial baseline baseline <- baseline_asls(XRD, p = 0.005, lambda = 10^7) lines(baseline, type = "l", col = "red")
## X-ray diffraction data("XRD") ## Subset from 20 to 70 degrees XRD <- signal_select(XRD, from = 20, to = 70) ## Plot spectrum plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") ## Polynomial baseline baseline <- baseline_asls(XRD, p = 0.005, lambda = 10^7) lines(baseline, type = "l", col = "red")
Linear Baseline Estimation
baseline_linear(x, y, ...) ## S4 method for signature 'numeric,numeric' baseline_linear(x, y, points = range(x)) ## S4 method for signature 'ANY,missing' baseline_linear(x, points = range(x))
baseline_linear(x, y, ...) ## S4 method for signature 'numeric,numeric' baseline_linear(x, y, points = range(x)) ## S4 method for signature 'ANY,missing' baseline_linear(x, points = range(x))
x , y
|
A |
... |
Currently not used. |
points |
A |
Returns a list
with two components x
and y
.
N. Frerebeau
Other baseline estimation methods:
baseline_asls()
,
baseline_peakfilling()
,
baseline_polynomial()
,
baseline_rollingball()
,
baseline_rubberband()
,
baseline_snip()
## X-ray diffraction data("XRD") ## Plot spectrum plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") ## Linear baseline baseline <- baseline_linear(XRD, points = c(25, 34)) plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") lines(baseline, type = "l", col = "red") ## Correct baseline XRD$count <- XRD$count - baseline$y plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count")
## X-ray diffraction data("XRD") ## Plot spectrum plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") ## Linear baseline baseline <- baseline_linear(XRD, points = c(25, 34)) plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") lines(baseline, type = "l", col = "red") ## Correct baseline XRD$count <- XRD$count - baseline$y plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count")
Baseline estimation by iterative mean suppression.
baseline_peakfilling(x, y, ...) ## S4 method for signature 'numeric,numeric' baseline_peakfilling(x, y, n, m, by = 10, lambda = 1600, d = 2, sparse = FALSE) ## S4 method for signature 'ANY,missing' baseline_peakfilling(x, n, m, by = 10, lambda = 1600, d = 2, sparse = FALSE)
baseline_peakfilling(x, y, ...) ## S4 method for signature 'numeric,numeric' baseline_peakfilling(x, y, n, m, by = 10, lambda = 1600, d = 2, sparse = FALSE) ## S4 method for signature 'ANY,missing' baseline_peakfilling(x, n, m, by = 10, lambda = 1600, d = 2, sparse = FALSE)
x , y
|
A |
... |
Currently not used. |
n |
An |
m |
An odd |
by |
A length-one |
lambda |
An |
d |
An |
sparse |
A |
Returns a list
with two components x
and y
.
N. Frerebeau
Liland, K. H. (2015). 4S Peak Filling - baseline estimation by iterative mean suppression. MethodsX, 2, 135-140. doi:10.1016/j.mex.2015.02.009.
signal_correct()
, smooth_whittaker()
Other baseline estimation methods:
baseline_asls()
,
baseline_linear()
,
baseline_polynomial()
,
baseline_rollingball()
,
baseline_rubberband()
,
baseline_snip()
## X-ray diffraction data("XRD") ## 4S Peak Filling baseline baseline <- baseline_peakfilling(XRD, n = 10, m = 5, by = 10, sparse = TRUE) plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") lines(baseline, type = "l", col = "red")
## X-ray diffraction data("XRD") ## 4S Peak Filling baseline baseline <- baseline_peakfilling(XRD, n = 10, m = 5, by = 10, sparse = TRUE) plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") lines(baseline, type = "l", col = "red")
Polynomial Baseline Estimation
baseline_polynomial(x, y, ...) ## S4 method for signature 'numeric,numeric' baseline_polynomial(x, y, d = 3, tolerance = 0.001, stop = 100) ## S4 method for signature 'ANY,missing' baseline_polynomial(x, d = 3, tolerance = 0.001, stop = 100)
baseline_polynomial(x, y, ...) ## S4 method for signature 'numeric,numeric' baseline_polynomial(x, y, d = 3, tolerance = 0.001, stop = 100) ## S4 method for signature 'ANY,missing' baseline_polynomial(x, d = 3, tolerance = 0.001, stop = 100)
x , y
|
A |
... |
Currently not used. |
d |
An |
tolerance |
A |
stop |
An |
Returns a list
with two components x
and y
.
N. Frerebeau
Lieber, C. A. and Mahadevan-Jansen, A. (2003). Automated Method for Subtraction of Fluorescence from Biological Raman Spectra. Applied Spectroscopy, 57(11): 1363-67. doi:10.1366/000370203322554518.
Other baseline estimation methods:
baseline_asls()
,
baseline_linear()
,
baseline_peakfilling()
,
baseline_rollingball()
,
baseline_rubberband()
,
baseline_snip()
## X-ray diffraction data("XRD") ## Subset from 20 to 70 degrees XRD <- signal_select(XRD, from = 20, to = 70) ## Plot spectrum plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") ## Polynomial baseline baseline <- baseline_polynomial(XRD, d = 4, tolerance = 0.02, stop = 1000) plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") lines(baseline, type = "l", col = "red")
## X-ray diffraction data("XRD") ## Subset from 20 to 70 degrees XRD <- signal_select(XRD, from = 20, to = 70) ## Plot spectrum plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") ## Polynomial baseline baseline <- baseline_polynomial(XRD, d = 4, tolerance = 0.02, stop = 1000) plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") lines(baseline, type = "l", col = "red")
Rolling Ball Baseline Estimation
baseline_rollingball(x, y, ...) ## S4 method for signature 'numeric,numeric' baseline_rollingball(x, y, m, s) ## S4 method for signature 'ANY,missing' baseline_rollingball(x, m, s)
baseline_rollingball(x, y, ...) ## S4 method for signature 'numeric,numeric' baseline_rollingball(x, y, m, s) ## S4 method for signature 'ANY,missing' baseline_rollingball(x, m, s)
x , y
|
A |
... |
Currently not used. |
m |
An odd |
s |
An odd |
Returns a list
with two components x
and y
.
There will be points both at the beginning and at the end
of the data series for which a complete
-width window cannot be
obtained. To prevent data loss, progressively wider/narrower windows are
used at both ends of the data series.
N. Frerebeau
Kneen, M. A. and Annegarn, H. J. (1996). Algorithm for Fitting XRF, SEM and PIXE X-Ray Spectra Backgrounds. Nuclear Instruments and Methods in Physics Research Section B: Beam Interactions with Materials and Atoms, 109/110: 209-213. doi:10.1016/0168-583X(95)00908-6.
Other baseline estimation methods:
baseline_asls()
,
baseline_linear()
,
baseline_peakfilling()
,
baseline_polynomial()
,
baseline_rubberband()
,
baseline_snip()
## X-ray diffraction data("XRD") ## Subset from 20 to 70 degrees XRD <- signal_select(XRD, from = 20, to = 70) ## Plot spectrum plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") ## Rolling Ball baseline baseline <- baseline_rollingball(XRD, m = 201, s = 151) plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") lines(baseline, type = "l", col = "red")
## X-ray diffraction data("XRD") ## Subset from 20 to 70 degrees XRD <- signal_select(XRD, from = 20, to = 70) ## Plot spectrum plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") ## Rolling Ball baseline baseline <- baseline_rollingball(XRD, m = 201, s = 151) plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") lines(baseline, type = "l", col = "red")
Rubberband Baseline Estimation
baseline_rubberband(x, y, ...) ## S4 method for signature 'numeric,numeric' baseline_rubberband(x, y, noise = 0, spline = TRUE, ...) ## S4 method for signature 'ANY,missing' baseline_rubberband(x, noise = 0, spline = TRUE, ...)
baseline_rubberband(x, y, ...) ## S4 method for signature 'numeric,numeric' baseline_rubberband(x, y, noise = 0, spline = TRUE, ...) ## S4 method for signature 'ANY,missing' baseline_rubberband(x, noise = 0, spline = TRUE, ...)
x , y
|
A |
... |
Extra arguments to be passed to |
noise |
A length-one |
spline |
A |
A convex envelope of the spectrum is determined and the baseline is estimated as the part of the convex envelope lying below the spectrum. Note that the rubber band does not enter the concave regions (if any) of the spectrum.
Returns a list
with two components x
and y
.
baseline_rubberband()
is slightly modified from C. Beleites'
hyperSpec::spc.rubberband()
.
N. Frerebeau
Other baseline estimation methods:
baseline_asls()
,
baseline_linear()
,
baseline_peakfilling()
,
baseline_polynomial()
,
baseline_rollingball()
,
baseline_snip()
## gamma-ray spectrometry data("BEGe") ## Subset from 2.75 to 200 keV BEGe <- signal_select(BEGe, from = 3, to = 200) ## Plot spectrum plot(BEGe, type = "l", xlab = "Energy (keV)", ylab = "Count") ## Rubberband baseline baseline <- baseline_rubberband(BEGe) plot(BEGe, type = "l", xlab = "Energy (keV)", ylab = "Count") lines(baseline, type = "l", col = "red")
## gamma-ray spectrometry data("BEGe") ## Subset from 2.75 to 200 keV BEGe <- signal_select(BEGe, from = 3, to = 200) ## Plot spectrum plot(BEGe, type = "l", xlab = "Energy (keV)", ylab = "Count") ## Rubberband baseline baseline <- baseline_rubberband(BEGe) plot(BEGe, type = "l", xlab = "Energy (keV)", ylab = "Count") lines(baseline, type = "l", col = "red")
Sensitive Nonlinear Iterative Peak clipping algorithm.
baseline_snip(x, y, ...) ## S4 method for signature 'numeric,numeric' baseline_snip(x, y, LLS = FALSE, decreasing = FALSE, n = 100) ## S4 method for signature 'ANY,missing' baseline_snip(x, LLS = FALSE, decreasing = FALSE, n = 100)
baseline_snip(x, y, ...) ## S4 method for signature 'numeric,numeric' baseline_snip(x, y, LLS = FALSE, decreasing = FALSE, n = 100) ## S4 method for signature 'ANY,missing' baseline_snip(x, LLS = FALSE, decreasing = FALSE, n = 100)
x , y
|
A |
... |
Currently not used. |
LLS |
A |
decreasing |
A |
n |
An |
Returns a list
with two components x
and y
.
N. Frerebeau
Morháč, M., Kliman, J., Matoušek, V., Veselský, M. & Turzo, I. (1997). Background elimination methods for multidimensional gamma-ray spectra. Nuclear Instruments and Methods in Physics Research Section A: Accelerators, Spectrometers, Detectors and Associated Equipment, 401(1), p. 113-132. doi:10.1016/S0168-9002(97)01023-1
Morháč, M. & Matoušek, V. (2008). Peak Clipping Algorithms for Background Estimation in Spectroscopic Data. Applied Spectroscopy, 62(1), p. 91-106. doi:10.1366/000370208783412762
Ryan, C. G., Clayton, E., Griffin, W. L., Sie, S. H. & Cousens, D. R. (1988). SNIP, a statistics-sensitive background treatment for the quantitative analysis of PIXE spectra in geoscience applications. Nuclear Instruments and Methods in Physics Research Section B: Beam Interactions with Materials and Atoms, 34(3), p. 396-402. doi:10.1016/0168-583X(88)90063-8
Other baseline estimation methods:
baseline_asls()
,
baseline_linear()
,
baseline_peakfilling()
,
baseline_polynomial()
,
baseline_rollingball()
,
baseline_rubberband()
## gamma-ray spectrometry data("BEGe") ## Subset from 2.75 to 200 keV BEGe <- signal_select(BEGe, from = 3, to = 200) ## Plot spectrum plot(BEGe, type = "l", xlab = "Energy (keV)", ylab = "Count") ## SNIP baseline baseline <- baseline_snip(BEGe, LLS = FALSE, decreasing = FALSE, n = 100) plot(BEGe, type = "l", xlab = "Energy (keV)", ylab = "Count") lines(baseline, type = "l", col = "red")
## gamma-ray spectrometry data("BEGe") ## Subset from 2.75 to 200 keV BEGe <- signal_select(BEGe, from = 3, to = 200) ## Plot spectrum plot(BEGe, type = "l", xlab = "Energy (keV)", ylab = "Count") ## SNIP baseline baseline <- baseline_snip(BEGe, LLS = FALSE, decreasing = FALSE, n = 100) plot(BEGe, type = "l", xlab = "Energy (keV)", ylab = "Count") lines(baseline, type = "l", col = "red")
Gamma-Ray Spectrometry
BEGe
BEGe
A data.frame
with 8192 rows (channels) and 2 variables.
(keV)
Other datasets:
LaBr
,
Raman
,
XRD
data("BEGe") plot(BEGe, type = "l", xlab = "Energy (keV)", ylab = "Count")
data("BEGe") plot(BEGe, type = "l", xlab = "Energy (keV)", ylab = "Count")
Approximates the definite integral by using the rectangle rule.
integrate_rectangle(x, y, ...) ## S4 method for signature 'numeric,numeric' integrate_rectangle(x, y, right = FALSE) ## S4 method for signature 'ANY,missing' integrate_rectangle(x, right = FALSE)
integrate_rectangle(x, y, ...) ## S4 method for signature 'numeric,numeric' integrate_rectangle(x, y, right = FALSE) ## S4 method for signature 'ANY,missing' integrate_rectangle(x, right = FALSE)
x , y
|
A |
... |
Currently not used. |
right |
A |
Returns a list
with two components x
and y
.
N. Frerebeau
Other integration methods:
integrate_trapezoid()
## Calculate the area under the sine curve from 0 to pi # integrate(f = function(x) x^3, lower = 0, upper = 2) x <- seq(0, 2, len = 101) y <- x^3 plot(x, y, type = "l") integrate_rectangle(x, y, right = FALSE) # 3.9204 integrate_rectangle(x, y, right = TRUE) # 4.0804 integrate_trapezoid(x, y) # 4.0004
## Calculate the area under the sine curve from 0 to pi # integrate(f = function(x) x^3, lower = 0, upper = 2) x <- seq(0, 2, len = 101) y <- x^3 plot(x, y, type = "l") integrate_rectangle(x, y, right = FALSE) # 3.9204 integrate_rectangle(x, y, right = TRUE) # 4.0804 integrate_trapezoid(x, y) # 4.0004
Approximates the definite integral by using the trapezoidal rule.
integrate_trapezoid(x, y, ...) ## S4 method for signature 'numeric,numeric' integrate_trapezoid(x, y) ## S4 method for signature 'ANY,missing' integrate_trapezoid(x)
integrate_trapezoid(x, y, ...) ## S4 method for signature 'numeric,numeric' integrate_trapezoid(x, y) ## S4 method for signature 'ANY,missing' integrate_trapezoid(x)
x , y
|
A |
... |
Currently not used. |
Returns a list
with two components x
and y
.
N. Frerebeau
Other integration methods:
integrate_rectangle()
## Calculate the area under the sine curve from 0 to pi # integrate(f = function(x) x^3, lower = 0, upper = 2) x <- seq(0, 2, len = 101) y <- x^3 plot(x, y, type = "l") integrate_rectangle(x, y, right = FALSE) # 3.9204 integrate_rectangle(x, y, right = TRUE) # 4.0804 integrate_trapezoid(x, y) # 4.0004
## Calculate the area under the sine curve from 0 to pi # integrate(f = function(x) x^3, lower = 0, upper = 2) x <- seq(0, 2, len = 101) y <- x^3 plot(x, y, type = "l") integrate_rectangle(x, y, right = FALSE) # 3.9204 integrate_rectangle(x, y, right = TRUE) # 4.0804 integrate_trapezoid(x, y) # 4.0004
Strip XRD ka2
ka2_strip_penalized(x, y, ...) ## S4 method for signature 'numeric,numeric' ka2_strip_penalized( x, y, lambda, wave = c(1.5406, 1.54443), tau = 0.5, nseg = 1, progress = interactive() ) ## S4 method for signature 'ANY,missing' ka2_strip_penalized( x, lambda, wave = c(1.5406, 1.54443), tau = 0.5, nseg = 1, progress = interactive() )
ka2_strip_penalized(x, y, ...) ## S4 method for signature 'numeric,numeric' ka2_strip_penalized( x, y, lambda, wave = c(1.5406, 1.54443), tau = 0.5, nseg = 1, progress = interactive() ) ## S4 method for signature 'ANY,missing' ka2_strip_penalized( x, lambda, wave = c(1.5406, 1.54443), tau = 0.5, nseg = 1, progress = interactive() )
x , y
|
A |
... |
Currently not used. |
lambda |
An |
wave |
A length-two |
tau |
A length-one |
nseg |
A length-one |
progress |
A |
Returns a list
with two components x
and y
.
Matrix is required.
J. J. de Rooi et al. (original R code).
de Rooi, J. J., van der Pers, N. M., Hendrikx, R. W. A., Delhez, R., Böttger A. J. and Eilers, P. H. C. (2014). Smoothing of X-ray diffraction data and Ka2 elimination using penalized likelihood and the composite link model. Journal of Applied Crystallography, 47: 852-860. doi:10.1107/S1600576714005809
## Not run: ## X-ray diffraction data("XRD") ## Subset from 20 to 40 degrees XRD <- signal_select(XRD, from = 20, to = 40) ## Plot diffractogram plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") ## Penalized likelihood smoothing lambda <- seq(from = 1, to = 8, length.out = 40) lambda <- 10^lambda likelihood <- smooth_likelihood(XRD, lambda = lambda, d = 3) lines(likelihood, col = "red") ## Strip ka2 ka2 <- ka2_strip_penalized(XRD, lambda = lambda, tau = 0.5, nseg = 1) lines(ka2, col = "blue") ## End(Not run)
## Not run: ## X-ray diffraction data("XRD") ## Subset from 20 to 40 degrees XRD <- signal_select(XRD, from = 20, to = 40) ## Plot diffractogram plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") ## Penalized likelihood smoothing lambda <- seq(from = 1, to = 8, length.out = 40) lambda <- 10^lambda likelihood <- smooth_likelihood(XRD, lambda = lambda, d = 3) lines(likelihood, col = "red") ## Strip ka2 ka2 <- ka2_strip_penalized(XRD, lambda = lambda, tau = 0.5, nseg = 1) lines(ka2, col = "blue") ## End(Not run)
Gamma-Ray Spectrometry
LaBr
LaBr
A data.frame
with 1024 rows (channels) and 2 variables.
(keV)
Other datasets:
BEGe
,
Raman
,
XRD
data("LaBr") plot(LaBr, type = "l", xlab = "Energy (keV)", ylab = "Count")
data("LaBr") plot(LaBr, type = "l", xlab = "Energy (keV)", ylab = "Count")
Finds local maxima in sequential data.
peaks_find(x, y, ...) ## S4 method for signature 'numeric,numeric' peaks_find(x, y, method = "MAD", SNR = 2, m = NULL, ...) ## S4 method for signature 'ANY,missing' peaks_find(x, method = "MAD", SNR = 2, m = NULL, ...)
peaks_find(x, y, ...) ## S4 method for signature 'numeric,numeric' peaks_find(x, y, method = "MAD", SNR = 2, m = NULL, ...) ## S4 method for signature 'ANY,missing' peaks_find(x, method = "MAD", SNR = 2, m = NULL, ...)
x , y
|
A |
... |
Extra parameters to be passed to internal methods. |
method |
A |
SNR |
An |
m |
An odd |
A local maximum has to be the highest one in the given window and has to be
higher than to be recognized as peak.
The following methods are available for noise estimation:
MAD
Median Absolute Deviation.
Note that to improve peak detection, it may be helpful to smooth the data and remove the baseline beforehand.
Returns a list
with two components x
and y
.
There will be points both at the beginning and at the end
of the data series for which a complete
-width window cannot be
obtained. To prevent data loss, progressively wider/narrower windows are
used at both ends of the data series.
Adapted from Stasia Grinberg's
findPeaks
function.
N. Frerebeau
Other peaks detection methods:
peaks_fwhm()
## X-ray diffraction data("XRD") ## 4S Peak Filling baseline baseline <- baseline_peakfilling(XRD, n = 10, m = 5, by = 10, sparse = TRUE) plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") lines(baseline, type = "l", col = "red") ## Correct baseline XRD <- signal_drift(XRD, lag = baseline, subtract = TRUE) ## Find peaks peaks <- peaks_find(XRD, SNR = 3, m = 11) plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") lines(peaks, type = "p", pch = 16, col = "red") abline(h = attr(peaks, "noise"), lty = 2) # noise threshold ## Half-Width at Half-Maximum x <- seq(-4, 4, length = 1000) y <- dnorm(x) peaks_fwhm(x, y, center = 0) # Expected: 2 * sqrt(2 * log(2))
## X-ray diffraction data("XRD") ## 4S Peak Filling baseline baseline <- baseline_peakfilling(XRD, n = 10, m = 5, by = 10, sparse = TRUE) plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") lines(baseline, type = "l", col = "red") ## Correct baseline XRD <- signal_drift(XRD, lag = baseline, subtract = TRUE) ## Find peaks peaks <- peaks_find(XRD, SNR = 3, m = 11) plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") lines(peaks, type = "p", pch = 16, col = "red") abline(h = attr(peaks, "noise"), lty = 2) # noise threshold ## Half-Width at Half-Maximum x <- seq(-4, 4, length = 1000) y <- dnorm(x) peaks_fwhm(x, y, center = 0) # Expected: 2 * sqrt(2 * log(2))
Estimates the Half-Width at Half-Maximum (FWHM) for a given peak.
peaks_fwhm(x, y, ...) ## S4 method for signature 'numeric,numeric' peaks_fwhm(x, y, center) ## S4 method for signature 'ANY,missing' peaks_fwhm(x, center)
peaks_fwhm(x, y, ...) ## S4 method for signature 'numeric,numeric' peaks_fwhm(x, y, center) ## S4 method for signature 'ANY,missing' peaks_fwhm(x, center)
x , y
|
A |
... |
Currently not used. |
center |
A |
It tries to get the smallest possible estimate.
A numeric
value.
N. Frerebeau
Other peaks detection methods:
peaks_find()
## X-ray diffraction data("XRD") ## 4S Peak Filling baseline baseline <- baseline_peakfilling(XRD, n = 10, m = 5, by = 10, sparse = TRUE) plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") lines(baseline, type = "l", col = "red") ## Correct baseline XRD <- signal_drift(XRD, lag = baseline, subtract = TRUE) ## Find peaks peaks <- peaks_find(XRD, SNR = 3, m = 11) plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") lines(peaks, type = "p", pch = 16, col = "red") abline(h = attr(peaks, "noise"), lty = 2) # noise threshold ## Half-Width at Half-Maximum x <- seq(-4, 4, length = 1000) y <- dnorm(x) peaks_fwhm(x, y, center = 0) # Expected: 2 * sqrt(2 * log(2))
## X-ray diffraction data("XRD") ## 4S Peak Filling baseline baseline <- baseline_peakfilling(XRD, n = 10, m = 5, by = 10, sparse = TRUE) plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") lines(baseline, type = "l", col = "red") ## Correct baseline XRD <- signal_drift(XRD, lag = baseline, subtract = TRUE) ## Find peaks peaks <- peaks_find(XRD, SNR = 3, m = 11) plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") lines(peaks, type = "p", pch = 16, col = "red") abline(h = attr(peaks, "noise"), lty = 2) # noise threshold ## Half-Width at Half-Maximum x <- seq(-4, 4, length = 1000) y <- dnorm(x) peaks_fwhm(x, y, center = 0) # Expected: 2 * sqrt(2 * log(2))
Raman Spectroscopy
Raman
Raman
A data.frame
with 1182 rows and 2 variables.
Raman shift.
Other datasets:
BEGe
,
LaBr
,
XRD
data("Raman") plot(Raman, type = "l", xlab = "Shift", ylab = "Intensity")
data("Raman") plot(Raman, type = "l", xlab = "Shift", ylab = "Intensity")
Replace Negative Values
replace_negative(x, y, ...) ## S4 method for signature 'numeric,numeric' replace_negative(x, y, value = 0) ## S4 method for signature 'ANY,missing' replace_negative(x, value = 0)
replace_negative(x, y, ...) ## S4 method for signature 'numeric,numeric' replace_negative(x, y, value = 0) ## S4 method for signature 'ANY,missing' replace_negative(x, value = 0)
x , y
|
A |
... |
Extra parameters to be passed to |
value |
A |
Returns a list
with two components x
and y
.
N. Frerebeau
Other replacement methods:
replace_threshold()
Replace Values Below a Given Threshold
replace_threshold(x, y, threshold, ...) ## S4 method for signature 'numeric,numeric,function' replace_threshold(x, y, threshold, value = 0, ...) ## S4 method for signature 'ANY,missing,function' replace_threshold(x, threshold, value = 0, ...) ## S4 method for signature 'numeric,numeric,numeric' replace_threshold(x, y, threshold, value = 0, ...) ## S4 method for signature 'ANY,missing,numeric' replace_threshold(x, threshold, value = 0, ...)
replace_threshold(x, y, threshold, ...) ## S4 method for signature 'numeric,numeric,function' replace_threshold(x, y, threshold, value = 0, ...) ## S4 method for signature 'ANY,missing,function' replace_threshold(x, threshold, value = 0, ...) ## S4 method for signature 'numeric,numeric,numeric' replace_threshold(x, y, threshold, value = 0, ...) ## S4 method for signature 'ANY,missing,numeric' replace_threshold(x, threshold, value = 0, ...)
x , y
|
A |
threshold |
A |
... |
Extra parameters to be passed to |
value |
A |
Returns a list
with two components x
and y
.
N. Frerebeau
Other replacement methods:
replace_negative()
Averages x
values and applies a function to the corresponding y
values.
resample_bin(x, y, ...) ## S4 method for signature 'numeric,numeric' resample_bin(x, y, by, f = mean, ...) ## S4 method for signature 'ANY,missing' resample_bin(x, y, by, f = sum)
resample_bin(x, y, ...) ## S4 method for signature 'numeric,numeric' resample_bin(x, y, by, f = mean, ...) ## S4 method for signature 'ANY,missing' resample_bin(x, y, by, f = sum)
x , y
|
A |
... |
Extra parameters to be passed to |
by |
An |
f |
A |
Returns a list
with two components x
and y
.
N. Frerebeau
Other resampling methods:
resample_down()
,
resample_interpolate()
## X-ray diffraction data("XRD") ## Plot spectrum plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") ## Bin by 3 XRD_bin_mean <- resample_bin(XRD, by = 3, f = mean) XRD_bin_min <- resample_bin(XRD, by = 3, f = min) plot(XRD, type = "l", xlim = c(25, 35), xlab = expression(2*theta), ylab = "Count") lines(XRD_bin_mean, type = "l", col = "red") lines(XRD_bin_min, type = "l", col = "green") ## Downsample by 10 XRD_down <- resample_down(XRD, by = 10) plot(XRD, type = "l", xlim = c(20, 40), xlab = expression(2*theta), ylab = "Count") lines(XRD_down, type = "l", col = "red") ## Linearly interpolate XRD_approx <- resample_interpolate(XRD, from = 20, to = 40, by = 0.02) plot(XRD, type = "l", xlim = c(20, 40), xlab = expression(2*theta), ylab = "Count") lines(XRD_approx, type = "l", col = "red")
## X-ray diffraction data("XRD") ## Plot spectrum plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") ## Bin by 3 XRD_bin_mean <- resample_bin(XRD, by = 3, f = mean) XRD_bin_min <- resample_bin(XRD, by = 3, f = min) plot(XRD, type = "l", xlim = c(25, 35), xlab = expression(2*theta), ylab = "Count") lines(XRD_bin_mean, type = "l", col = "red") lines(XRD_bin_min, type = "l", col = "green") ## Downsample by 10 XRD_down <- resample_down(XRD, by = 10) plot(XRD, type = "l", xlim = c(20, 40), xlab = expression(2*theta), ylab = "Count") lines(XRD_down, type = "l", col = "red") ## Linearly interpolate XRD_approx <- resample_interpolate(XRD, from = 20, to = 40, by = 0.02) plot(XRD, type = "l", xlim = c(20, 40), xlab = expression(2*theta), ylab = "Count") lines(XRD_approx, type = "l", col = "red")
Downsample
resample_down(x, y, ...) ## S4 method for signature 'numeric,numeric' resample_down(x, y, by) ## S4 method for signature 'ANY,missing' resample_down(x, y, by)
resample_down(x, y, ...) ## S4 method for signature 'numeric,numeric' resample_down(x, y, by) ## S4 method for signature 'ANY,missing' resample_down(x, y, by)
x , y
|
A |
... |
Currently not used. |
by |
An |
Returns a list
with two components x
and y
.
N. Frerebeau
Other resampling methods:
resample_bin()
,
resample_interpolate()
## X-ray diffraction data("XRD") ## Plot spectrum plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") ## Bin by 3 XRD_bin_mean <- resample_bin(XRD, by = 3, f = mean) XRD_bin_min <- resample_bin(XRD, by = 3, f = min) plot(XRD, type = "l", xlim = c(25, 35), xlab = expression(2*theta), ylab = "Count") lines(XRD_bin_mean, type = "l", col = "red") lines(XRD_bin_min, type = "l", col = "green") ## Downsample by 10 XRD_down <- resample_down(XRD, by = 10) plot(XRD, type = "l", xlim = c(20, 40), xlab = expression(2*theta), ylab = "Count") lines(XRD_down, type = "l", col = "red") ## Linearly interpolate XRD_approx <- resample_interpolate(XRD, from = 20, to = 40, by = 0.02) plot(XRD, type = "l", xlim = c(20, 40), xlab = expression(2*theta), ylab = "Count") lines(XRD_approx, type = "l", col = "red")
## X-ray diffraction data("XRD") ## Plot spectrum plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") ## Bin by 3 XRD_bin_mean <- resample_bin(XRD, by = 3, f = mean) XRD_bin_min <- resample_bin(XRD, by = 3, f = min) plot(XRD, type = "l", xlim = c(25, 35), xlab = expression(2*theta), ylab = "Count") lines(XRD_bin_mean, type = "l", col = "red") lines(XRD_bin_min, type = "l", col = "green") ## Downsample by 10 XRD_down <- resample_down(XRD, by = 10) plot(XRD, type = "l", xlim = c(20, 40), xlab = expression(2*theta), ylab = "Count") lines(XRD_down, type = "l", col = "red") ## Linearly interpolate XRD_approx <- resample_interpolate(XRD, from = 20, to = 40, by = 0.02) plot(XRD, type = "l", xlim = c(20, 40), xlab = expression(2*theta), ylab = "Count") lines(XRD_approx, type = "l", col = "red")
Linearly Interpolate
resample_interpolate(x, y, ...) ## S4 method for signature 'numeric,numeric' resample_interpolate(x, y, from, to, by, ...) ## S4 method for signature 'ANY,missing' resample_interpolate(x, y, from, to, by, ...)
resample_interpolate(x, y, ...) ## S4 method for signature 'numeric,numeric' resample_interpolate(x, y, from, to, by, ...) ## S4 method for signature 'ANY,missing' resample_interpolate(x, y, from, to, by, ...)
x , y
|
A |
... |
Extra arguments to be passed to |
from |
A length-one |
to |
A length-one |
by |
A length-one |
Returns a list
with two components x
and y
.
N. Frerebeau
Other resampling methods:
resample_bin()
,
resample_down()
## X-ray diffraction data("XRD") ## Plot spectrum plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") ## Bin by 3 XRD_bin_mean <- resample_bin(XRD, by = 3, f = mean) XRD_bin_min <- resample_bin(XRD, by = 3, f = min) plot(XRD, type = "l", xlim = c(25, 35), xlab = expression(2*theta), ylab = "Count") lines(XRD_bin_mean, type = "l", col = "red") lines(XRD_bin_min, type = "l", col = "green") ## Downsample by 10 XRD_down <- resample_down(XRD, by = 10) plot(XRD, type = "l", xlim = c(20, 40), xlab = expression(2*theta), ylab = "Count") lines(XRD_down, type = "l", col = "red") ## Linearly interpolate XRD_approx <- resample_interpolate(XRD, from = 20, to = 40, by = 0.02) plot(XRD, type = "l", xlim = c(20, 40), xlab = expression(2*theta), ylab = "Count") lines(XRD_approx, type = "l", col = "red")
## X-ray diffraction data("XRD") ## Plot spectrum plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") ## Bin by 3 XRD_bin_mean <- resample_bin(XRD, by = 3, f = mean) XRD_bin_min <- resample_bin(XRD, by = 3, f = min) plot(XRD, type = "l", xlim = c(25, 35), xlab = expression(2*theta), ylab = "Count") lines(XRD_bin_mean, type = "l", col = "red") lines(XRD_bin_min, type = "l", col = "green") ## Downsample by 10 XRD_down <- resample_down(XRD, by = 10) plot(XRD, type = "l", xlim = c(20, 40), xlab = expression(2*theta), ylab = "Count") lines(XRD_down, type = "l", col = "red") ## Linearly interpolate XRD_approx <- resample_interpolate(XRD, from = 20, to = 40, by = 0.02) plot(XRD, type = "l", xlim = c(20, 40), xlab = expression(2*theta), ylab = "Count") lines(XRD_approx, type = "l", col = "red")
Rescales intensities so that the area under the curve (AUC) is equal to 1.
rescale_area(x, y, ...) ## S4 method for signature 'numeric,numeric' rescale_area(x, y, method = c("rectangle", "trapezoid"), ...) ## S4 method for signature 'ANY,missing' rescale_area(x, method = c("rectangle", "trapezoid"), ...)
rescale_area(x, y, ...) ## S4 method for signature 'numeric,numeric' rescale_area(x, y, method = c("rectangle", "trapezoid"), ...) ## S4 method for signature 'ANY,missing' rescale_area(x, method = c("rectangle", "trapezoid"), ...)
x , y
|
A |
... |
Currently not used. |
method |
A |
Returns a list
with two components x
and y
.
N. Frerebeau
Other normalization methods:
rescale_range()
,
rescale_snv()
,
rescale_total()
,
rescale_transform()
## gamma-ray spectrometry data("BEGe") ## Subset from 2.75 to 200 keV BEGe <- signal_select(BEGe, from = 3, to = 200) ## Plot spectrum plot(BEGe, type = "l", xlab = "Energy (keV)", ylab = "Count") ## Normalize by area under the curve BEGe_area <- rescale_area(BEGe) plot(BEGe_area, type = "l", xlab = "Energy (keV)", ylab = "Count") integrate_rectangle(BEGe) integrate_rectangle(BEGe_area) ## Rescale so that intensities sum to 1 BEGe_total <- rescale_total(BEGe, total = 1) plot(BEGe_total, type = "l", xlab = "Energy (keV)", ylab = "Count") ## Rescale intensities to 0-1 BEGe_range <- rescale_range(BEGe, min = 0, max = 1) plot(BEGe_range, type = "l", xlab = "Energy (keV)", ylab = "Count")
## gamma-ray spectrometry data("BEGe") ## Subset from 2.75 to 200 keV BEGe <- signal_select(BEGe, from = 3, to = 200) ## Plot spectrum plot(BEGe, type = "l", xlab = "Energy (keV)", ylab = "Count") ## Normalize by area under the curve BEGe_area <- rescale_area(BEGe) plot(BEGe_area, type = "l", xlab = "Energy (keV)", ylab = "Count") integrate_rectangle(BEGe) integrate_rectangle(BEGe_area) ## Rescale so that intensities sum to 1 BEGe_total <- rescale_total(BEGe, total = 1) plot(BEGe_total, type = "l", xlab = "Energy (keV)", ylab = "Count") ## Rescale intensities to 0-1 BEGe_range <- rescale_range(BEGe, min = 0, max = 1) plot(BEGe_range, type = "l", xlab = "Energy (keV)", ylab = "Count")
Rescales intensities to have specified minimum and maximum.
rescale_range(x, y, ...) rescale_min(x, y, ...) rescale_max(x, y, ...) ## S4 method for signature 'numeric,numeric' rescale_range(x, y, min = 0, max = 1) ## S4 method for signature 'ANY,missing' rescale_range(x, min = 0, max = 1) ## S4 method for signature 'numeric,numeric' rescale_min(x, y, min = 0) ## S4 method for signature 'ANY,missing' rescale_min(x, min = 0) ## S4 method for signature 'numeric,numeric' rescale_max(x, y, max = 1) ## S4 method for signature 'ANY,missing' rescale_max(x, max = 1)
rescale_range(x, y, ...) rescale_min(x, y, ...) rescale_max(x, y, ...) ## S4 method for signature 'numeric,numeric' rescale_range(x, y, min = 0, max = 1) ## S4 method for signature 'ANY,missing' rescale_range(x, min = 0, max = 1) ## S4 method for signature 'numeric,numeric' rescale_min(x, y, min = 0) ## S4 method for signature 'ANY,missing' rescale_min(x, min = 0) ## S4 method for signature 'numeric,numeric' rescale_max(x, y, max = 1) ## S4 method for signature 'ANY,missing' rescale_max(x, max = 1)
x , y
|
A |
... |
Currently not used. |
min |
A legnth-one |
max |
A legnth-one |
Returns a list
with two components x
and y
.
N. Frerebeau
Other normalization methods:
rescale_area()
,
rescale_snv()
,
rescale_total()
,
rescale_transform()
## gamma-ray spectrometry data("BEGe") ## Subset from 2.75 to 200 keV BEGe <- signal_select(BEGe, from = 3, to = 200) ## Plot spectrum plot(BEGe, type = "l", xlab = "Energy (keV)", ylab = "Count") ## Normalize by area under the curve BEGe_area <- rescale_area(BEGe) plot(BEGe_area, type = "l", xlab = "Energy (keV)", ylab = "Count") integrate_rectangle(BEGe) integrate_rectangle(BEGe_area) ## Rescale so that intensities sum to 1 BEGe_total <- rescale_total(BEGe, total = 1) plot(BEGe_total, type = "l", xlab = "Energy (keV)", ylab = "Count") ## Rescale intensities to 0-1 BEGe_range <- rescale_range(BEGe, min = 0, max = 1) plot(BEGe_range, type = "l", xlab = "Energy (keV)", ylab = "Count")
## gamma-ray spectrometry data("BEGe") ## Subset from 2.75 to 200 keV BEGe <- signal_select(BEGe, from = 3, to = 200) ## Plot spectrum plot(BEGe, type = "l", xlab = "Energy (keV)", ylab = "Count") ## Normalize by area under the curve BEGe_area <- rescale_area(BEGe) plot(BEGe_area, type = "l", xlab = "Energy (keV)", ylab = "Count") integrate_rectangle(BEGe) integrate_rectangle(BEGe_area) ## Rescale so that intensities sum to 1 BEGe_total <- rescale_total(BEGe, total = 1) plot(BEGe_total, type = "l", xlab = "Energy (keV)", ylab = "Count") ## Rescale intensities to 0-1 BEGe_range <- rescale_range(BEGe, min = 0, max = 1) plot(BEGe_range, type = "l", xlab = "Energy (keV)", ylab = "Count")
Subtracts the mean and scales to unit variance.
rescale_snv(x, y, ...) ## S4 method for signature 'numeric,numeric' rescale_snv(x, y, ...) ## S4 method for signature 'ANY,missing' rescale_snv(x, y, ...)
rescale_snv(x, y, ...) ## S4 method for signature 'numeric,numeric' rescale_snv(x, y, ...) ## S4 method for signature 'ANY,missing' rescale_snv(x, y, ...)
x , y
|
A |
... |
Currently not used. |
Returns a list
with two components x
and y
.
N. Frerebeau
Barnes, R. J., Dhanoa, M. S. & Lister, S. J. (1989). Standard Normal Variate Transformation and De-Trending of Near-Infrared Diffuse Reflectance Spectra. Applied Spectroscopy, 43(5): 772-777. doi:10.1366/0003702894202201.
Other normalization methods:
rescale_area()
,
rescale_range()
,
rescale_total()
,
rescale_transform()
## Raman spectrometry data("Raman") ## Subset from 200 to 800 1/cm Raman <- signal_select(Raman, from = 200, to = 800) ## Plot spectrum plot(Raman, type = "l", xlab = "Raman shift", ylab = "Intensity") ## Normalize SNV Raman_snv <- rescale_snv(Raman) plot(Raman_snv, type = "l", xlab = "Raman shift", ylab = "Intensity")
## Raman spectrometry data("Raman") ## Subset from 200 to 800 1/cm Raman <- signal_select(Raman, from = 200, to = 800) ## Plot spectrum plot(Raman, type = "l", xlab = "Raman shift", ylab = "Intensity") ## Normalize SNV Raman_snv <- rescale_snv(Raman) plot(Raman_snv, type = "l", xlab = "Raman shift", ylab = "Intensity")
Rescales intensities to sum to a specified value.
rescale_total(x, y, ...) ## S4 method for signature 'numeric,numeric' rescale_total(x, y, total = 1) ## S4 method for signature 'ANY,missing' rescale_total(x, total = 1)
rescale_total(x, y, ...) ## S4 method for signature 'numeric,numeric' rescale_total(x, y, total = 1) ## S4 method for signature 'ANY,missing' rescale_total(x, total = 1)
x , y
|
A |
... |
Currently not used. |
total |
A legnth-one |
Returns a list
with two components x
and y
.
N. Frerebeau
Other normalization methods:
rescale_area()
,
rescale_range()
,
rescale_snv()
,
rescale_transform()
## gamma-ray spectrometry data("BEGe") ## Subset from 2.75 to 200 keV BEGe <- signal_select(BEGe, from = 3, to = 200) ## Plot spectrum plot(BEGe, type = "l", xlab = "Energy (keV)", ylab = "Count") ## Normalize by area under the curve BEGe_area <- rescale_area(BEGe) plot(BEGe_area, type = "l", xlab = "Energy (keV)", ylab = "Count") integrate_rectangle(BEGe) integrate_rectangle(BEGe_area) ## Rescale so that intensities sum to 1 BEGe_total <- rescale_total(BEGe, total = 1) plot(BEGe_total, type = "l", xlab = "Energy (keV)", ylab = "Count") ## Rescale intensities to 0-1 BEGe_range <- rescale_range(BEGe, min = 0, max = 1) plot(BEGe_range, type = "l", xlab = "Energy (keV)", ylab = "Count")
## gamma-ray spectrometry data("BEGe") ## Subset from 2.75 to 200 keV BEGe <- signal_select(BEGe, from = 3, to = 200) ## Plot spectrum plot(BEGe, type = "l", xlab = "Energy (keV)", ylab = "Count") ## Normalize by area under the curve BEGe_area <- rescale_area(BEGe) plot(BEGe_area, type = "l", xlab = "Energy (keV)", ylab = "Count") integrate_rectangle(BEGe) integrate_rectangle(BEGe_area) ## Rescale so that intensities sum to 1 BEGe_total <- rescale_total(BEGe, total = 1) plot(BEGe_total, type = "l", xlab = "Energy (keV)", ylab = "Count") ## Rescale intensities to 0-1 BEGe_range <- rescale_range(BEGe, min = 0, max = 1) plot(BEGe_range, type = "l", xlab = "Energy (keV)", ylab = "Count")
Transform Intensities
rescale_transform(x, y, ...) ## S4 method for signature 'numeric,numeric' rescale_transform(x, y, f, ...) ## S4 method for signature 'ANY,missing' rescale_transform(x, f, ...)
rescale_transform(x, y, ...) ## S4 method for signature 'numeric,numeric' rescale_transform(x, y, f, ...) ## S4 method for signature 'ANY,missing' rescale_transform(x, f, ...)
x , y
|
A |
... |
Extra arguments to be passed to |
f |
A |
Transformation of intensities can be used to improve the identification of peaks with a low signal-to-noise ratio.
Returns a list
with two components x
and y
.
N. Frerebeau
Other normalization methods:
rescale_area()
,
rescale_range()
,
rescale_snv()
,
rescale_total()
## gamma-ray spectrometry data("BEGe") ## Subset from 2.75 to 200 keV BEGe <- signal_select(BEGe, from = 3, to = 200) ## Plot spectrum plot(BEGe, type = "l", xlab = "Energy (keV)", ylab = "Count") ## Transform intensities BEGe_trans <- rescale_transform(BEGe, f = sqrt) plot(BEGe_trans, type = "l", xlab = "Energy (keV)", ylab = "sqrt(Count)")
## gamma-ray spectrometry data("BEGe") ## Subset from 2.75 to 200 keV BEGe <- signal_select(BEGe, from = 3, to = 200) ## Plot spectrum plot(BEGe, type = "l", xlab = "Energy (keV)", ylab = "Count") ## Transform intensities BEGe_trans <- rescale_transform(BEGe, f = sqrt) plot(BEGe_trans, type = "l", xlab = "Energy (keV)", ylab = "sqrt(Count)")
Combines XY objects.
signal_bind(...) ## S4 method for signature 'ANY' signal_bind(...)
signal_bind(...) ## S4 method for signature 'ANY' signal_bind(...)
... |
Any object that can be interpreted in a suitable way
(see |
Returns a matrix
of intensities.
N. Frerebeau
Other signal processing methods:
signal_correct()
,
signal_drift()
,
signal_mean()
,
signal_shift()
,
subset()
## X-ray diffraction data("XRD") XRD1 <- signal_drift(XRD, lag = 1500) ## Bind XRD_bind <- signal_bind(XRD, XRD1) XRD_bind[, 1:10] ## Mean XRD_mean <- signal_mean(XRD, XRD1) plot(NULL, type = "l", xlim = c(10, 70) , ylim = c(3000, 36000), xlab = expression(2*theta), ylab = "Count") lines(XRD, type = "l") lines(XRD1, type = "l") lines(XRD_mean, type = "l", col = "red")
## X-ray diffraction data("XRD") XRD1 <- signal_drift(XRD, lag = 1500) ## Bind XRD_bind <- signal_bind(XRD, XRD1) XRD_bind[, 1:10] ## Mean XRD_mean <- signal_mean(XRD, XRD1) plot(NULL, type = "l", xlim = c(10, 70) , ylim = c(3000, 36000), xlab = expression(2*theta), ylab = "Count") lines(XRD, type = "l") lines(XRD1, type = "l") lines(XRD_mean, type = "l", col = "red")
Baseline Correction
signal_correct(x, y, ...) ## S4 method for signature 'numeric,numeric' signal_correct( x, y, method = c("linear", "polynomial", "asls", "rollingball", "rubberband", "SNIP", "4S"), ... ) ## S4 method for signature 'ANY,missing' signal_correct( x, method = c("linear", "polynomial", "asls", "rollingball", "rubberband", "SNIP", "4S"), ... )
signal_correct(x, y, ...) ## S4 method for signature 'numeric,numeric' signal_correct( x, y, method = c("linear", "polynomial", "asls", "rollingball", "rubberband", "SNIP", "4S"), ... ) ## S4 method for signature 'ANY,missing' signal_correct( x, method = c("linear", "polynomial", "asls", "rollingball", "rubberband", "SNIP", "4S"), ... )
x , y
|
A |
... |
Extra arguments to be passed to |
method |
A |
Available methods for baseline estimation:
asls
Asymmetric Least Squares Smoothing (see baseline_asls()
).
linear
Linear baseline estimation (see baseline_linear()
).
polynomial
Polynomial baseline estimation (see
baseline_polynomial()
).
rollingball
Rolling ball baseline estimation (see
baseline_rollingball()
).
rubberband
Rubberband baseline estimation (see
baseline_rubberband()
).
SNIP
Sensitive Nonlinear Iterative Peak clipping algorithm
(see baseline_snip()
).
4S
4S Peak Filling (see baseline_peakfilling()
).
Returns a list
with two components x
and y
.
N. Frerebeau
Other signal processing methods:
signal_bind()
,
signal_drift()
,
signal_mean()
,
signal_shift()
,
subset()
## gamma-ray spectrometry data("BEGe") ## Subset from 2.75 to 200 keV BEGe <- signal_select(BEGe, from = 3, to = 200) ## Drift baseline <- baseline_snip(BEGe) BEGe_drif <- signal_drift(BEGe, lag = baseline, subtract = TRUE) plot(BEGe, type = "l", xlab = "Energy (keV)", ylab = "Count") lines(BEGe_drif, type = "l", col = "red") ## Correct BEGe_corr <- signal_correct(BEGe, method = "SNIP") plot(BEGe, type = "l", xlab = "Energy (keV)", ylab = "Count") lines(BEGe_corr, type = "l", col = "red")
## gamma-ray spectrometry data("BEGe") ## Subset from 2.75 to 200 keV BEGe <- signal_select(BEGe, from = 3, to = 200) ## Drift baseline <- baseline_snip(BEGe) BEGe_drif <- signal_drift(BEGe, lag = baseline, subtract = TRUE) plot(BEGe, type = "l", xlab = "Energy (keV)", ylab = "Count") lines(BEGe_drif, type = "l", col = "red") ## Correct BEGe_corr <- signal_correct(BEGe, method = "SNIP") plot(BEGe, type = "l", xlab = "Energy (keV)", ylab = "Count") lines(BEGe_corr, type = "l", col = "red")
Drift Intensities
signal_drift(x, y, lag, ...) ## S4 method for signature 'numeric,numeric,numeric' signal_drift(x, y, lag) ## S4 method for signature 'ANY,missing,ANY' signal_drift(x, lag, subtract = FALSE)
signal_drift(x, y, lag, ...) ## S4 method for signature 'numeric,numeric,numeric' signal_drift(x, y, lag) ## S4 method for signature 'ANY,missing,ANY' signal_drift(x, lag, subtract = FALSE)
x , y
|
A |
lag |
A |
... |
Currently not used. |
subtract |
A |
Returns a list
with two components x
and y
.
N. Frerebeau
Other signal processing methods:
signal_bind()
,
signal_correct()
,
signal_mean()
,
signal_shift()
,
subset()
## gamma-ray spectrometry data("BEGe") ## Subset from 2.75 to 200 keV BEGe <- signal_select(BEGe, from = 3, to = 200) ## Drift BEGe_plus <- signal_drift(BEGe, lag = 250) BEGe_minus <- signal_drift(BEGe, lag = 250, subtract = TRUE) plot(BEGe, type = "l", xlab = "Energy (keV)", ylab = "Count") lines(BEGe_plus, type = "l", col = "red") lines(BEGe_minus, type = "l", col = "green")
## gamma-ray spectrometry data("BEGe") ## Subset from 2.75 to 200 keV BEGe <- signal_select(BEGe, from = 3, to = 200) ## Drift BEGe_plus <- signal_drift(BEGe, lag = 250) BEGe_minus <- signal_drift(BEGe, lag = 250, subtract = TRUE) plot(BEGe, type = "l", xlab = "Energy (keV)", ylab = "Count") lines(BEGe_plus, type = "l", col = "red") lines(BEGe_minus, type = "l", col = "green")
Mean Intensities
signal_mean(...) ## S4 method for signature 'ANY' signal_mean(...)
signal_mean(...) ## S4 method for signature 'ANY' signal_mean(...)
... |
Any object that can be interpreted in a suitable way
(see |
Returns a list
with two components x
and y
.
N. Frerebeau
Other signal processing methods:
signal_bind()
,
signal_correct()
,
signal_drift()
,
signal_shift()
,
subset()
## X-ray diffraction data("XRD") XRD1 <- signal_drift(XRD, lag = 1500) ## Bind XRD_bind <- signal_bind(XRD, XRD1) XRD_bind[, 1:10] ## Mean XRD_mean <- signal_mean(XRD, XRD1) plot(NULL, type = "l", xlim = c(10, 70) , ylim = c(3000, 36000), xlab = expression(2*theta), ylab = "Count") lines(XRD, type = "l") lines(XRD1, type = "l") lines(XRD_mean, type = "l", col = "red")
## X-ray diffraction data("XRD") XRD1 <- signal_drift(XRD, lag = 1500) ## Bind XRD_bind <- signal_bind(XRD, XRD1) XRD_bind[, 1:10] ## Mean XRD_mean <- signal_mean(XRD, XRD1) plot(NULL, type = "l", xlim = c(10, 70) , ylim = c(3000, 36000), xlab = expression(2*theta), ylab = "Count") lines(XRD, type = "l") lines(XRD1, type = "l") lines(XRD_mean, type = "l", col = "red")
Shifts the x
scale by a given value.
signal_shift(x, y, lag, ...) ## S4 method for signature 'numeric,numeric' signal_shift(x, y, lag) ## S4 method for signature 'ANY,missing' signal_shift(x, lag)
signal_shift(x, y, lag, ...) ## S4 method for signature 'numeric,numeric' signal_shift(x, y, lag) ## S4 method for signature 'ANY,missing' signal_shift(x, lag)
x , y
|
A |
lag |
A |
... |
Currently not used. |
Returns a list
with two components x
and y
.
N. Frerebeau
Other signal processing methods:
signal_bind()
,
signal_correct()
,
signal_drift()
,
signal_mean()
,
subset()
## X-ray diffraction data("XRD") ## Plot spectrum plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") ## Shift by one degree XRD_offset <- signal_shift(XRD, lag = 1) lines(XRD_offset, type = "l", col = "red")
## X-ray diffraction data("XRD") ## Plot spectrum plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") ## Shift by one degree XRD_offset <- signal_shift(XRD, lag = 1) lines(XRD_offset, type = "l", col = "red")
Penalized Likelihood Smoothing
smooth_likelihood(x, y, ...) ## S4 method for signature 'numeric,numeric' smooth_likelihood(x, y, lambda, d = 2, SE = FALSE, progress = interactive()) ## S4 method for signature 'ANY,missing' smooth_likelihood(x, lambda, d = 2, SE = FALSE, progress = interactive())
smooth_likelihood(x, y, ...) ## S4 method for signature 'numeric,numeric' smooth_likelihood(x, y, lambda, d = 2, SE = FALSE, progress = interactive()) ## S4 method for signature 'ANY,missing' smooth_likelihood(x, lambda, d = 2, SE = FALSE, progress = interactive())
x , y
|
A |
... |
Currently not used. |
lambda |
An |
d |
An |
SE |
A |
progress |
A |
Returns a list
with two components x
and y
.
Matrix is required.
J. J. de Rooi et al. (original R code).
de Rooi, J. J., van der Pers, N. M., Hendrikx, R. W. A., Delhez, R., Böttger A. J. and Eilers, P. H. C. (2014). Smoothing of X-ray diffraction data and Ka2 elimination using penalized likelihood and the composite link model. Journal of Applied Crystallography, 47: 852-860. doi:10.1107/S1600576714005809
Other smoothing methods:
smooth_loess()
,
smooth_rectangular()
,
smooth_savitzky()
,
smooth_triangular()
,
smooth_whittaker()
## Not run: ## X-ray diffraction data("XRD") ## Subset from 20 to 40 degrees XRD <- signal_select(XRD, from = 20, to = 40) ## Plot diffractogram plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") ## Penalized likelihood smoothing lambda <- seq(from = 1, to = 8, length.out = 40) lambda <- 10^lambda likelihood <- smooth_likelihood(XRD, lambda = lambda, d = 3) lines(likelihood, col = "red") ## Strip ka2 ka2 <- ka2_strip_penalized(XRD, lambda = lambda, tau = 0.5, nseg = 1) lines(ka2, col = "blue") ## End(Not run)
## Not run: ## X-ray diffraction data("XRD") ## Subset from 20 to 40 degrees XRD <- signal_select(XRD, from = 20, to = 40) ## Plot diffractogram plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count") ## Penalized likelihood smoothing lambda <- seq(from = 1, to = 8, length.out = 40) lambda <- 10^lambda likelihood <- smooth_likelihood(XRD, lambda = lambda, d = 3) lines(likelihood, col = "red") ## Strip ka2 ka2 <- ka2_strip_penalized(XRD, lambda = lambda, tau = 0.5, nseg = 1) lines(ka2, col = "blue") ## End(Not run)
Smoothes intensities by loess fitting.
smooth_loess(x, y, ...) ## S4 method for signature 'numeric,numeric' smooth_loess(x, y, span = 0.75, ...) ## S4 method for signature 'ANY,missing' smooth_loess(x, span = 0.75, ...)
smooth_loess(x, y, ...) ## S4 method for signature 'numeric,numeric' smooth_loess(x, y, span = 0.75, ...) ## S4 method for signature 'ANY,missing' smooth_loess(x, span = 0.75, ...)
x , y
|
A |
... |
Extra arguments to be passed to |
span |
An |
Returns a list
with two components x
and y
.
N. Frerebeau
Other smoothing methods:
smooth_likelihood()
,
smooth_rectangular()
,
smooth_savitzky()
,
smooth_triangular()
,
smooth_whittaker()
## Simulate data with some noise x <- seq(-4, 4, length = 100) y <- dnorm(x) + rnorm(100, mean = 0, sd = 0.01) ## Plot spectrum plot(x, y, type = "l", xlab = "", ylab = "") ## Rectangular smoothing unweighted <- smooth_rectangular(x, y, m = 3) plot(unweighted, type = "l", xlab = "", ylab = "") ## Triangular smoothing weighted <- smooth_triangular(x, y, m = 5) plot(weighted, type = "l", xlab = "", ylab = "") ## Loess smoothing loess <- smooth_loess(x, y, span = 0.75) plot(loess, type = "l", xlab = "", ylab = "") ## Savitzky–Golay filter savitzky <- smooth_savitzky(x, y, m = 21, p = 2) plot(savitzky, type = "l", xlab = "", ylab = "") ## Whittaker smoothing whittaker <- smooth_whittaker(x, y, lambda = 1600, d = 2) plot(whittaker, type = "l", xlab = "", ylab = "")
## Simulate data with some noise x <- seq(-4, 4, length = 100) y <- dnorm(x) + rnorm(100, mean = 0, sd = 0.01) ## Plot spectrum plot(x, y, type = "l", xlab = "", ylab = "") ## Rectangular smoothing unweighted <- smooth_rectangular(x, y, m = 3) plot(unweighted, type = "l", xlab = "", ylab = "") ## Triangular smoothing weighted <- smooth_triangular(x, y, m = 5) plot(weighted, type = "l", xlab = "", ylab = "") ## Loess smoothing loess <- smooth_loess(x, y, span = 0.75) plot(loess, type = "l", xlab = "", ylab = "") ## Savitzky–Golay filter savitzky <- smooth_savitzky(x, y, m = 21, p = 2) plot(savitzky, type = "l", xlab = "", ylab = "") ## Whittaker smoothing whittaker <- smooth_whittaker(x, y, lambda = 1600, d = 2) plot(whittaker, type = "l", xlab = "", ylab = "")
Unweighted sliding-average or rectangular Smoothing.
smooth_rectangular(x, y, ...) ## S4 method for signature 'numeric,numeric' smooth_rectangular(x, y, m = 3) ## S4 method for signature 'ANY,missing' smooth_rectangular(x, m)
smooth_rectangular(x, y, ...) ## S4 method for signature 'numeric,numeric' smooth_rectangular(x, y, m = 3) ## S4 method for signature 'ANY,missing' smooth_rectangular(x, m)
x , y
|
A |
... |
Currently not used. |
m |
An odd |
It replaces each point in the signal with the average of adjacent
points.
Returns a list
with two components x
and y
.
There will be points both at the beginning and at the end
of the data series for which a complete
-width window cannot be
obtained. To prevent data loss, progressively wider/narrower windows are
used at both ends of the data series.
N. Frerebeau
Other smoothing methods:
smooth_likelihood()
,
smooth_loess()
,
smooth_savitzky()
,
smooth_triangular()
,
smooth_whittaker()
## Simulate data with some noise x <- seq(-4, 4, length = 100) y <- dnorm(x) + rnorm(100, mean = 0, sd = 0.01) ## Plot spectrum plot(x, y, type = "l", xlab = "", ylab = "") ## Rectangular smoothing unweighted <- smooth_rectangular(x, y, m = 3) plot(unweighted, type = "l", xlab = "", ylab = "") ## Triangular smoothing weighted <- smooth_triangular(x, y, m = 5) plot(weighted, type = "l", xlab = "", ylab = "") ## Loess smoothing loess <- smooth_loess(x, y, span = 0.75) plot(loess, type = "l", xlab = "", ylab = "") ## Savitzky–Golay filter savitzky <- smooth_savitzky(x, y, m = 21, p = 2) plot(savitzky, type = "l", xlab = "", ylab = "") ## Whittaker smoothing whittaker <- smooth_whittaker(x, y, lambda = 1600, d = 2) plot(whittaker, type = "l", xlab = "", ylab = "")
## Simulate data with some noise x <- seq(-4, 4, length = 100) y <- dnorm(x) + rnorm(100, mean = 0, sd = 0.01) ## Plot spectrum plot(x, y, type = "l", xlab = "", ylab = "") ## Rectangular smoothing unweighted <- smooth_rectangular(x, y, m = 3) plot(unweighted, type = "l", xlab = "", ylab = "") ## Triangular smoothing weighted <- smooth_triangular(x, y, m = 5) plot(weighted, type = "l", xlab = "", ylab = "") ## Loess smoothing loess <- smooth_loess(x, y, span = 0.75) plot(loess, type = "l", xlab = "", ylab = "") ## Savitzky–Golay filter savitzky <- smooth_savitzky(x, y, m = 21, p = 2) plot(savitzky, type = "l", xlab = "", ylab = "") ## Whittaker smoothing whittaker <- smooth_whittaker(x, y, lambda = 1600, d = 2) plot(whittaker, type = "l", xlab = "", ylab = "")
Savitzky-Golay Filter
smooth_savitzky(x, y, ...) ## S4 method for signature 'numeric,numeric' smooth_savitzky(x, y, m = 3, p = 2) ## S4 method for signature 'ANY,missing' smooth_savitzky(x, m, p)
smooth_savitzky(x, y, ...) ## S4 method for signature 'numeric,numeric' smooth_savitzky(x, y, m = 3, p = 2) ## S4 method for signature 'ANY,missing' smooth_savitzky(x, m, p)
x , y
|
A |
... |
Currently not used. |
m |
An odd |
p |
An |
This method is based on the least-squares fitting of polynomials to
segments of adjacent points.
Returns a list
with two components x
and y
.
There will be points both at the beginning and at the end
of the data series for which a complete
-width window cannot be
obtained. To prevent data loss, the original
points at
both ends of the data series are preserved.
N. Frerebeau
Gorry, P. A. (1990). General Least-Squares Smoothing and Differentiation by the Convolution (Savitzky-Golay) Method. Analytical Chemistry, 62(6), p. 570-573. doi:10.1021/ac00205a007.
Savitzky, A. & Golay, M. J. E. (1964). Smoothing and Differentiation of Data by Simplified Least Squares Procedures. Analytical Chemistry, 36(8), p. 1627-1639. doi:10.1021/ac60214a047.
Other smoothing methods:
smooth_likelihood()
,
smooth_loess()
,
smooth_rectangular()
,
smooth_triangular()
,
smooth_whittaker()
## Simulate data with some noise x <- seq(-4, 4, length = 100) y <- dnorm(x) + rnorm(100, mean = 0, sd = 0.01) ## Plot spectrum plot(x, y, type = "l", xlab = "", ylab = "") ## Rectangular smoothing unweighted <- smooth_rectangular(x, y, m = 3) plot(unweighted, type = "l", xlab = "", ylab = "") ## Triangular smoothing weighted <- smooth_triangular(x, y, m = 5) plot(weighted, type = "l", xlab = "", ylab = "") ## Loess smoothing loess <- smooth_loess(x, y, span = 0.75) plot(loess, type = "l", xlab = "", ylab = "") ## Savitzky–Golay filter savitzky <- smooth_savitzky(x, y, m = 21, p = 2) plot(savitzky, type = "l", xlab = "", ylab = "") ## Whittaker smoothing whittaker <- smooth_whittaker(x, y, lambda = 1600, d = 2) plot(whittaker, type = "l", xlab = "", ylab = "")
## Simulate data with some noise x <- seq(-4, 4, length = 100) y <- dnorm(x) + rnorm(100, mean = 0, sd = 0.01) ## Plot spectrum plot(x, y, type = "l", xlab = "", ylab = "") ## Rectangular smoothing unweighted <- smooth_rectangular(x, y, m = 3) plot(unweighted, type = "l", xlab = "", ylab = "") ## Triangular smoothing weighted <- smooth_triangular(x, y, m = 5) plot(weighted, type = "l", xlab = "", ylab = "") ## Loess smoothing loess <- smooth_loess(x, y, span = 0.75) plot(loess, type = "l", xlab = "", ylab = "") ## Savitzky–Golay filter savitzky <- smooth_savitzky(x, y, m = 21, p = 2) plot(savitzky, type = "l", xlab = "", ylab = "") ## Whittaker smoothing whittaker <- smooth_whittaker(x, y, lambda = 1600, d = 2) plot(whittaker, type = "l", xlab = "", ylab = "")
Weighted sliding-average or triangular smoothing.
smooth_triangular(x, y, ...) ## S4 method for signature 'numeric,numeric' smooth_triangular(x, y, m = 3) ## S4 method for signature 'ANY,missing' smooth_triangular(x, m)
smooth_triangular(x, y, ...) ## S4 method for signature 'numeric,numeric' smooth_triangular(x, y, m = 3) ## S4 method for signature 'ANY,missing' smooth_triangular(x, m)
x , y
|
A |
... |
Currently not used. |
m |
An odd |
It replaces each point in the signal with the weighted mean of
adjacent points.
Returns a list
with two components x
and y
.
There will be points both at the beginning and at the end
of the data series for which a complete
-width window cannot be
obtained. To prevent data loss, progressively wider/narrower windows are
used at both ends of the data series.
N. Frerebeau
Other smoothing methods:
smooth_likelihood()
,
smooth_loess()
,
smooth_rectangular()
,
smooth_savitzky()
,
smooth_whittaker()
## Simulate data with some noise x <- seq(-4, 4, length = 100) y <- dnorm(x) + rnorm(100, mean = 0, sd = 0.01) ## Plot spectrum plot(x, y, type = "l", xlab = "", ylab = "") ## Rectangular smoothing unweighted <- smooth_rectangular(x, y, m = 3) plot(unweighted, type = "l", xlab = "", ylab = "") ## Triangular smoothing weighted <- smooth_triangular(x, y, m = 5) plot(weighted, type = "l", xlab = "", ylab = "") ## Loess smoothing loess <- smooth_loess(x, y, span = 0.75) plot(loess, type = "l", xlab = "", ylab = "") ## Savitzky–Golay filter savitzky <- smooth_savitzky(x, y, m = 21, p = 2) plot(savitzky, type = "l", xlab = "", ylab = "") ## Whittaker smoothing whittaker <- smooth_whittaker(x, y, lambda = 1600, d = 2) plot(whittaker, type = "l", xlab = "", ylab = "")
## Simulate data with some noise x <- seq(-4, 4, length = 100) y <- dnorm(x) + rnorm(100, mean = 0, sd = 0.01) ## Plot spectrum plot(x, y, type = "l", xlab = "", ylab = "") ## Rectangular smoothing unweighted <- smooth_rectangular(x, y, m = 3) plot(unweighted, type = "l", xlab = "", ylab = "") ## Triangular smoothing weighted <- smooth_triangular(x, y, m = 5) plot(weighted, type = "l", xlab = "", ylab = "") ## Loess smoothing loess <- smooth_loess(x, y, span = 0.75) plot(loess, type = "l", xlab = "", ylab = "") ## Savitzky–Golay filter savitzky <- smooth_savitzky(x, y, m = 21, p = 2) plot(savitzky, type = "l", xlab = "", ylab = "") ## Whittaker smoothing whittaker <- smooth_whittaker(x, y, lambda = 1600, d = 2) plot(whittaker, type = "l", xlab = "", ylab = "")
Whittaker Smoothing
smooth_whittaker(x, y, ...) ## S4 method for signature 'numeric,numeric' smooth_whittaker(x, y, lambda = 1600, d = 2, sparse = FALSE) ## S4 method for signature 'ANY,missing' smooth_whittaker(x, lambda = 1600, d = 2, sparse = FALSE)
smooth_whittaker(x, y, ...) ## S4 method for signature 'numeric,numeric' smooth_whittaker(x, y, lambda = 1600, d = 2, sparse = FALSE) ## S4 method for signature 'ANY,missing' smooth_whittaker(x, lambda = 1600, d = 2, sparse = FALSE)
x , y
|
A |
... |
Currently not used. |
lambda |
An |
d |
An |
sparse |
A |
Returns a list
with two components x
and y
.
N. Frerebeau
Eilers, P. H. C. (2003). A Perfect Smoother. Analytical Chemistry, 75(14): 3631-36. doi:10.1021/ac034173t.
Other smoothing methods:
smooth_likelihood()
,
smooth_loess()
,
smooth_rectangular()
,
smooth_savitzky()
,
smooth_triangular()
## Simulate data with some noise x <- seq(-4, 4, length = 100) y <- dnorm(x) + rnorm(100, mean = 0, sd = 0.01) ## Plot spectrum plot(x, y, type = "l", xlab = "", ylab = "") ## Rectangular smoothing unweighted <- smooth_rectangular(x, y, m = 3) plot(unweighted, type = "l", xlab = "", ylab = "") ## Triangular smoothing weighted <- smooth_triangular(x, y, m = 5) plot(weighted, type = "l", xlab = "", ylab = "") ## Loess smoothing loess <- smooth_loess(x, y, span = 0.75) plot(loess, type = "l", xlab = "", ylab = "") ## Savitzky–Golay filter savitzky <- smooth_savitzky(x, y, m = 21, p = 2) plot(savitzky, type = "l", xlab = "", ylab = "") ## Whittaker smoothing whittaker <- smooth_whittaker(x, y, lambda = 1600, d = 2) plot(whittaker, type = "l", xlab = "", ylab = "")
## Simulate data with some noise x <- seq(-4, 4, length = 100) y <- dnorm(x) + rnorm(100, mean = 0, sd = 0.01) ## Plot spectrum plot(x, y, type = "l", xlab = "", ylab = "") ## Rectangular smoothing unweighted <- smooth_rectangular(x, y, m = 3) plot(unweighted, type = "l", xlab = "", ylab = "") ## Triangular smoothing weighted <- smooth_triangular(x, y, m = 5) plot(weighted, type = "l", xlab = "", ylab = "") ## Loess smoothing loess <- smooth_loess(x, y, span = 0.75) plot(loess, type = "l", xlab = "", ylab = "") ## Savitzky–Golay filter savitzky <- smooth_savitzky(x, y, m = 21, p = 2) plot(savitzky, type = "l", xlab = "", ylab = "") ## Whittaker smoothing whittaker <- smooth_whittaker(x, y, lambda = 1600, d = 2) plot(whittaker, type = "l", xlab = "", ylab = "")
signal_select()
allows to subset by values of x
.
signal_slice()
allows to subset by position along x
.
signal_select(x, y, ...) signal_slice(x, y, ...) ## S4 method for signature 'numeric,numeric' signal_select(x, y, from, to) ## S4 method for signature 'ANY,missing' signal_select(x, from, to) ## S4 method for signature 'numeric,numeric' signal_slice(x, y, subset) ## S4 method for signature 'ANY,missing' signal_slice(x, subset)
signal_select(x, y, ...) signal_slice(x, y, ...) ## S4 method for signature 'numeric,numeric' signal_select(x, y, from, to) ## S4 method for signature 'ANY,missing' signal_select(x, from, to) ## S4 method for signature 'numeric,numeric' signal_slice(x, y, subset) ## S4 method for signature 'ANY,missing' signal_slice(x, subset)
x , y
|
A |
... |
Currently not used. |
from , to
|
A |
subset |
An |
Returns a list
with two components x
and y
.
N. Frerebeau
Other signal processing methods:
signal_bind()
,
signal_correct()
,
signal_drift()
,
signal_mean()
,
signal_shift()
## gamma-ray spectrometry data("BEGe") ## Plot spectrum plot(BEGe, type = "l", xlab = "Energy (keV)", ylab = "Count") ## Subset from 2.75 keV to 200 keV BEGe_1 <- signal_select(BEGe, from = 3, to = 200) ## Plot spectrum plot(BEGe_1, type = "l", xlab = "Energy (keV)", ylab = "Count") ## Subset from the 20th to the 1250th value BEGe_2 <- signal_slice(BEGe, subset = 20:1250) ## Plot spectrum plot(BEGe_2, type = "l", xlab = "Energy (keV)", ylab = "Count")
## gamma-ray spectrometry data("BEGe") ## Plot spectrum plot(BEGe, type = "l", xlab = "Energy (keV)", ylab = "Count") ## Subset from 2.75 keV to 200 keV BEGe_1 <- signal_select(BEGe, from = 3, to = 200) ## Plot spectrum plot(BEGe_1, type = "l", xlab = "Energy (keV)", ylab = "Count") ## Subset from the 20th to the 1250th value BEGe_2 <- signal_slice(BEGe, subset = 20:1250) ## Plot spectrum plot(BEGe_2, type = "l", xlab = "Energy (keV)", ylab = "Count")
There will be points both at the beginning and at the end
of the data series for which a complete
-width window cannot be
obtained. To prevent data loss, progressively wider/narrower windows are
evaluated at both ends of the data series.
window_sliding(n, m, ...) ## S4 method for signature 'integer,integer' window_sliding(n, m, i = NULL) ## S4 method for signature 'numeric,numeric' window_sliding(n, m, i = NULL)
window_sliding(n, m, ...) ## S4 method for signature 'integer,integer' window_sliding(n, m, i = NULL) ## S4 method for signature 'numeric,numeric' window_sliding(n, m, i = NULL)
n |
An |
m |
An odd |
... |
Currently not used. |
i |
A vector |
Returns a length-
list
of integer
vectors (indices of the
data points in each window).
N. Frerebeau
Other moving windows:
window_tumbling()
## Length of the data series n <- 10 ## Progressive sliding windows sliding <- window_sliding(n = n, m = 5) plot(NULL, xlim = c(1, n), ylim = c(1, 10.5), xlab = "Index", ylab = "Window") for (i in seq_along(sliding)) { w <- sliding[[i]] text(x = w, y = rep(i, length(w)), labels = w, pos = 3) lines(w, rep(i, length(w)), type = "l", lwd = 2) } ## Tumbling windows ## (compare with drop = TRUE) tumbling <- window_tumbling(n = n, m = 3, drop = FALSE) plot(NULL, xlim = c(1, n), ylim = c(1, 5.5), xlab = "Index", ylab = "Window") for (i in seq_along(tumbling)) { w <- tumbling[[i]] text(x = w, y = rep(i, length(w)), labels = w, pos = 3) lines(w, rep(i, length(w)), type = "l", lwd = 2) }
## Length of the data series n <- 10 ## Progressive sliding windows sliding <- window_sliding(n = n, m = 5) plot(NULL, xlim = c(1, n), ylim = c(1, 10.5), xlab = "Index", ylab = "Window") for (i in seq_along(sliding)) { w <- sliding[[i]] text(x = w, y = rep(i, length(w)), labels = w, pos = 3) lines(w, rep(i, length(w)), type = "l", lwd = 2) } ## Tumbling windows ## (compare with drop = TRUE) tumbling <- window_tumbling(n = n, m = 3, drop = FALSE) plot(NULL, xlim = c(1, n), ylim = c(1, 5.5), xlab = "Index", ylab = "Window") for (i in seq_along(tumbling)) { w <- tumbling[[i]] text(x = w, y = rep(i, length(w)), labels = w, pos = 3) lines(w, rep(i, length(w)), type = "l", lwd = 2) }
Tumbling Windows
window_tumbling(n, m, ...) ## S4 method for signature 'integer,integer' window_tumbling(n, m, drop = FALSE) ## S4 method for signature 'numeric,numeric' window_tumbling(n, m, drop = FALSE)
window_tumbling(n, m, ...) ## S4 method for signature 'integer,integer' window_tumbling(n, m, drop = FALSE) ## S4 method for signature 'numeric,numeric' window_tumbling(n, m, drop = FALSE)
n |
An |
m |
An |
... |
Currently not used. |
drop |
A |
Returns a list
of integer
vectors (indices of the data points in
each window).
N. Frerebeau
Other moving windows:
window_sliding()
## Length of the data series n <- 10 ## Progressive sliding windows sliding <- window_sliding(n = n, m = 5) plot(NULL, xlim = c(1, n), ylim = c(1, 10.5), xlab = "Index", ylab = "Window") for (i in seq_along(sliding)) { w <- sliding[[i]] text(x = w, y = rep(i, length(w)), labels = w, pos = 3) lines(w, rep(i, length(w)), type = "l", lwd = 2) } ## Tumbling windows ## (compare with drop = TRUE) tumbling <- window_tumbling(n = n, m = 3, drop = FALSE) plot(NULL, xlim = c(1, n), ylim = c(1, 5.5), xlab = "Index", ylab = "Window") for (i in seq_along(tumbling)) { w <- tumbling[[i]] text(x = w, y = rep(i, length(w)), labels = w, pos = 3) lines(w, rep(i, length(w)), type = "l", lwd = 2) }
## Length of the data series n <- 10 ## Progressive sliding windows sliding <- window_sliding(n = n, m = 5) plot(NULL, xlim = c(1, n), ylim = c(1, 10.5), xlab = "Index", ylab = "Window") for (i in seq_along(sliding)) { w <- sliding[[i]] text(x = w, y = rep(i, length(w)), labels = w, pos = 3) lines(w, rep(i, length(w)), type = "l", lwd = 2) } ## Tumbling windows ## (compare with drop = TRUE) tumbling <- window_tumbling(n = n, m = 3, drop = FALSE) plot(NULL, xlim = c(1, n), ylim = c(1, 5.5), xlab = "Index", ylab = "Window") for (i in seq_along(tumbling)) { w <- tumbling[[i]] text(x = w, y = rep(i, length(w)), labels = w, pos = 3) lines(w, rep(i, length(w)), type = "l", lwd = 2) }
Powder X-ray Diffraction
XRD
XRD
A data.frame
with 2989 rows and 2 variables.
Other datasets:
BEGe
,
LaBr
,
Raman
data("XRD") plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count")
data("XRD") plot(XRD, type = "l", xlab = expression(2*theta), ylab = "Count")