# Complex randomisation structure

I have a complex randomisation structure that I am hoping I can do more simply that I am now.

There are six within subjects conditions (1-6).
Each condition can draw from the same list of stimuli (there are 56 total stimuli but I am hoping to use a shorter list).

Each participant will do 12 trials (2 in each condition).

I need to counterbalance
(a) the order of the conditions across participants
(b) the stimuli

At the same time, the same stimuli must not appear more than once in the 12 trials.

Does anyone have any ideas how to structure my spreadsheets. Do I just need to create a lot of groups to capture each combination or is there a simpler way?

Thank you so much!!

It sounds like you should have a condition spreadsheet with 6 rows to randomise the order of the conditions. The easiest option might be to preload the stimuli into a separate list. Have a look at my Independent Randomisation demo

Thank you, that already sounds simpler than I was thinking. I’ll take a look.

1 Like

Hi again

Sorry, I think I wasn’t very clear in my initial description. The problem is that the stimuli do change with condition but involving a central object which needs to be different.

So, each trial is an object in an environment. The relationship between the object and the environment changes across conditions - more to less congruent. The six conditions correspond to six levels of congruency. These conditions needs to be counterbalanced across participants.

But also within the trials (12 in total - 2 per condition) the same object should not be presented twice. So say you have a banana in a fruitbowl in trial one (highly congruent) , the banana on a shoe rack (highly incongruent) should not feature, instead it would be the apple on the shoe rack.

Is there an easy way to do this without a complicated latin square arrangment and programming many groups?

1 Like

Okay, so you have objects (some of which are fruit) and environments (of different levels of congruency with fruit)?

It seems to me that you might need lists of different categories of objects and then select one on each trial from an appropriate category depending on the level of congruency and the environment (which should be independently randomised).

How many different environments do you have? Do you really have six levels of congruency for each? Is each object category used for all six levels of congruency?

I am using the stimuli from this database here: Öhlschläger, S., Võ, M.LH. SCEGRAM: An image database for semantic and syntactic inconsistencies in scenes. Behav Res 49, 1780–1791 (2017). SCEGRAM: An image database for semantic and syntactic inconsistencies in scenes | SpringerLink
I think I will create six groups and counterbalance those and then within those groups create the list of stimuli to ensure that they don’t overlap. Something like this:
Group 1 STIMULI: 1,2,3,4,5,6,7,8,9, 10,11,12
Group 2 STIMULI: 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
etc.,
I am right in thinking that PsychoPy will always draw from the first line for each trial? I can create some randomisation using this and groups, I think.

While thinking about a different issue I’ve just written a demo which I believe is a simple solution for complex randomisation situations.

# Complex Randomisation code | try it

This demo is for anyone who wants to randomise the order of their trials with constraints, and can do so based on the row numbers. In this case the demo produces CVC letter strings by shuffling rows 0 to 4 for the vowels and 5-25 for the consonant, and then adding appropriate items to useRows. The loop itself is sequential. The advantage of this method over preloading stimuli is that it does not require extra loops or lists – the trials loop itself is attached to the conditions spreadsheet as normal.

What did you try to make it work?:

What specifically went wrong when you tried that?:
Include pasted full error message if possible. “That didn’t work” is not enough information.