Randomizing loops

What did you try to make it work?:
I have two loops in my experiment ( Loop A and Loop B). Each loop present different kind of stimuli ( one loop present a picture and the other present a video). Within each loop, I have 8 trials. I want to randomize the order of the loops but I don’t want to present all 8 trials within each loop all together. Meaning That, I want to present one trial from Loop A, and then another trial from Loop B. For example, trials order can be : a1, a2, b1,a3,b2,b3…

What specifically went wrong when you tried that?:
I tried adding an outer loop that contains an excel file to randomize order of the inner loops. However, what it does is that it randomizes the order of loops, such that all trials from same loop are presented one after another.

Thank you in advance!

Hi There,

This is a fun scenario! I think you want to be resetting the ‘Selected Rows’ field of your inner loop on each iteration (so it only selects one row [ trial] rather than running through all of the rows). One way to do this is to add a column to your outerloop conditions file (e.g. rowIndex) and use that as input to the Selected rows field of your inner loops. This will mean the number of rows in your outer loop equates to, n trials per condition * n routines.

Let us know how you get on!
Becca

Thank you Becca!

It’s actually my first time programming in Psychopy so I’m not sure what I’m doing wrong.
The file for my outer loop contains one column for file names( LoopA.xlsx and LoopB.xlsx). I also added a column for row index starting from 0.
In the inner loops, I added the file that is specific to each loop, and in selected rows, I wrote the name of the column for row index (RowIndex). For some reason It’s not working
I’m attaching here a screanshot of my file for the outer loop


Thank you again!

Hadeel

Hi,

The outer loop file all looks correct there. So on your inner loop you just want to have the Selected Rows set to $rowindex and the conditions file set to $confile (again as you said!) do you get an error in your stdout section of your runner view? if so please can you share that with us?

Becca

Thank you Becca.

I tried to do the same thing on a very simple version of two loops, with 2 trials within each loop.
This is the file for outer loop:
image

and this is the parametrs for the inner trials :slight_smile:

and this is for the outer loop:
image
And it does not work. I don’t get any error message in the stdout, the experiment just shuts down.

Thank you again!

Hi There!

OK I see that it is because the “Selected Rows” needs to be a range if the value is larger than 0. So try formatting your conditions file like this :slight_smile:

Screenshot 2020-09-17 125554

Becca

randomTrialsNested.psyexp (7.9 KB) outerCond.xlsx (8.7 KB) cond2.xlsx (8.5 KB) cond1.xlsx (8.5 KB) here is a demo that I have been working off with associated conditions files

Thank you so much Becca!!

Hi! I am trying to do the same think as Hadeel - randomize trials between loops (loop1 and loop4) using an outer loop. So for example the trials would look something like this: 1.1, 1.3, 4.5, 1.2, 4.6, etc. I tried to follow what Hadeel and Becca did, but I get an error stating that the stimuli from loop4 cannot be found. I think what is happening is that the outer loop is going through loop1 (works okay) but immediately goes to loop4 as part of the same trial, but it cannot find the excel with the loop4 stimuli. I can share screenshots or files if that would be helpful to demonstrate. I appreciate any help :slight_smile:

For resource not found errors please look at:

https://psychopy.org/online/resources.html#handlingonlineresources

and

https://psychopy.org/online/psychoJSCodingDebugging.html