Ask Your Question
4

How can the stimuli from two different loops be randomly combined in OpenSesame?

asked 2021-08-08 11:00:00 +0000

nofretete gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2023-02-20 08:00:00 +0000

djk gravatar image

One way to randomly combine stimuli from two different loops in OpenSesame is to use Python code.

First, define the two loops and their corresponding variables:

loop1 = items1 # first loop
loop2 = items2 # second loop
n_trials = len(loop1) # number of trials in each loop

Then, use the random module to randomly select a trial from each loop and concatenate them:

import random

combined_items = [] # list to store combined items

for i in range(n_trials):
   item1 = loop1[random.randint(0, n_trials - 1)] # randomly select a trial from loop1
   item2 = loop2[random.randint(0, n_trials - 1)] # randomly select a trial from loop2
   combined_items.append(item1 + item2) # concatenate the stimuli and add to the list

Finally, create a new loop using the combined_items list:

combined_loop = [[i] for i in combined_items] # convert the list into format suitable for a loop
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-08-08 11:00:00 +0000

Seen: 10 times

Last updated: Feb 20 '23