Main loop playing sub loops randomly

MacOS Sierra
PsychoPy3.2.4

Hello PsychoPy community!

I’m currently working with the builder to build the framework for my experiment to later gradually finetune things with the coder.
I have read through many threads and still could not find a working solution for my issue. My experiment consists of a main loop that is supposed to repeat 12times and while initiated six sub loops in a random order. So far, the main loop always crashes after one full run with an index error ("line 853, in
WordVisual = WordV_item[WordV_order[WordV_trial]]
IndexError: list index out of range).
I cannot figure out why this is happening and how to solve this issue. Also, the main loop is not playing the sub loops in a random order, although it is supposed to and its TrialHandler says so. Is there a way to make this work in the Builder or does this have to be handled in the coder?

Any help is appreciated very much as I’m new to PsychoPy (also coding solutions are warmly welcomed)!

Have a great day!
Testing.psyexp (54.4 KB) AStimuli.xlsx (11.1 KB) VStimuli.xlsx (7.4 KB)

Hi,
I read your thread and I wanted to know if you could find a solution to playing loops in random? I have the same problem and loops in my psychopy file are presented sequential not random, however I’ve set the outer loop’s LoopType in random. and I don’t know what to do!

I haven’t looked at your flow (I’m on my phone) but an outer loop can be used to repeat an inner loop using parameters in a random order. It won’t randomise the order of multiple different sub loops.

Hey there!
I decided to switch to Coder to solve this problem. There I have solved it by defining different functions and creating a list of these functions that I shuffled randomly and then the main loop iterated through the list for the desired number of times (the list was shuffled after each full loop again).

If you need it, I can surely share some of my code but keep in mind that I’m just a beginner in programming!

Best wishes!

Hi,
Thanks for your reply. Yes, if it’s ok for you, I’d like to take a look at it.

Hi,
I have the same problem. If it is still OK for you, I’d like to look at it as well. Thank you so much.

Hi there!
I am not sure if the code will be much of a help as it is quite much and there are many different functions. But if you want to solve the randomization with the coder, just do the following:
create a list of functions e.g. list_functions = [Func1, Func2, Func3, …]
then you can randomly shuffle that list e.g. np.random.shuffle(list_functions)
And you could iterate with a main loop through that list e.g. for funcs in list_functions: funcs()

You can also shuffle the functions at the end of each main loop run if you need to. This is a really great way to randomize loops and subloops and subsubloops.
I hope this helps! If you still want to see the code I can upload a screenshot, but again its quite long and a mix from builder & coder stuff, so I am not sure it will be readily understandable.

Best,
Zara