Coding the correct key response for a Stroop task

I’m trying to create a Stroop task whereby the word stimuli (red, green, blue, yellow) appear on the screen, and one must correctly identify whether the word stimuli are congruent with the colour presented (the word red presented in red font) or incongruent (the word red presented in yellow font).

For the key responses I would like the left arrow key to signify “CONGRUENT” and the right arrow key to signify “INCONGRUENT”.

I know it is quite easy to specify left and right arrow keys using the Builder and an excel sheet, but I would like to randomize the color-word stimuli presented, thus it would seem, according to YouTube tutorials, that manually coding would be the solution.

My question is: How do I set the correct key response to be the left arrow key when pressed with congruent stimuli (and incorrect when pressed to incongruent stimuli), and vice-versa with the right arrow key?

Thanks

Hi @respthreshold,

this should be quite straightforward, as soon as you know how you determine whether a trial is incongruent or congruent. Assuming there are two variables word and color, which determine the word and the color of your stimulus, you could do

Begin routine

if word == color:
    corr = 'left' 
else:
    corr = 'right'

Then, use $corr in the “Correct answer” field of your keyboard component.

Hello,

This can easily be achieved by using an Excel-file.

See attached example. Specify corrAns (or whatever you call the column containing the correct answer) as Correct Answer on the data tab of the response-component.

trialTypes.xlsx (8.7 KB)

grafik

Adopt the example to your needs.

Set the loop-type to random to get a random presentation of your colour words.

BTW, the cursor keys are called left, right, up, and down.

Best wishes Jens

1 Like