psychopy.org | Reference | Downloads | Github

Experiment halts/hangs after first stimulus

URL of experiment:

https://gitlab.pavlovia.org/rubenvanbergen/occlusiontask

I don’t have credits to share the actual experiment but this links to the code. There’s some junk in there but the actual (work-in-progress) experiment is in builder_doodle{.py, .psyexp, .js}

Description of the problem:

Each trial in the experiment starts with a fixation period, followed by a stimulus, followed by a mask, followed by a response, followed by feedback. A stimulus consists of four digits drawn partially occluding each other, in random positions. The stimulus has one of three randomly chosen durations. These parameters (positions, durations, and which digits to present) are generated procedurally using random() and randint(). These parameters are all generated at the start of the experiment as lists (with one entry per trial). Stimuli are set to update these properties at every repeat, and in the builder I then set it up so this information is loaded from the appropriate list. So e.g. the position of stimulus ‘digit0’ is set as $(trial_digits_posx[trial_idx][0], trial_digits_posy[trial_idx][0]).

Now for the problem: when I run this experiment in Pavlovia, it runs until the first stimulus (which appears on screen correctly) and then just halts. The stimulus remains on screen forever, and there is no error message. I have no idea how to effectively debug this as I know next to no JavaScript (I rely heavily on the automatic translation in Builder, with limited editing of the JS when bugs arise), and with no error message it’s hard to figure out where the problem even arises.

I should also note that locally, the experiment runs just fine.

I do have one additional clue to the problem. As I said my stimulus durations are procedurally generated at the start of the experiment, and then read out every repeat like this:
image
image

If I instead fix the mask to begin at 0.5 s, then what happens is that the stimulus appears, then the mask is presented, but then the stimulus comes back on screen (or is revealed again by the mask disappearing) and once again just stays there and nothing else happens. Similarly, if I set one of the digits’ duration to a constant, then that digit is removed from the screen correctly after that constant duration and does not return (but the other digits, that have their durations set as a variable, still remain).

So, long story short, it seems to have something to do with the way that the timing parameters are set in the code, which somehow has the effect that the trial routine is never ended and the stimulus’ autodraw parameter is never set to False. However I cannot figure out why this happens as the code looks fine (there are definitely lines in there that appear to do these things and the only difference seems to be that the timing is set by these variables rather than a constant).

Any idea what might be causing this?

Your JS code has stuff I don’t understand (e.g. .call(this);). I would separate Both code and Auto code into separate components to keep the manual JS code to a minimum.

The first step is to try to work out whether your arrays are being set up as you expected using print / console.log.

Console.log can also help with working out where your code has got to.

If any of your durations are undefined then you’ll get the behaviour you’re seeing.

Thanks!

I maybe should have held off on posting this as a bit more debugging revealed the issue, and your intuition was correct! My python code for generating these lists did not translate to JS properly and so the stimulus durations list was actually set to a single value of NaN. (I’m starting to learn that I need to resist the urge to vectorize operations, and instead just stick everything into an ugly loop that appends items to lists. Whenever I try to do something more elegantly, I get punished by Auto->JS with code that doesn’t work.)

Thanks again for a helpful reply!