| Reference | Downloads | Github

How to randomly assign stimuli with multiple conditions into blocks without repetitions

PsychoPy version : 1.85.4

Hello everybody! :slight_smile:
I’m new in Psychopy and I’m trying to design my first experiment.

I got stucked with a problem of stimuli selection.
Basically, this experiment consists of 120 images of 3 types (40 positive, 40 neutral and 40 negative). Each of these images could appear in one of four conditions, defined by the combination of other two variables, namely the position (ABOVE or BELOW the center of the screen) and the response required (UP or DOWN arrow key). So, the experiment counts 120x4 total conditions.

I would like to split the experiment in 4 block, in which all the 120 images are presented once and are balanced between the 4 conditions: for example in block 1, 10 negative images appear in ABOVE-UP, 10 in ABOVE-DOWN, 10 in BELOW-UP and 10 in BELOW-DOWN. The same procedure shuold apply to positive and neutral images and this assignment to each condition should be done randomly. Moreover, in the subsequent blocks, the images in one condition should now be inserted in another of the remaining conditions.
I hope everything is clear -_-’’

Currently, I am trying to do this within the coder, but since I’m not an expert python coder, I’m having difficulty. Is there a way to do this within the buider component? I know I should do a .csv file specifying all the possible combinations of stimuli and conditions, but I get stucked with this random assignment of the stimuli in the blocks. Any suggestion would be appreciated :slight_smile:
Thank you in advance for your help.

Please provide a precise and consistent description of your design (think what would be needed in a methods section of a paper). e.g. at the moment, you describe 4 blocks × 40 images per blocks = 160 images, which contradicts the requirement of being 120 images.

Dear Michael thanks for your answer and I apologize if I reply only now. Actually the study involves that all the 120 stimuli (40 positive, 40 negative and 40 neutral images) are presented in each block, but in a different condition, specified by their position (above or below of the center of the screen) and by the response required (up or down key). However, in each one of the four blocks, each stimulus should appear in only one of these conditions and this correspondence stimulus-condition has to be different between the blocks.

For example, stimulus 56 in the 1st block should appear in the condition (ABOVE-up), in the 2nd block in the condition (ABOVE-down), in the 3rd block in the condition (BELOW-up) and in the 4th block in the condition (BELOW-down). Of course, stimuli should be randomly assigned to these conditions within a block.

Since the time was running out and I needed to run a pilot as soon as possible, for now I wrote an external script that automatically and randomly assigns each stimulus to one of the conditions and gives as output 4 excel sheets where each row is a stimulus in one of the four possible combinations (the number of the stimuli assigned to each condition is also balanced between the sheets). These excel files enter in a psychopy loop (representing the block_loop) in a way as showed here.

Although these procedure works, I find it not so elegant and I would appreciate a more optimized solution.

I hope now it’s clearer :slight_smile: Thank you for your time.