URL of experiment:
Description of the problem:
I have created a study in Psychopy using video stimuli.
But when I upload the experiment to Pavlovia, the experiment runs for a couple of seconds (showing two of the sets of videos) and then it crashes with the error: TypeError: Cannot read properties of undefined (reading ‘0’).
It seems to be happening on the second loop within the experiment (shown in image below). It seems to run the ‘observation’ loop once where the ‘obs_ran’ routine plays followed by the ‘obs_l’ and ‘obs_r’, but when it goes to do another rep of the whole observation loop it crashes.
Any help would be much appreciated.
Please copy the full text of the error message that pops up, and if possible please also get the text of the error message from the browser’s developer console (go to view or window → developer to find the console).
OK. That means that it can’t read a property for the next trial. Can you share the loop settings for all four of the loops here? Observation, random_example, dots_obs_l and dots_obs_r?
I also have a code component defining dots_obs_l and dots_obs_r
First, try putting that code in the “before experiment” tab rather than the “begin experiment” tab. I don’t think that’s the main issue but just in case there are any scope problems it will help.
Otherwise, I’m not sure. It could be an issue with the “inner” loop (random_example) not being able to read the excel file again after the first run through it, but in principle I think that should still work. How is the “Routine” parameter used in obs_l and obs_r?
I just have a few comments about the structure of your experiment. My comments will not help you directly with the error message you get, but they may help you to simplify the flow of your experiment and make debugging easier.
- A loop with nReps set to 1 is executed once. Unless you set some parameter in that loop, it is essentially equivalent to an experiment run without the loop. So your loop observation does not seem to be essential to your experiment.
- The same seems to be true for the loops dots_obs_l and dots_obs_r which you initialise with 1 at the beginning of the experiment. If you do not change this value during the course of the experiment, you do not need the loops.
- If you change the value of dots_obs_l and dots_obs_r after initialising them, you must do so before their respective loops are executed.
- Also make sure that you use the same name for the loop and nReps, dots_obs_l and dots_obs_r. Avoid using the same name twice.
- only tick is trials in the loop definition if it really is a trial. So it is probably sufficient to tick this only for the innermost loop.
If trials between blocks differ only in the stimuli presented, their location aso., it is better to reuse a routine than to create an extra routine for each stimulus configuration.
Best wishes Jens
I have tried putting the code into the “before experiment” tab, but nothing seemed to change.
Here is the routines:
Thank you! I have modified these areas, hopefully this will make it run more smoothly.
No the dots_obs_l and dots_obs_r stay the same throughout the experiment. Do I need to set it to a different value?
I use the stop code so that the videos stop playing, to let the next videos play without overlap.
I do not know if you need to set dots_obs_r/l to a different value. You have to know. You define how often the loops dots_obs_rl/ are repeated. So if it is not necessary for your experiment that the loops are repeated and you never change the value of dots_obs_r/l from 1, you can simply delete the variables and the loops dots_obs_r/l.
Best wishes Jens
I have changed it so that dots_obs_l/r run 3 times as I had planned. This seemed to get rid of the error and it runs for longer but then it stops again. Also, it gets rid of the randomisation of the loop (i.e. it just plays left three times and then right three times and then stops with the same error).