Skip to main content
Social Sci LibreTexts

2.3: Exercise - Looking at the EEG and the Event Codes

  • Page ID
    87934
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    In our first exercise in this chapter, we’ll take a look at the EEG and the event codes for one participant (Participant #6). You should always scan through a participant’s EEG and event codes before starting to process the data. Many things can go wrong during an EEG recording, and you want to make sure that there aren’t any problems that you need to address before you go further. I provide a detailed example of how to visually inspect a participant's EEG in the chapter on artifact rejection (Chapter 7).

    Remember, event codes are stored in the EEG file during data collection and indicate what event happened (e.g., which particular stimulus or response) and the time of occurrence (see Figure A1.1 in Appendix 1). In the system we used for collecting the ERP CORE data, event codes were integers between 1 and 255 (see the box below for more information about event codes). Table 1 lists the event codes for the N400 experiment. An event code was produced for each prime word and each target word, and different codes were used depending on whether the target was semantically related or unrelated to the prime on that trial. Note that we used two different lists of words (for counterbalancing purposes), and that was also indicated by the event codes. Each subject saw a total of 120 trials, 60 on which the target word was related to the prime word and 60 in which they were unrelated. Thus, there were 30 occurrences of each stimulus event code (30 related and 30 unrelated for each of the two lists).

    Table 2.1. Event codes for the ERP CORE N400 experiment.
     

    Word Type

    Relatedness

    Word List

    Event Code

    Occurrences

    Stimuli

    Prime

    Related

    List 1

    111

    30

     

    Prime

    Related

    List 2

    112

    30

     

    Prime

    Unrelated

    List 1

    121

    30

     

    Prime

    Unrelated

    List 2

    122

    30

     

    Target

    Related

    List 1

    211

    30

     

    Target

    Related

    List 2

    212

    30

     

    Target

    Unrelated

    List 1

    221

    30

     

    Target

    Unrelated

    List 2

    222

    30

               

    Responses

    Correct

       

    201

    Variable

     

    Incorrect

       

    202

    Variable

    Event Codes

    In most EEG systems, one computer is used for presenting stimuli, and a different computer is used for recording the EEG. In addition, the experimenter often uses general-purpose stimulus presentation software that is not made by the manufacturer of the EEG recording system. To ensure compatibility, the method typically used to pass event codes from the stimulus presentation computer to the EEG recording computer is based on a communications protocol that has been around since 1970 (the Centronics-style parallel port). The protocol requires that the event codes be whole numbers between 1 and 255. That’s plenty for some experiments, but it’s woefully inadequate for others. In our N400 experiment, for example, it would have been nice for each event code to indicate the actual word that was presented. The ERP CORE online resource therefore provides text files (in CSV format) with the actual words used for each participant.

    Some EEG systems come with stimulus presentation software, and they use custom protocols to allow for richer event codes (which might be text instead of 8-bit integers). However, this is not a very general solution.

    There is now a movement to use a newer standardized protocol called Lab Streaming Layer. This will make it possible to use an Ethernet cable instead of a parallel port and send much richer event codes, while still providing a standardized protocol that any software package can implement. I’m looking forward to the day when both my EEG recording system and our various stimulus presentation programs can use this newer protocol.

    In the exercises for this chapter, we’re going to look at the data from Subject 6, who has particularly nice data.

    If Matlab isn’t already running, launch it now and start EEGLAB (by typing eeglab in the Matlab command window). In Matlab, set the current folder to be the Chapter_2 folder. On the left side of the Matlab window, you should see the contents of this folder, including a file named 6_N400_preprocessed.set. That file contains the EEG from Subject 6. A few minor preprocessing steps have already been conducted to make the exercises in this chapter a little easier.

    In the EEGLAB GUI, select File > Load existing dataset and select the file 6_N400_preprocessed.set (be careful that you don’t accidentally select Load existing study instead). Then select Plot > Channel data (scroll). You should see a plot that looks like Screenshot 2. 1. You can see the EEG waveforms for only a few of the channels. This is because the voltages are out of the range of the plotting display for most of the channels, which is a result a DC voltage offset that arises mainly from the skin (see Chapter 5 in Luck, 2014). That is, the voltage recorded in our EEG electrodes is the sum of the EEG plus any voltage offset, and the voltage offsets are often so large that they make the signal go beyond the range of values shown in the plot. You didn’t experience this when you did the exercises in Chapter 1 because the low frequencies had already been filtered out in the data in used in those exercises, which minimizes the DC offset.

    Screenshot 1.1
    72fc1iG1l5i_-p3aNv56ksvs_gIgkulzPz8eO73uEuXOkKQTpdDa1dFbuXQ0lkJghGfbSsrvB7zZX9UVzlz3mNngY0tr2Ci0tbjrk7crkY634yFss_E8H0Tyvo0NBXVVDlo2TU0

    To see all of the channels, you can tell the plotting window to subtract the DC offset (i.e., to subtract the mean voltage across time points from the voltage at each time point, separately for each channel). In the EEG plotting window, select Display > Remove DC offset, and then you’ll see all the channels, as shown in Screenshot 2.2.

    Screenshot 2.2

    r4KFDy1-7NKzXmhwcET2kKbk1oAXpnd2tPyR6X19cLI4rfjqdFmwGEWsI1OdyDoTOXrI1UT-jHpneYRIO8Vn9gBCNXgu9Upb3RdazV8uyDhQUrjuXdb18giHpY4Y1YNVLFnHS0Q

    Someday, when you’re loading your own EEG data into EEGLAB, you might see a completely blank screen when you try to plot the EEG. I’m hoping that you’ll remember that this means you need to remove the DC offset.

    Now let’s look at the event codes in the EEG plot. Do you see the two vertical lines with a label of 202 at the top of each line? Those are event codes. If you look at Table 2.1, you’ll see that event code 202 corresponds to an incorrect behavioral response. In this task, there are some instruction screens at the beginning, and the participants are required to press a response button to go to the next screen. Those responses generated an event code 202.

    Pro tip: Starting the recording several seconds before the first trial

    You might expect that the EEG recording would begin only moments before the first trial. Why waste disk space with all that extra EEG? However, there is a technical reason why you should start the recording several seconds before the first trial. Specifically, this can help you avoid artifacts that filters can produce at the beginning and end of the waveform. If you have some “extra” EEG at the beginning and end of the recording, the filter artifacts occur during these time periods that you don’t care about rather than distorting the data during the first and last trials of the recording. See Chapter 7 in Luck (2014) for a more detailed explanation.

    Click the >> button near the bottom of the plotting window to scroll forward 5 seconds in time. You should now see an event code 121 at approximately 6.6 seconds, an event code 221 at approximately 7.7 seconds, and event code 201 at approximately 8.3 seconds (see Screenshot 2.3). Look up these event codes in Table 2.1. What happened at these three time points?

    Event code 121 was a prime word that began approximately 6.6 after the start of the recording. Event code 221 was a target word that was unrelated to the prime word, and it began approximately 1.1 seconds after the prime word. Event code 201 was a correct response, and it occurred approximately 0.6 seconds after the target word. So, this was the first trial in the experiment, and the subject correctly determined that the target was unrelated to the prime with a response time of approximately 600 ms. You can get approximate timing information like this by hovering the mouse over the plotting window. The time corresponding to the location of the mouse pointer is shown at the bottom of the plotting window. Later, we’ll discuss how you can determine these times more precisely.

    Screenshot 2.3

    IK6IqUWxuUXTpgPsqUWSwn6fKCigU3njIHO0YBW2I5QylzXxvRgGRBRJgmmMGr8HLUT0LBbSXV5gx1mxdYjhTVk-qZsG7orMMs66TdrgAGuxxrj3XsOWZOpOB6VAAgBzte5HYiw

    If you look near the right edge of the plotting window, you’ll see the event code for the prime word on the second trial. You can click the > button 4 times to scroll over 4 seconds, and then you’ll be able to see the event codes for the prime, the target, and the response on this second trial. Here are some questions you should try to answer:

    If possible, keep the EEG plotting window open for the next exercise.


    This page titled 2.3: Exercise - Looking at the EEG and the Event Codes is shared under a CC BY 4.0 license and was authored, remixed, and/or curated by Steven J Luck directly on the LibreTexts platform.

    • Was this article helpful?