OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): v2022.1.1
Standard Standalone? (y/n) Y
What are you trying to achieve?: I’ve just started tinkering around with Psychopy today and I want to construct a task with two different counterbalancing conditions. I want participants to only see one of the conditions based on keyboard input by the experimenter. I’m using this tutorial released by Psychopy as basis: How to Make Branched Experiments in PsychoPy: An Example using Consent forms - YouTube
What did you try to make it work?:
I have two conditions placed in separate loops.
In the showCounterbalance properties for both conditions I have assigned the nreps option to be a variable:
Prior to these conditions, I have a routine where I ask for input, whether 1 or 2 depending on which counterbalancing condition is wanted.
I then use this input to assign values to the nreps variables in code
if counterbalance_input.keys == 1:
nReps_A = 1
nReps_B = 0
elif counterbalance_input.keys == 2:
nReps_A = 0
nReps_B = 1
The code should assign one of the ‘nReps’ to be 0, thereby suppressing the corresponding condition.
What specifically went wrong when you tried that?:
I’m getting a naming error:
showCounterbalance1 = data.TrialHandler(nReps=nReps_A, method=‘random’,
NameError: name ‘nReps_A’ is not defined
I’ve checked many times through that the names are consistent in the code and in the properties section. Any insight into what might be happening? Thank you.