Description of the problem:
What do I want to happen?
I am looking to add a counter balancing code component for an online experiment with 2 possible orders (task 1 and 2 first or task 3 and 4 first)
What have I tried?
I have conditions files called conditionsAB.xlsx and conditionsBA.xlsx in my experiment folder which define the number of nReps for each condition (as shown in the documentation here: Blocks of trials and counterbalancing — PsychoPy v2021.2
and see screen shot of my loop structure below following the counter balancing different subtasks). They have not yet been imported to my html folder.
The inner loops are the subtasks (1 and 2) and (3 and 4)
The outer loop is control Task Order as shown on documentation. The references to trial 1 and trial 2 is unrelated to the counter balancing as its purely because the time line of trial 1 and trial 2 onwards is different.
These conditions files are called to the outer most loop by typing
$“conditions”+”group”+”.xlsx” into the box for conditions files (see screen shot).
Then my if statement to decide which group it will be based on if the participant number is odd or even (in a code component in my instructions Instr3 routine) looks like this…
What happened when I did this?
I got an error saying unknown source (see screen shot). I’m guessing that this is because my if statement isn’t working but I’m not sure why.
When I try to commit the changes I receive a traceback error saying that group is not defined (I have put the code component at the start of the experiment and the if statement for assigning groups is in begin routine). Even if I move it to before experiment, I still get the error saying that group is not defined.
Traceback (most recent call last):
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/experiment/_experiment.py”, line 808, in findPathsInFile
File “”, line 1, in
NameError: name ‘group’ is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/app/builder/builder.py”, line 1221, in onPavloviaSync
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/app/builder/builder.py”, line 719, in fileExport
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/scripts/psyexpCompile.py”, line 73, in generateScript
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/scripts/psyexpCompile.py”, line 242, in compileScript
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/scripts/psyexpCompile.py”, line 214, in _makeTarget
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/experiment/_experiment.py”, line 214, in writeScript
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/experiment/components/settings/init.py”, line 527, in writeInitCodeJS
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/experiment/components/settings/init.py”, line 515, in prepareResourcesJS
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/experiment/_experiment.py”, line 856, in getResourceFiles
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/experiment/_experiment.py”, line 822, in findPathsInFile
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/experiment/_experiment.py”, line 839, in findPathsInFile
File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.6/psychopy/data/utils.py”, line 447, in importConditions
UnboundLocalError: local variable ‘trialList’ referenced before assignment
Thank you I will try that. I think I was also setting up a group in experiment info and then defining it again in the code which might be confusing Pavlovia
Upon further inspection I think the ‘group’ that is being referred to in this error is from experiment info as I was setting up the groups there in addition to defining them in the code.
Although even as I removed the ‘group’ field from experiment info I still get the error. So I’m wondering if my changes are being committed correctly.
So it looks like the .js script is still using ‘group’ as a field in exp info. I don’t want it to do that here as I am now defining group as a variable in the code instead.
I’m not sure what to do but I’ve heard that directly editing the .js script is not advised?
well, you can edit your PsychoJS-script but these edits are not reflected in you local experiment instance. So, it is often best to get the experiment running locally, set auto->JS for the code-components, and to edit manually the instances that are not properly auto-translated.
So, if your experiment is not yet finished, try to find the error that prevents syncing.
Yes that does work but I would like to assign the participants to each group according to whether their participant number is odd or even. So at the moment I get the traceback error when I try to commit that change from local to online.
I still get the same traceback error as above. I thought if it was an issue with syncing that I should update to the latest version- I have done that now and receive the same error.
In the experiment runner in psychopy I also see:
Command ‘[‘git’, ‘branch’, ‘–show-current’]’ returned non-zero exit status 129