Invalid value in correct_response: None
Hi all,
I am attempting to define "correct_response" on every trial, dependent on whether a target is present and, if it is, which way it is rotated. I have the following in an inline script at the top of my trial sequence:
if var.target_present == "No": var.correct_response = None elif var.T1_rotation < 0: var.correct_response = '1' else: var.correct_response = '4'
But every time a trial with no target comes up (target_present == "No"), the experiment crashes with the following error message:
Invalid value in correct_response: None
I think I'm following the instructions outlined here: https://osdoc.cogsci.nl/3.2/escop2017/#step-10-define-the-correct-response
I've also tried putting 'None' in single quotes, and making 1 and 4 integers instead of strings. I get the same error.
What am I missing?
Many thanks in advance for any help anyone can provide!
Best,
Jon

Comments
Hi Jon,
I think correct_response is not allowed to be none. There is likely a check if the value you enter for correct response can be mapped to a key on the keyboard or to a button on the mouse.
Alternatively, these errors are often related to placing the code in the wrong phase of a script. Note this section of the page that you linked:
Defining a correct response is a clear example of something that should be done in the Prepare phase.
There is a run and prepare phase (indicated by tabs in an inline script item). Where is your code currently located?
Thanks so much, Daniel!
I'm fairly certain that it should be possible. I found another reference to setting correct_response to None in the documentation, and a couple of forum posts in which it worked for others, although they are a bit older, from 2015 and 2016.
And I did place the code in the prepare phase, so I must be doing something else wrong 😅
I'm attaching my experiment file. I don't expect anyone to look at it, but am providing it in case it could be helpful in pinpointing the issue. The code in question starts on line 43 of the inline script 'prepare_rand_variables':
Cheers,
Jon
Whoops. Forgot the attachment!
I checked your experiment, and found the code you refer to in the run phase, and not in the prepare phase. That is, I find it in the prepare phase of
prepare_rand_variablesbut in the run phase ofset_response_code. So maybe the second entry causes these problems. I actually ran the experiment without troubles (although I didn't get past the practice trials), so maybe updating your version of OpenSesame also fixes the problem, if you aren't using the latest release.Hi Daniel!
So sorry for the very, very late reply.
Thanks for your suggestions! I just updated to the latest version of OpenSesame (3.3.1 Lentiform Loewenfeld), and that did not fix the problem. However, replacing the joystick item with a keyboard_response item did!
So maybe there's some discrepancy between the
keyboard_responseandjoystickplugins? I really wanted to use the gamepad that we have, but I might consider getting a standalone keypad or something like that instead (a full keyboard isn't practical for our physical setup).All best,
Jon
P.S. - I should have mentioned in my last post that the experiment version I was uploading had replaced
with
so that the experiment would not crash.
P.P.S. - I appreciate your suggestion about putting the other code in the prepare phase. Unfortunately, I need to keep the code of
set_response_codein the run phase, as it depends on the response that was made during that trial.