OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): v2021.2.3
Standard Standalone? (y/n) If not then what?: y
What are you trying to achieve?:
Shuffle subsets of trials:
I have 14 blocks of 3-6 trials each.
I want to shuffle the trials, only within the block
In the 1st block, I have 3 trials that I want to shuffle amongst themselves.
In the 2nd, I have 6 trials to shuffle amongst themselves.
In the 3rd, I have 6 trials to shuffle amongst themselves.
In the 14th, I have 3 trials to shuffle amongst themselves.
I want to keep the sequential order of the blocks.
What did you try to make it work?:
I have tried inserting two loops, one for sequential blocks and another for randomized trials.
The downside is, I have to create 14 conditions files, which is not preferable.
(Slightly unrelated, but I also have 10 counterbalanced groups, each group with 14 blocks, so this ends up being a lot of conditions files that I’d rather not make).
I’d prefer to take subsets of trials from a single conditions file.
I have tried inserting customized code.
This is pseudo-code, but:
I have a conditions file, each trial is labeled with block number it corresponds to.
#for each block, n = 1 to 14
#compile trials with corresponding block number
#shuffle this temporarily created conditions file
#present randomized trials
What specifically went wrong when you tried that?:
Code does not work, I’m not sure how to put pseudocode into practice.
No error code, sorry. I just get errors that certain “names” don’t exist, and this is because I don’t know how to call the correct subsets of trials, for every block.
Nor do I know how to randomize each subset of trials.
Thank you so much in advance for your help!
To access the first three trials of a spreadsheet use a variable for the selected rows, e.g. useRows and in your sequential spreadsheet put useRows as 0:3. The second entry would be 3:9 for the next 6 trials.
Thank you so much for your fast response!
I tried creating a new spreadsheet for sequential variables.
Here is a screenshot:
And then the screenshot of the original spreadsheet that I am pulling image files from:
As you can see, I want to shuffle the first 3 images, then the next 6, then the next 6…etc.
Lastly, here is a screenshot of my builder:
I think I am going wrong with my variable naming convention?
I get an error: “TypeError: ‘NoneType’ object is not iterable”
Thank you so much.
Try $useRows where useRows in your spreadsheet is 0:3 etc.
Hi! Thank you for your discussion, it was really helpful.
I’m figuring out the same problem, where did you inserted the additional ‘$’ to make it work? Thank you.
Don’t insert an additional $
Here are my updated screenshots:
Wakefield pointed this out already, but I failed to notice – indexing is inclusive. To use every 3 rows, for example, you’d have to write
Hope it helps
Thank you both for your help. Everything is working and clear now!
Hi again, I’m trying to go one step further by putting all image files into one conditions file.
From before, I have a shuffler of a subset of trials.
For example, I am shuffling within each of the 3 blocks of 0:3, 3:6, 6:9.
That’s trials 0:9.
I actually have 18 trials total.
So I want to repeat the above twice, or as two groups – 0:9 and 9:18 from the same conditions file.
Is this possible?
I’ve been getting the first group repeated twice.
This is sort of what I’m trying:
If not, I could write out each block, it’d just be a bit tedious.
Tl;dr - take 18 trials, split into 2 groups (9 trials each).
For each of the 9 trial-group, split into 3 blocks.
Shuffle each block among itself.
The way to do this is to create $testRows mathematically.
You could have an outer loop pointing to a spreadsheet with two rows of a column called, say, offset with values 0 and 9 and an inner loop with three rows pointing to a column called, say, startRow with values 0, 3 and 6.
Then you would need a calculation in a code component before the blocks loop of
testRows = str(startRow+offset)+":"+str(startRow+offset+3)
Wow that works so beautifully, thank you so much.