Inner and outer looping

Hello,

I am using Builder for my experiment with a linked excel file.

The task simply requires participants to give a keyboard press to numbers on screen. I have two sets of stimuli. The first are just single numbers from 1-6 at the top of the screen. The second are two numbers 1-6 on screen (one above the other). I want the first stimulus type to be on loop for 5 trials and then a single trial of the second stimulus and then back to 5 trials of the first stimulus and so on. In essence, a stimulus from the second set will appear every 5 trials of the first stimuli set. I want my data to all save in one excel file so I can be adding data on overall %correct responses across both stimuli types. Does anyone have any advice about how I should do my loops? I was going to have a loop around routine 1 (that goes 5 times) and then an outer loop around routine 1 and 2. How can I make sure that the inner loop only goes 5 times before moving on?

Thanks,
Lucy

I guess you could insert a code component in the first routine that sets a counter at the beginning of the experiment (something like myTrials1 = 0 in the Begin Experiment tab) and then each time it runs it goes up, plus a conditional that stops the loop at 4 repeats so that it only runs 5 times looking something like this:
myTrials1 = myTrials1 + 1
if myTrials1 > 4
trials.finished = True
Thats assuming the inner loop is called trials, of course.
Then, you can insert another code component in the second routine that resets myTrials and starts a different counter so that everything is repeated the number of times you want.
That is, assuming you are using two different routine that only differ in that stimulus. You could instead create a single routine with both stimuli and have the second one only be shown each 6 trials, but i think you wouls have to tamper with a little coding

1 Like

Thank you, that works perfectly!