Hello,
I have four stimulus files for a counterbalanced set of trials, and I need Psychopy to randomly select one file to use without cycling through all four, as would happen in a loop. My current strategy is inspired by the advice about counterbalancing in another Psychopy article. I have four conditions files, named file1, file2, etc. Following those instructions, I was able to do this by having a “group” field at the beginning of the experiment, then manually typing in a number 1-4 at the beginning of the experiment, and assigning a file using:
$“group”+expInfo[‘group’]+".xlsx"
This worked well, but my supervisor wants Psychopy to generate the number randomly and internally, to save time on our end during data collection. I’ve inserted a code block before the trials in builder mode, where I’m trying to generate a random integer 1-4, save it as a variable (filepath), and then in the conditions field, call up the specific file using this text:
$“file”+thisExp[‘filepath’]+".xlsx"
Can I accomplish this using a code chunk in the Builder mode? Thank you!