| Reference | Downloads | Github

Help with randomization in sound-film matching experiment

Hey everyone,

I’m trying to put together a pilot study in PsychoPy for a masters project course, and, being relatively new to this, I’m having some trouble about how to proceed. Essentially, I’m having trouble envisioning what the randomization should look like, practically speaking (e.g., what are good functions for what I’m trying to do, etc). If you have the time to help out, I would apreciate it.

Here’s the study as detalied as I can manage.

-In all, there are 24 sounds and 24 films, divided into four categories, such that there are four categories of sound (S1-S4) and four equivalent categories of films (F1-F4), with six stimuli in every category.

-In every trial, participants should be presented with one sound from a certain category (i.e. S1), a film from the equivalent category (F1) and a film from a second category (i.e. V2). I want to investigate if participants can match at above-chance level, an so, for every trial one film should be correct and the other incorrect. I’d like randomize which is which, constrained by category (that is, a sound for F1 should be randomly matched for a film in V1, and so on).

-All sounds should be correct only once, as participants will be instructed the sounds are equivalent to words (which should only have one meaning). There is no constraint on how many times a film can be incorrect.

If there’s something I’ve missed to fill in, I’m happy to do so.

Thanks for your help,
A. E.

How many trials?

Do the other films (the ones you label V1, V2, etc) come from the same set of 24 films of type F1 through F4?

Hi, Michael,

In every experiment, there will be 24 trials, so that every sound will be correctly matched once. After that, the experiment end.

Yes, sorry about the inconsistency. I must have gotten lost between F(ilm) and V(ideo) when writing – but in both examples they are part of the same corpus of 24.

Mmm, this is actually non-trivial.

from numpy.random import shuffle
import copy

sounds = []
sound_names = ['A', 'B', 'C', 'D', 'E', 'F']
matching_films = []
film_names = ['A', 'B', 'C', 'D', 'E', 'F']

# create a list of sounds in order, with a corresponding list of
# randomly-chosen films of the same type:
for sound_type in [1, 2, 3, 4]:
    for i, sound_name in enumerate(sound_names):

# now need an ordered list of films from which to select the 
# non-matching films:
sorted_films = copy.copy(matching_films)

# break that list into types, so we can sample from them evenly:
film_sublists = [] # will be a list of four lists
for i in range(0, len(sorted_films), 6):
    sublist = sorted_films[i:i + 6]
    shuffle(sublist) # each type is ordered randomly

# to select non-matching types, we need to ensure that we never
# match a sound again with one of its matching film types:
nonmatching_films = [] # will be of length 24
for film_type in [1, 2, 3, 4]:
    nonmatching_types = [1, 2, 3, 4]
    # exclude the matching type from sampling:
    block = [] # the six non-matching films for this sound type
    for i in nonmatching_types:
        # get two from each non-matching type
    shuffle(block) # need to be randomised

# delete these: just for illustrative purposes

# bring the entries of the three lists together so they can be
# all randomised together (i.e. preserving their linkages):
lists = list(zip(sounds, matching_films, nonmatching_films))
conditions = [{'sound': sound, 'match': match, 'non_match':non_match} for sound, match, non_match in lists]
shuffle(conditions) # a randomised list of dictionaries, one per trial
print(conditions) # just for illustration