This is probably a simple question, but I couldn’t find a solution.
I have two conditions files with different sets of images. And I have two routines - Trial and Que (see below). I have a code component within Trial which randomly selects one of the condition files. Right now it works. The issue is, I want Trial to present all images (rows) from the randomly selected conditions file and only after that should the Que begin with the same set of images.
What is the easiest solution to this? Thanks so much!
You can create two loops:
The spreadsheet of the Outer_Loop
will have a condition file containing your other condition files:
The spreadsheet of the Inner_Loop
will be the variable chosen_spreadsheet
that we set in the Inner_Loop
:
You can do it either with some code or only with spreadsheets.
Here’s the spreadsheets example:
2 Loops.zip (96.2 KB)
It should give you an idea on how to achieve it with code as well
Do you want the second loop to be in the same order as the first. If so, then you could set a random seed in a Begin Experiment code component using seed = random() and then use it in both loops
Thanks a lot! I deleted my code component and instead followed this instruction, it now looks like this:
However, after the first Trial is completed and just before the Que one is activated, I receive the * ReferenceError: asarray is not defined
No, the order is not important. But the set of images needs to be the same across both routines.
That just sounds like two loops pointing at the same spreadsheet.
They do point at the same spreadheet, but I get the error: ReferenceError: asarray is not defined for some reason
It’s challenging to troubleshoot the issue without seeing all your settings, spreadsheets, etc. Any chance you can upload a zip file containing all of those?
My experiment is too large to share here unfortunately, but I added the second trial to your experiment (because I need two trials, that’s the whole issue with my experiment: it works perfectly with one trial, as does yours, but not with two trials) and it didn’t work either, although the error was different: * when preparing the trial list
- unable to prepare trial list: unknown type: number
2Loops.psyexp (17.4 KB)
It seems to be working fine. See the following:
Loops.zip (37.1 KB)
Can you replicate the error you’re getting in the experiment you sent? This time includes the spreadsheet so that I will have an identical experiment.
Also, try to compare your experiment to the one I sent.
Thanks a lot! I couldn’t find any differences between our experiments, yet I am constantly getting the * ReferenceError: asarray is not defined at the end of the first trial.
URL of experiment: Regid3 [PsychoPy]
Sign in · GitLab
This is a link to the actual experiment, so there’s no way for me to see how you defined your spreadsheets or how you developed your experiment. I get the error you mentioned but I can’t troubleshoot it.
Maybe you can share the GitLab link (after changing it to public), so I will be able to see it as well?
Thank you, I’ve now changed it for public!
I’m not sure why the asarray error even occurs since there is no code in these two loops. Anyway, I added the following code component in Before experiment tab:
let asarray=function(something) {
return something;
}
but the error persists
This seemed to solve my asarray error issue:
I guess it may be due to the scope of the variables as well as functions in JS language, that is, the functions you define possibly are local rather than global, so they cannot work in other places of your codes. I encountered similar issues before in my program, but when I re-defined the functions or objects when I used them, it worked out!