Balanced "randomization" according to one parameter

PsychoPy version 1.85.4

Hello everyone, I’m creating an experiment in which a set of stimuli (images) will be presented to the participants, and we’ll record their responses using the keyboard.

I would like to (psuedo)randomize the stimuli according to one parameter (in the same Excel sheet). This parameter, “Congruency”, has 3 levels, “congruent”, “incongruent”, and “neutral”, and I would like 1/3 of the stimuli presented to be from each level. There are differing amounts of congruent, incongruent, and neutral trials, so I am unable to use all of the stimuli and achieve a 1:1:1 balance, and even if there was an even amount, I do not plan on using all of the stimuli for each participant, so there is no way to ensure balance.

Additionally, I have considered making a different conditions file for each level, however, this does not work because I want individuals to have an equal probability of seeing a “congruent”, “incongruent”, and “neutral” stimuli each trial, NOT all “congruent” trials in succession in followed by all “incongruent” trials in succession.

I’d also prefer NOT to just remove stimuli of a certain condition until a 1:1:1 balance is achieved, and then import the conditions file.

If I sort the excel sheet alphabetically, is there a way to specify that I would like 30 stimuli from rows 1-50, 30 stimuli from 51-150, and 30 stimuli from rows 151-200, while also making sure that all of the stimuli are randomized between?

Because I plan on running this experiment online, there are certain features that are not supported: like code components. With that in mind, I’d prefer to use builder features that are supported online (and no code, as I do not have coding experience).

Any ideas would be greatly appreciated.

Try playing with the selected rows field of the loop dialog. That probably won’t work with online experiments, however, as this would require some Python expressions in that field (e.g. random sampling of 30 values from within a range).

The online experiments function is for demonstration purposes only: it isn’t yet ready for prime time, and this shows some of its (current) limitations.

Hi Michael,

I am trying to do something similar…but a bit more complicated. See my actual question here: How do I select a subset of rows/stimuli from TWO conditions files and then randomly arrange these two selections into one sequence for presentation?

Could you provide some more details on how I would code to select a certain number of stimuli from two different condition files and then combine them together into a randomly ordered stimuli list for presentation?

Will answer in that thread.