The short reprex below shows how the Savitzky-Golay implementation that we have on MassSpecWavelet does not filter properly the signal boundaries. We can see in the figure that the implementation from the signal package works well. It's not a critical issue since it just affects few points at the border, and it is just used to optionally skip some peak detection computations... but it would be nice to get it done right.
data("exampleMS", package = "MassSpecWavelet")
# Filter the signal:
filtered_with_sav_gol <- MassSpecWavelet:::sav.gol(exampleMS, fl =13, forder=2, dorder=0)
filtered_with_sgolayfilt <- signal::sgolayfilt(exampleMS, p = 2, n = 13)
# Plot
plot(exampleMS, type = "l", xlim = c(1, 24), ylim = c(300, 1300), main = "sav.gol() is wrong close to the end points")
abline(v = 7, col = "blue")
lines(filtered_with_sav_gol, col = "red", lty = 2)
lines(filtered_with_sgolayfilt, col = "darkgreen", lty = 3)
legend(
x = "topright",
c("Raw signal", "MassSpecWavelet:::sav.gol()", "signal::sgolayfilt()", "half of filter length"),
col = c("black", "red", "darkgreen", "blue"),
lty = c(1,2,3, 1)
)
[x] Add the signal package to Suggests: (the interface of the signal package hasn't change much in the last 10 years)
[x] Change peakDetectionCWT(), replacing sav.gol() with the corresponding signal::sgolayfilt() call. If signal is not installed, raise an error asking the user to install it. Keep the current peakDetectionCWT() parameter structure to avoid breaking backwards compatiblity
[x] Document the fl, forder, dorder parameters in the ... argument of the peakDetectionCWT() page.
[x] Remove the internal sav.gol() and related functions (none of them are exported, including: pinv, conv and convolve2 in C)
[x] Remove the documentation page for the sav.gol function.
The xcms package seems to be the main user of this function and these filtering options were added by Steffen Neumann, so I'm mentioning you (@sneumann) to get feedback and see if I may be missing anything.
The short reprex below shows how the Savitzky-Golay implementation that we have on MassSpecWavelet does not filter properly the signal boundaries. We can see in the figure that the implementation from the
signal
package works well. It's not a critical issue since it just affects few points at the border, and it is just used to optionally skip some peak detection computations... but it would be nice to get it done right.Created on 2022-04-04 by the reprex package (v2.0.1)
My plan to address this is:
signal
package toSuggests:
(the interface of the signal package hasn't change much in the last 10 years)peakDetectionCWT()
, replacingsav.gol()
with the correspondingsignal::sgolayfilt()
call. Ifsignal
is not installed, raise an error asking the user to install it. Keep the currentpeakDetectionCWT()
parameter structure to avoid breaking backwards compatiblityfl
,forder
,dorder
parameters in the...
argument of thepeakDetectionCWT()
page.sav.gol()
and related functions (none of them are exported, including:pinv
,conv
andconvolve2
in C)sav.gol
function.peakDetectionCWT()
instead of pointing tosav.gol
.The
xcms
package seems to be the main user of this function and these filtering options were added by Steffen Neumann, so I'm mentioning you (@sneumann) to get feedback and see if I may be missing anything.