Measuring and Analyzing ERPs
Part of my work as a PhD candidate consists of measuring and analyzing brain waves. We do this by conducting so-called “ERPs”, i.e. “event-related potentials”. We record the EEG (Electroencephalogram) of participants and time-lock it to stimuli, the events. In order to get only the information that relates to the stimulus, a lot of repetitions are necessary. The brain waves of all those repetitions are then averaged, which filters out the “noise” as this is random and leaves only the constant reaction to our stimulus.
As you can read on my “PhD Project” site I am interested in the perceptionof speech sounds in individuals with aphasia, an acquired languagedisorder. In my experiment the participants are asked to watch asequence of videos of someone uttering syllables. These can beso-called standard (occurring in 80% of the trials) or deviant(occurring in the other 20%) stimuli. They differ by only the initialspeech sound (pa vs. ta or ka). On encountering a deviant stimulusparticipants should push a button. Whenever a new stimulus is starteda marker is sent to the EEG, so the EEG can be related to the stimulilater on.
However when I want to analyze my data I’m facing some problems: The marker denotes the onset of the video in which the stimulus is displayed, but not the onset of the sound, like I would need. Furthermore I have way too many standards compared to the deviants.
So I decided I want only the standard stimuli that occur directly before a deviant one. This makes sense for 2 reasons: I will definitely get the same amount of standard and deviant stimuli and I will get the most standard standards…What I mean here, is that the last standard of a row of standards is the least new and therefore it has the biggest contrast to the surprising deviants that occur only every now and then.
Also I wanted to move the marker to the onset of the sound or actually add a marker there. Fortunately the speech always starts at the same time after the onset of the video. This made my task a lot easier. Basically all I want is an additional marker x milliseconds after the other marker. Another good thing is that the markers are stored in a simple text file with a quite basic structure. Below there’s an example of the first rows of every marker file. First it is specified that it is a marker file and to what .eeg file it belongs. Furthermore there’s some information about the coding and then there’s one row per marker. For each marker it is specified what number it has (just counting upwards), what kind of marker it is, what is put down in the eeg as information, at what data point the marker is placed, how big it is (usually 0) and to which electrode channels it applies.
Brain Vision Data Exchange Marker File, Version 1.0 [Common Infos] Codepage=UTF-8 DataFile=3_1_Tones.eeg [Marker Infos] ; Each entry: Mk<Marker number>=<Type>,<Description>,<Position in data points>, ; <Size in data points>, <Channel number (0 = marker is related to all channels)> ; Fields are delimited by commas, some fields might be omitted (empty). ; Commas in type or description text are coded as "\1". Mk1=New Segment,,1,1,0,20100331151632436646 Mk2=Stimulus,S 1,259,0,0 Mk3=Stimulus,S 9,510,0,0 Mk4=Stimulus,S 15,512,0,0 Mk5=Stimulus,S 1,636,0,0 Mk6=Stimulus,S 9,887,0,0 Mk7=Stimulus,S 15,889,0,0
As you can see I have different markers of the category “stimulus”: S1, S9 and S15 in this example. S1 marks the onset of the video and is the one I was concerned about. S9 and S15 correspond to the actual response given by the participant. Those are sent to the EEG after the end of the stimulus.
In order to change my markers in the way I wanted, I wrote a Ruby program that reads the input from the original marker file, processes it like I want (keep only deviants and standards before deviants and add the sound-onset marker) and writes them to a new file.
If you’re curious about this small program (which is still under constant revision to improve the functionality and the efficiency) you can check it out on github
If you have any ideas on how to improve the program or comments about it or questions, please let me know! It cost me quite some time to write it (as I’m still a beginner in Ruby), but doing it all by hand would have been just as time-consuming and a lot more boring than writing this program!Written by Dörte de Kok, 29 Sep 2010 View Comments