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

Applied Event-Related Potential Data Analysis 2e · LibreTexts

0%

Contents

    Text

    Size
    100%
    Theme
    Typeface
    Line length
    Spacing

    Read aloud

    How

    Speed: 1×
    Light up
    Highlight

    Symbols: Mulberry Symbols, © 2018–2026 Steve Lee, CC BY-SA 4.0 (licence, the set), the site's own copies.

    From LibreTexts, under CC BY-NC 4.0, as the source states it; its equations are written in TeX, which the PDF shows typeset. This page at LibreTexts.

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

    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 the target and prime 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 their own 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.

    Some stimulus presentation systems and EEG recording systems now allow you to use a newer standardized protocol called Lab Streaming Layer. This protocol makes it possible to use an Ethernet cable or even WiFi so that you can send much richer event codes. I hope this becomes the standard approach, because rich event information makes it easier to perform sophisticated ERP analyses. After all, "event" is the first word in "event-related potential".

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

    Go to the Matlab command window and start ERPLAB Studio (by typing estudio in the command window). To make sure that you get the same results that will be shown in the screenshots, reset eStudio's settings by clicking the Reset button under the lower right corner of the plotting region, check the boxes for restoring the default parameters for both the EEG panels and the ERP panels, and click Continue. It's a good idea to do this whenever eStudio is not behaving the way you expect.

    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.

    Make sure that the EEG tab is open in eStudio, click the Load button in the EEGsets panel, and select the file 6_N400_preprocessed.set. The plotting region should look like Screenshot 2. 1. 

    Screenshot 2.1
    eStudio EEG Tab

    In the Plot Settings panel, you can see that Remove DC is selected. Uncheck the box for this option and click the Apply button at the bottom of the panel. As shown in Screenshot 2.2, the waveforms are now visible for only two of the channels. Why do you think that is?

    eStudio EEG Tab

    Screenshot 2.2

    The answer is that the voltage in each channel contains a DC voltage offset that arises mainly from voltages generated by the skin (see Chapter 5 in Luck, 2014), and this shifts the voltages out of the range of the plotting display for most of the channels. 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. The Remove DC option subtracts the mean voltage for each channel during the time period being plotted so you can easily see all the channels. You will almost always want to do this, so this option is on by default. Turn the option back on and click Apply so that the waveforms look like Screenshot 2.1 again.

    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 at the beginning and end of the waveform that are often produced when you filter the data. If you have some “extra” EEG at the beginning and end of the recording, the filter artifacts occur during these unused time periods 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 +X button near the bottom of the plotting window to scroll forward 5 seconds in time. As shown in Screenshot 2.3, 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. 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 seconds 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. Later, we’ll discuss how you can determine these times more precisely.

    eStudio EEG Tab

    Screenshot 2.3

    If you look near the right edge of the plotting region, you’ll see the event code for the prime word on the second trial. You can type 9 (followed by Enter/Return) in the box between the -X and +X buttons so that the plot starts at 9 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:

    • Given the experimental design shown in Figure 2.1, what is the shortest amount of time you should ever see between the prime word and the target word? What is the longest time?
    • Similarly, what are the longest and shortest times between the target word on one trial and the prime word on the next trial?
    • What was the response time for the second trial (approximately)?

    If possible, keep eStudio in the same state for the next exercise.


    This page titled 2.3: Exercise - Looking at the EEG and the Event Codes was last modified on Thu, 01 Oct 2026 18:52:40 GMT and is shared under a CC BY-NC 4.0 license and was authored, remixed, and/or curated by Steven J Luck directly on the LibreTexts platform.