Randomize picture presentation depending on condition

I feel a little stupid that I am not able to do this myself. I try to achieve the following:

Let’s say my participants will be presented with sentences from two conditions. Either they see a positive statement or a negative statement. I have a csv file which looks contains these sentences:

sentences
positivesentence1
positivesentence2
positivesentence3
positivesentence4
negativesentence1
negativesentence2
negativesentence3
negativesentence4

Participants will be presented with the sentences in random order. Now they will be additionally presented with a picture. They either see a picture of a clown or a picture of a bear (I am completely making this up for illustration). Here, I have a csv file too:

picture
clownpicture1.jpg
clownpicture2.jpg
clownpicture3.jpg
clownpicture4.jpg
bearpicture1.jpg
bearpicture2.jpg
bearpicture3.jpg
bearpicture4.jpg

There can also be just one csv file with two columns, doesn’t matter. But what I want to achieve is that two of the positive sentences are combined with a clown and two with a bear. Similarly, two negative statements should be shown with a clown and two with a bear. However, if I just use plain randomization a participants might, in the end, for example, see three positive sentences combined with a clown. That’s not what I want.

I really would appreciate any help :slight_smile:

I’m not so sure whether this works and even if it works there is probably a more elegant solution.

I added a (probably messy and overly complicated) code component:

picsa=["clownpicture", "clownpicture", "bearpicture", "bearpicture"]
shuffle(picsa)
picsb=["clownpicture", "clownpicture", "bearpicture", "bearpicture"]
shuffle(picsb)
picscomplete=picsa+picsb

numbers=["1.jpg", "2.jpg", "3.jpg","4.jpg","1.jpg", "2.jpg", "3.jpg","4.jpg"]
shuffle(numbers)
lista = [m+str(n) for m,n in zip(picscomplete,numbers)]

sentencesa=["positivesentence", "positivesentence", "negativesentenec", "negativesentence"]
shuffle(sentencesa)
sentencesb=["positivesentence", "positivesentence", "negativesentenec", "negativesentence"]
shuffle(sentencesb)
sentences=sentencesa+sentencesb
sentencenumbersa=["1", "2", "1", "2"]
shuffle(sentencenumbersa)
sentencenumbersb=["3", "4", "3", "4"]
shuffle(sentencenumbersb)
sentencenumbers=sentencenumbersa+sentencenumbersb
shuffle(sentencenumbers)
sentencelist = [m+str(n) for m,n in zip(sentences,sentencenumbers)]

Then I added a loop around my trial with 8 repetitions.
I include the (fantasy) sentences via: $lista.pop() (with “set every repeat”) and
the pictures via: $sentencelist.pop() (with “set every repeat”)

I’m not so sure whether this does what it should, but I will have a glass of wine now and call it a day :joy: