Practical Wavelet Transform Workflow in R (Feature Extraction & Denoising)

Hi everyone,

I’ve been working on wavelet transform methods for time series and signal data, and I wanted to share a simple, practical workflow in R that might be useful—especially for feature extraction and denoising.

Here’s a minimal example using waveslim:

library(waveslim)

# Example signal
set.seed(123)
x <- sin(seq(0, 8*pi, length.out = 256)) + rnorm(256, 0, 0.5)

# Discrete Wavelet Transform
wt <- dwt(x, wf = "la8", n.levels = 4)

# Inspect coefficients
str(wt)

# Simple denoising: zero out high-frequency components
wt_denoised <- wt
wt_denoised$d1 <- rep(0, length(wt$d1))
wt_denoised$d2 <- rep(0, length(wt$d2))

# Reconstruct signal
x_denoised <- idwt(wt_denoised)

# Plot
plot(x, type = "l", col = "gray", main = "Wavelet Denoising Example")
lines(x_denoised, col = "blue", lwd = 2)
legend("topright", legend = c("Original", "Denoised"),
col = c("gray", "blue"), lty = 1)

Questions / Discussion

I’d be really interested in how others here are using wavelets in practice:

  • Do you prefer wavelet features over Fourier-based features for ML models?
  • Any recommended packages beyond waveslim or wavelets?
  • How do you typically choose decomposition levels in real-world datasets?

I’ve been organizing some of these workflows and case studies into a series of books on wavelet transform. If anyone is interested, I’m happy to share more details or discuss specific use cases.

1 Like