psychopy.org | Reference | Downloads | Github

Builder Loop: Randomisation of Stimuli from conditions file

OS : Mac OS Big Sur 11.4

What are you trying to achieve?:
Dear Psychopy Community:

I am trying to load a randomly selected number of stimuli (words) from a conditions file.
My current issue is that the words that are retrieved from the file repeat sometimes. However, they should appear no more than once.

What did you try to make it work?:
I am currently using the builder and have inserted a loop that calls up the excel file. In the loop properties, under ‘selected rows’ I have entered $random(6)*40. This works well for repeating the loop 6 times, however, every once in a while a word repeats.
What can I do to make sure that each word comes up only once?
Thank you in advance! :slight_smile:

Hello,
if you are repeating the loop 6 times each row in your cond file will be repeated 6 times. You should set it to 1

If I understand correctly, you are trying to pick 6 words (out of 40) for each of the 6 repeats.

Instead of having nReps as 6 and selecting 6 rows each time you could select all rows and end the loop after 36 trials. If you want something to happen every 6 trials then use if trials.thisN%6 == 0: for 0, 6, 12 or if trials.thisN%6 == 5: for 5, 11, 17.

Many thanks for your response! So the routine is quite short and only one word is presented per repeat. So ‘nReps’ is set to 1 and loop Type is set to random. With the ‘selected rows’ set to $random(6)*40, six words are shown in total (as desired), however, sometimes a word repeats, which it is not supposed to.
Your suggestion looks interesting, however I’m not sure if I understand. Where would I need to insert this code?
Thanks!

If you just want 6 words from 40 and the loop is called trials then leave selected rows blank and simply put

if trials.thisN == 5:
     trials.finished = True

in a Begin Routine or End Routine tab somewhere inside the loop.

1 Like

So far no further repetitions, looks like this is working! Thank you so much! :slight_smile: