There is a bit of a trick you can do to randomise two things separately in the same loop - it’s easier to show than tell, so here is an example experiment I just made which does it as simply as possible:
indrand.psyexp (11.2 KB)
strings.csv (41 Bytes)
Essentially, you create a loop with the number of repetitions you want, and make each row of the corresponding csv
file a list of all the possible values, separated by a delimiter (here I use a comma). The first thing you’ll need to do is import random.numpy.choice
so you have access to this function. You can do this using a Code component, with this in the Begin Experiment tab:
from numpy.random import choice as rndchoice
Using a Variable component, you can create a variable (I called mine txt1
and txt2
) with the value set to be rndchoice(
COLUMN NAME.split("
DELIMITER"))
. So, essentially, you’re saying “Take the value of this column, split it at every delimiter (a comma, in my example) so that it’s a list of strings, then choose one item at random from this list”.
Then you can just use this variable (preface it with a $
so that Psychopy knows to interpret it as a variable name) in your stimuli.