if (FALSE) {
# The following code need to download additional demo data
# Please see https://rave.wiki/ for more details
library(raveio)
repo <- prepare_subject_power(
subject = "demo/DemoSubject",
time_windows = c(-1, 3),
electrodes = c(14, 15))
##### Direct baseline on the repository
power_baseline(x = repo, method = "decibel",
baseline_windows = list(c(-1, 0), c(2, 3)))
power_mean <- repo$power$baselined$collapse(
keep = c(2,1), method = "mean")
image(power_mean, x = repo$time_points, y = repo$frequency,
xlab = "Time (s)", ylab = "Frequency (Hz)",
main = "Mean power over trial (Baseline: -1~0 & 2~3)")
abline(v = 0, lty = 2, col = 'blue')
text(x = 0, y = 20, "Aud-Onset", col = "blue", cex = 0.6)
##### Alternatively, baseline on electrode instances
baselined <- lapply(repo$power$data_list, function(inst) {
re <- power_baseline(inst, method = "decibel",
baseline_windows = list(c(-1, 0), c(2, 3)))
collapse2(re, keep = c(2,1), method = "mean")
})
power_mean2 <- (baselined[[1]] + baselined[[2]]) / 2
# Same with precision difference
max(abs(power_mean2 - power_mean)) < 1e-6
}
Run the code above in your browser using DataLab