OS (e.g. Win10): Win10 PsychoPy version (e.g. 1.84.x): 1.90.1 Standard Standalone? (y/n) If not then what?: y What are you trying to achieve?:
I have 5 blocks and each block contains 100 trials. I want to repeat all my block twice, which results in 10 blocks in total. I’d like to randomize the first 5 blocks and then present all blocks in reverse order for the same participants. Namely, if the first 5 blocks are 3, 2, 4, 5, 1 (randomly chose order), then I’d like my experiment to have the 10 blocks like 3,2,4,5,1,1,5,4,2,3 What did you try to make it work?:
My initial guess is that, with a ‘random’ looptype
and only repeat all my blocks once, I will get some kind of output of which order does it pick up. Then I can assign it to another loop. However, I am not able to figure out how can I do that.
This would need to be done in code. Insert a code component. In its “begin experiment tab”, put something like:
import copy
# create a list of filenames (use your actual names of course):
blocks = ['con01.xlsx', 'con02.xlsx', 'con03.xlsx', 'con04.xlsx', 'con05.xlsx']
# randomise it:
shuffle(blocks)
# make a copy and reverse it:
blocks_2 = copy.copy(blocks)
blocks2.reverse()
# add it to end of the original list:
blocks.extend(blocks2)
# check that it does what you want:
print(blocks)
Now your blocks loop:
no longer needs to be connected to a conditions file (as the list of blocks is held in code now), and
you’ll need to specify the nReps to be 10 so you get the correct number of blocks, and
it should be “sequential” rather than “random” now (not that it would make much difference here I guess).
Lastly, in your inner trials loop, put this in the “conditions file” field:
$blocks.pop()
This takes the next filename in order from the blocks list.
Thank you @Michael, the above code and setting solved my block order problem. However, as a result, I have to disconnect to a condition file, as you said. However, in my previous condition files, I also put other variables only for the start of each block, because I want to show participants some reference stimuli before each block. So that I had condition files like this:
Hi @Michael I think I got a fairly detailed question than my last reply.
I have 5 blocks in total and want to present them 10 times, first 5 times in a random order, next 5 times in reverse order. In instr2, I created a code component and wrote your code down
import copy
# a list of filenames
blocks1 = ['condition0.8.xlsx', 'condition0.7.xlsx', 'condition0.6.xlsx', 'condition0.5.xlsx', 'condition0.4.xlsx']
shuffle(blocks1)
# make a copy and reverse it:
blocks_2 = copy.copy(blocks1)
blocks_2.reverse()
# add it to end of the original list:
blocks1.extend(blocks_2)
Also, I set the trials properties like this
For each condition excel file, I add 3 references stimuli pictures in row 2-4,
Then, I set trails_ref loop property:
The problem is that trails-ref and trials does not take the same condition file when I run the code.
It seems that trials_ref and trails loop are independent from each other. Is there any way to let trail_ref take the first 3 rows of one condition file, and then trail take the rest of the stimuli from the same condition file?