Hello, I’m new to PsychoPy & in need of assistance.
I have designed an experiment (using the builder) where in a single trial participants are simultaneously presented with audio stimuli and text stimuli. In a single trial participants:
- See text (combination of 3 letters)
- Hear 3 sounds and must decide which sound is the odd one out.
- Must indicate which sound is the odd one out by clicking either ‘z’ or ‘m’
I have created an excel sheet which contains all the values i.e. text stimuli (x 30 unique 3-letter-long combinations), sound stimuli (10 varieties input 3x to match no. of text stimuli), correct answers (in response to sound stimuli), and a jpg of a piano key (30x) which is to be displayed at all times. This list has to be repeated only once.
I have used the ‘randomize’ function within the builder which is fine but I would like to ensure that no one set of letters or sounds features in consecutive trials (i.e. TRIAL 1: text stimuli ‘ijb’ & sound/a.wav; TRIAL 2: text stimuli ‘abz’ & sound/d.wav; TRIAL 3: can’t include either text stimuli ‘abz’ or sound/d.wav)
I have tried inserting a code element at the beginning of the loop and top of the routine but info in the loop prevails i.e. same stimuli is still likely to feature twice in a row. This is the code I got from another post (by kmcdubb);
stimulus_list = [‘v’, ‘b’, ‘n’, ‘m’] * 3
shuffle(stimulus_list)
make sure the same target doesn’t appear on consecutive trials
double_stim = False
list_ok = False
while list_ok == False:
for i in range(len(stimulus_list) - 1):
# check for equal neighbours:
if stimulus_list[i] == stimulus_list[i + 1]:
double_stim = True # D’oh!
break # can stop checking on this run
if double_stim == True:
shuffle(stimulus_list) # try a new order
double_stim = False
else:
list_ok = True # Yay! The loop won’t run again.
print(stimulus_list)
I have adjusted it accordingly
stimulus_list = [‘jzt’, ‘wzt’, ‘ijb’, ‘ikj’, ‘abz’, ‘rnq’, ‘tkz’, ‘htg’, ‘orh’, ‘hia’] *# I have adjusted the values to those in my stimuli sheet. Removed 3.
shuffle(stimulus_list)
make sure the same target doesn’t appear on consecutive trials
double_stim = False
list_ok = False
while list_ok == False:
for i in range(len(stimulus_list) - 1):
# check for equal neighbours:
if stimulus_list[i] == stimulus_list[i + 1]:
double_stim = True # D’oh!
break # can stop checking on this run
if double_stim == True:
shuffle(stimulus_list) # try a new order
double_stim = False
else:
list_ok = True # Yay! The loop won’t run again.
print(stimulus_list)
I also created a revised excel sheet where I took out the column containing these 3 letter combinations so as not to confuse the builder. The revised sheet linked to the loop has 3 columns only (piano, corrAns, picture). When I run it in the builder the 3 letter combinations aren’t showing. Would anyone have any idea as to how to get around this problem?
Also, I need to be able to run this on Pavlovia, but for now getting it working in the builder would be great. Many thanks!
Would you be able to explain in more detail? I’m attaching a copy of my stimuli sheet. As you can see there are 4 columns. The values in $stimuli are already set i.e.the 3-letter combinations. The builder has to loop once through all these entries ensuring that consecutive trials do not contain the same values. They way it’s randomnised now (using built in randomise function) there is a chance that i.e. value ‘orh’ will be presented twice in a row - this kind of repetition I’m trying to avoid. Many thanks again!

