Numbers as corrAns in excel

Hi, we are trying to develop an fMRI compatible version of a reaction time task and need to use numbers 1-4 as corrAns values. However, the experiment is not registering these key presses as a response. The task works when letters (i.e. a,b,c,d) are used.

We have tried to save the corrAns values in excel as strings (i.e. added apostrophes before each digit), and subsequently changed Allowed keys to str(corrAns) … but the issue remains.

Any help would be much appreciated.

Hello Josh,

do have two problems?

  1. 1, 2, 3, 4 are not registered as response? Did you use the num-pad? If yes, use num_1, num_2 aso. instead of 1, 2 aso.

  2. Your corrAns is not registered? Did you try $corrAns in the relevant field?

Best wishes Jens

hi @JensBoelte
thanks for replying.

It is neither of these problems:

    • we have tried both the numbers on the main keyboard, and on the number pad. Doesn’t work for either.
  1. Yes, tried both “corrAns” and “$corrAns”

The issue is that we are trying to reference the variable corrAns in two places, and to check that the key pressed is an exact match for the string in the corrAns column of the excel sheet. The code will only progress when that exact match is registered.
The issue seems to be that the number (e.g “1”) is being compared in a logical statement, but there is an issue because it is comparing a number to a string and therefore no match is found.

@Becca -any ideas?? (we are using Windows OS, with Psychopy3 v2020.1.3)

Also, we have tried saving the excel sheet as a .csv
And we have tried using a preceding apostrophe (read in previous forum that this should be read in as a string)


if you are using Store correct and compare it to Correct answer you get a new variable in the result file key_resp.corr (if key_resp is your keyboard-component’s name) that contains 1 when the response is correct and 0 when the response is incorrect. Furthermore, there is a variable called key_resp.key that contains the key the participant pressed. If you check "Force end of Routine the routine is finished as soon as one of allowed keys has been pressed.

CorrectKey.psyexp (8.1 KB)
Stimuli.xlsx (8.4 KB)

It works in the uploaded example (notice; I am using ; as column separator). You may use the number-keys in the top-row of your keyboard, not the number-keys on the numeric keypad.

Best wishes Jens