#> EEG data
#> 
#> Number of channels   : 72 
#> Electrode names      : A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15 A16 A17 A18 A19 A20 A21 A22 A23 A24 A25 A26 A27 A28 A29 A30 A31 A32 B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11 B12 B13 B14 B15 B16 B17 B18 B19 B20 B21 B22 B23 B24 B25 B26 B27 B28 B29 B30 B31 B32 EXG1 EXG2 EXG3 EXG4 EXG5 EXG6 EXG7 EXG8 
#> Sampling rate        : 512 Hz
#> Reference        :

In this example, we’re going to look at how to handle epoching and events. To start, we have continuous data from 70 channels sampled at 512 Hz, average referenced, and bandpass filtered from 0.1 to 40 Hz. There is a complete table of all of the events imported with the data. We can use that table to form epochs.

There are 18 unique trigger codes, which we can check with list_events().

In this experiment, six of those triggers correspond to condition codes.

Trigger Semantic type Spatial frequency
207 Match High
208 Match Low
213 Mismatch High
215 Mismatch Low
219 Nonsense High
222 Nonsense Low

We can use the epoch_data() function to create epochs around each of these triggers, and label those epochs accordingly. In this example, I’ll label each trigger using hierarchically coded event tags, simultaneously giving each condition of semantic type and spatial frequency separated by a “/” symbol.

As can be seen, this modifies the epochs structure so that it now labels each epoch accordingly. Since we have hierarchically encoded event tags, an easy way to split that into multiple columns is using the separate() function from the tidyr package.

Any columns in the epochs structure are included when converting to a data frame. This has a lot of advantages for plotting; many plotting commands now allow you to use facet_wrap() and facet_grid() from ggplot2 to facet on any of the columns from the epoch structure.