Hi, everyone!
I’m trying to do something similar to the OP using @lindeloev’s “select rows dynamically” method in PsychoPy 1.84.2, except instead of randomizing within sequentially increasing blocks of conditions (random within 1:12, random within 13:24, etc.), I’m trying to randomize within alternating blocks of conditions. That is to say, I have a conditions file with 100 rows, and I’d like odd numbered trials to be chosen at random from rows 0:49 and even numbered trials chosen from rows 50:99.
To try to implement this, I currently have a single routine with a single loop around it. I’ve inserted a code component into my routine, with
thisLoop = 1
in the Begin Experiment tab, and
if thisLoop = 1: ....thisLoop = 2 else: ....thisLoop = 1
in the begin routine tab.
In the loop settings dialog, I set “nReps $” to 1, load my conditions file, and set “Selected rows $” to ((thisLoop-1)*50):((thisLoop*50)-1)
. If I close and reopen the loop dialog, there’s an error message at the bottom of it that says “Python syntax error in field ‘Selected rows’:” and the OK button is greyed out. Here’s a screenshot in case I haven’t described this clearly:
Update:
When I try to run the experiment, I get the following error.
line 829
trialList=data.importConditions(u'[path].csv', selection=((thisLoop-1)*50):((thisLoop*50)-1))
For some reason there’s an extra )
on the end of the selection
value!
I’ve also tried different combinations of including extra (
at the beginning and leaving off extra )
at the end of the “Selected rows $” dialog to try to balance out the total number of parens, but that hasn’t worked. Here’s a list of things I input, and the errors they generate:
Input (thisLoop-1)*50:(thisLoop*50)-1
Error (thisLoop-1)*50:(thisLoop*50)-1)
Input (thisLoop-1)*50:((thisLoop*50)-1
Error (thisLoop-1)*50:((thisLoop*50)-1)
Input ((thisLoop-1)*50):((thisLoop*50)-1
Error ((thisLoop-1)*50):((thisLoop*50)-1)
Input ((thisLoop-1)*50:(thisLoop*50)-1
Error ((thisLoop-1)*50:(thisLoop*50)-1)
So it seems even when there’s an even number of open and close parens, PsychoPy doesn’t like something about my “Selected rows $” code. What am I doing that python doesn’t like?
Thank you for your help!