psychopy.org | Reference | Downloads | Github

How do I get coder to show participants a random subset of all stimuli?

Hi all,
I have150 stims but want to show a given participant a random 75. How would I do this? The study is a simple stimulus rating task, I use a conditions csv file to store trial names and use trial handler to show participants the stimuli.
Thanks,
Richie

Depends what the stimuli are, words, pictures, shapes? For now, if you have a list of words e.g. words=[“duck”, “tree”, … “rock”, “cloud” ] you would just call numpy.random.shuffle(words) which shuffles the order 'in ‘place’ and then pick off the first 75 for a subject. When it is run for the next subject, a different ordering would occur. If you don’t want to disturb the words list, make a list of integers from 0 to 149, then shuffle this list and pull the items from the word list according to the first 75 numbers in the list of integers.

If using Builder, the easiest solution is simply to choose a loop type of random and then terminate the loop after 75 trials. This gives you your random subset of 75 conditions.

Insert a code component from the “custom” component panel, and in its “End routine” tab, put something like this:

if your_loop_name.thisN == 74: # the 75th trial counting from 0
    your_loop_name.finished = True