sending TTL pulses for different keyes pushed (ERP experiment)

310 views
Skip to first unread message

Sebastian Korinth

unread,
Jan 22, 2014, 9:49:38 AM1/22/14
to psychop...@googlegroups.com

Dear PsychoPy community,

Here a question that addresses especially those who have some experience with PsychoPy in ERP-experiments. We are using PsychoPy 1.79, Builder on a Windows 7, 64bit computer for stimulus presentation; this computer sends TTL pulses via the parallel port to an identical computer on which Brain Vision recorder software collects the EEG data.

We want to run a sentence processing experiment. With onset of each word of a sentences a TTL pulse is sent, providing the code for the first word (10), the second word (20) and so on. Since the experimental manipulation happens on the last word, at which semantic processing is manipulated, three levels of cloze probability are coded as 51, 52 or 53. Sending the TTL pulses for the stimuli works very well, however, we have some problems with the response trigger. Specifically, participants will have to push one of three buttons to indicated the level of cloze probability. We have managed to send a TTL pulse for the moment they have pushed the button using the $response.clock.getTime() variable for the definition of the start time for the parallel port to send our code. However, we are failing to send different codes for different keys pressed. All I want to do is to send for instance a 51 when the pressed the left button, a 52 when the pressed a down button or a 53 when they pressed the right button on the keyboard. I assume that I will add a little piece of Code that translates ‘left’ to 51 and so on.

But I cannot even find in the variable that indicates which key is pressed in the compiled version of our experiment. Has anyone a suggestion? Thanks in advance,

 

Sebastian

  

Michael MacAskill

unread,
Jan 22, 2014, 4:26:42 PM1/22/14
to psychop...@googlegroups.com
Hi Sebastian,

You have a keyboard component called "response" (by the way, sending a screen shot was very useful…)

Thus the key which was pressed can be accessed via the variable "response.keys" (without the quotes).

What you could do is insert a Code component which will create a dictionary, i.e. a lookup table that matches key presses to the message you want to send. e.g. In the "Begin Experiment" box of a Code component, put this:

codeTable = {"left":51, "down":52, "right":53}

That creates this dictionary at the start of the experiment, so it can be referred to in any routine at any point.
Then in the Parallel component's data field (I think), you should be able to send the appropriate response with something like this:

codeTable[response.keys] # look up the keypress in the dictionary and return the appropriate number

Hope that helps?

Michael
Reply all
Reply to author
Forward
0 new messages