if(try(require(wavethresh,quietly=TRUE))){
blinks <- rep(c(rep(0,5),sin(1:10)*35,rep(0,15)),5)
noise <- runif(length(blinks), min = -12, max = 12)
blinks.thrsh <- mwd.thrsh(blinks + noise)
ylimit <- c(-45, 80)
plot(blinks + noise, type = "l", ylim = ylimit,
ylab = "Amplitude", col = grey(0.4))
lines(blinks.thrsh, col = "red", lty = 2)
lines(blinks, col = "blue", lty = 3)
legend("topleft", legend = c("Blinks + Noise",
"Thresholded Blinks + Noise", "Blinks only"),
lty = c(1, 2, 3), col = c(grey(0.4), "red",
"blue"), bty = "n", cex = 0.75)
}
Run the code above in your browser using DataLab