| Reference | Downloads | Github

Random selection of stimuli without repeating in different blocks


OS (e.g. Win10): Win 10
PsychoPy version (e.g. 1.84.x): 1.85.2
Standard Standalone? (y/n) y

I have a list of 96 prime-target pairs for lexical decision. Presenting these in a random order is no problem at all, but the poor participants are bombarded with these things and I don’t want them to get fatigued. Hence I would like to present 3 x 32 prime-target pairs separated by breaks.

I can get PsychoPy to present 3 x 32 trials with breaks in between BUT there is a distinct possibility that the same prime-target pair may be presented in more than one block, with the result that some trials appear more than once while others do not appear at all. In essence what I want to achieve is the following:

Block 1: randomly select any 32 from 96 trials and present them. After the 32nd trial, give the participant a break
Block 2: randomly select any 32 from the 64 trials that haven’t been used so far and present them. Then give the participant another break
Block 3: present the remaining 32 trials in a random order. End.

I am new to PsychoPy (though for the most part I have found it very accessible and intuitive, so thank you!) and I am not familiar with coding in Python either. I apologise if this is a really simple fix and I’m just being silly.

Thanks in advance for any help you can offer



Hi David,

Welcome along…

Well, below is a quick code snippet to show you how a tiny bit of Python can go a long way…

You don’t need to break your trials into blocks. The easiest arrangement to have here is a single loop surrounding your trial routine so that it will run all 96 trials in random order. What you can then have is a pause routine that interrupts that single loop, but only on trials 32 and 64.

i.e. insert a new routine. Just put a text stimulus on it saying something like “Take a break. Then press any key to continue.” Set it to last indefinitely (i.e. don’t give it a duration). Insert a keyboard component too, also set to last indefinitely and to force the end of the routine. The trick is to use a tiny bit of code that will only let this routine appear on the two specified trials. So insert a code component. In its Begin routine tab, put something like the code below. I’m assuming your loop is called trials. If it is called something else, use that name instead. Also, remember that Python is zero-based, so we will insert the pause after trials 31 and 63:

# Conditionally execute this pause routine:
if not trials.thisN in [31, 63]: # on most trials:
    continueRoutine = False # don't even start this routine

Randomization across lists in a priming experiment