This package was created to allow the analysis of EEG data in R. The code in this vignette was previously published on Matt's blog.
Two example Biosemi bdf files can be downloaded from the producer's website. To download and unzip example bdf files use:
url_bdf_zip <- "https://www.biosemi.com/download/BDFtestfiles.zip" temp <- tempfile() download.file(url_bdf_zip, temp) unzip(temp) unlink(temp)
library(eegUtils) library(dplyr) bdf_filename <- "Newtest17-256.bdf" bdf_data <- import_raw(bdf_filename)
The file is now loaded. You can see its structure
str(bdf_data)
eegUtils allows loading the bdf files, selecting channels
my_data <- bdf_data %>% select_elecs(c("A1", "A2"), keep = FALSE) %>% # remove channels reref_eeg(ref_chans = "average") %>% # re-reference iir_filt(low_freq = 0.1, high_freq = 40) %>% # band-pass filter epoch_data(255, c(-.2,.2)) # epoch: choose a trigger and time limits
Create a butterfly plot showing data from all the electrodes
plot_butterfly(my_data, baseline = c(-.2, 0), time_lim = c(-.1, .2), legend = FALSE)
Or the timecourse of a single electrode
plot_timecourse(my_data, electrode = "A3", baseline = c(-.2,0), time_lim = c(-.1, .2))
How about an EEGLAB style ERP image?
erp_image(my_data, electrode = "A9")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.