README.md

About

Provides a set of utilities to easily work with event-related EEG data (including evoked potential and spectral analysis). This is still work in progress. The main idea is to provide a time-domain signal of EEG records and a named vector of event points. The user proceeds in the analysis by informing regexes that captures the set of events of interest. The functions evoked and spect perform averages and vector-averages, respectively, over the set of epochs selected by the regex, returning a tibble of either time series or spectrograms for easy statistical analysis and visualization:

library(stringr)

# -- Time-domain analysis: Get peak and latency --

# Simulate some data. Randomly present stim1 and stim2
signal <- (-1) + 2 * runif(1e5)
onset <- as.integer(runif(20) * 1e5)
event_names <- c(str_c('stim1_trial', 1:10), str_c('stim2_trial', 1:10))
names(onset) <- event_names
onset <- sample(onset, 20, replace=FALSE)
eeg <- eeg_session(signal, onset, e_size=1000L, srate=1000L)

# Fetch peak value and latency
evoked_s1 <- eeg %>% evoked("stim1")
evoked_s2 <- eeg %>% evoked("stim2")

peak_s1 %>% pull(evoked) %>% 
    which.max %>% slice(evoked_s1, .)
peak_s2 %>% pull(evoked) %>% 
    which.max %>% slice(evoked_s1, .)

# -- Frequency-domain analysis: Get power and phase at alpha (10Hz) --
signal2 <- (-1) + 2 * runif(1e5) + sin(2*pi*10*seq(0,100,length.out=1e5))
eeg2 <- eeg_session(signal2, onset, e_size=1000L, srate=1000L)
eeg2 %>% spect("stim1") %>% 
    mutate(power=spect_power(.), phase=spect_phase(.)) %>%
    filter(freq==10)

License

This work is licensed under the LGPL.



limads/eegr documentation built on May 3, 2019, 3:21 p.m.