Scripts not compiling and Online Experiment rushes through routines ignoring duration nor waiting for a response

URL of experiment: encoding_paradigm_TOPSEM [PsychoPy] (pavlovia.org)

Description of the problem:

I am working on an experiment that I had already run online. Many tweaks were made, so its hard to trace the problem from there.

The main issue is: after ending the 4th routine, the experiment suddenly rushes through many routines (which should have a defined duration or require a response), flashing each really fast and then stopping at a routine as if normal. This happens a couple of times and then stabilises and continues the experiment as normal. Importantly, it does not always stop rushing at the same routines (note that loops are sequential in this buggy part).

This does not happen locally, only online (through my browser or pavlovia).

When I tried compiling the PsychoJS to inspect it I cannot. I get the following message:

Generating PsychoJS script...

I don't know the appropriate default value for a 'allowedKeys' parameter. Please email the mailing list about this error
I don't know the appropriate default value for a 'allowedKeys' parameter. Please email the mailing list about this error
I don't know the appropriate default value for a 'allowedKeys' parameter. Please email the mailing list about this error
I don't know the appropriate default value for a 'allowedKeys' parameter. Please email the mailing list about this error
508.8535     EXP     Imported C:\Users\...\Encoding_paradigm_TOPSEM\training_list.csv as conditions, 38 conditions, 12 params
508.8880     EXP     Imported C:\Users\...\Encoding_paradigm_TOPSEM\training_list.csv as conditions, 38 conditions, 12 params
514.8290     EXP     Imported C:\Users\...\Encoding_paradigm_TOPSEM\training_list.csv as conditions, 38 conditions, 12 params
514.8542     EXP     Imported C:\Users\...\Encoding_paradigm_TOPSEM\training_list.csv as conditions, 38 conditions, 12 params

I know the JS script is getting updated when I try changes because I have inspected it through other means. But for some reason the builder cannot compile it for me and it keeps showing the message about a default value for ‘allowedKeys’ even though I have made sure all my keyboard components have the allowed Keys field specified (e.g. I type in: ‘left’, ‘right’).

Don’t worry about the allowed keys warning. I get that all the time.

The behaviour you’re describing is probably related to mouse clicks to advance in the same location on the screen. Online the mouse is seen as already clicked. Try inserting an ISI of about 250ms to allow time for the mouse button to be released or delay the start of the mouse component.

Thanks for the quick reply!

Good to know the message is not worrisome, but it would be nice to quickly draw up the .py and .js scripts with the built-in compile buttons.

I don’t use mouse clicks to continue through routines, I use keyboard presses which take about a second to activate. I also have several ISIs that are rushed through nonetheless (these have no mouse or keyboard components, they have a fixed time defined by the duration of the fixation cross component).

Any other suggestions?

Please could you show the details of an example routine that is rushed through. Does it have a code component? Does it have any routine settings? What version of PsychoPy are you using?

So the last routine that works has a Keyboard component with allowed Keys [‘left’, ‘right’]. It also has a code component that checks which response is given, switches the show_correct or the show_incorrect variable to True based on the response, and ends the trial. Here is the JS code in the code component (each frame) for this functioning routine.

if (key_resp_example_fam.keys) {

if (response_given === true && t > (image_presentation_duration - 0.8)) {
    setTimeout(() => {
        continueRoutine = false;
    }, 800);
}

if (response_given === false) {
    if (key_resp_example_fam.keys.includes("left")) {
        show_correct = true;
        response_given = true;
    }

    if (key_resp_example_fam.keys.includes("right")) {
        show_incorrect = true;
        response_given = true;
    }

}

}

The next routine is an ISI with a polygon component and a text component. Both components are set to start at time (s) = 0.0 and stop at time (s) = 1. I also tried it with stop defined as duration (s) = 1. The icon of the routine is green and is tagged “(1.00s)”, in the GUI.

The routine after that is very similar to the last functioning routine. After that comes a routine with a keyboard component (allowed keys [‘left’, ‘right’], Force end of Routine is activated). Then comes a loop with an ISI and an example trial. It sometimes pauses at one of these. It then skips another 3 routines, enters another loop where it sometimes also pauses and waits for a response. Finishes that loop and moves on to the main trials loop where it eventually stabilises (I am unsure whether it always stabilises at the some point here, but I dont think so).

setTimeout doesn’t look like something that should be included in a Builder experiment

The purpose of that function is to make sure the feedback is shown for at least 800ms.

In python I used time.sleep(0.8), and because the automatic translator gave a very convoluted answer I used chatGPT instead to translate from python to JS.

I just changed setTimeout to time.sleep(0.8) as the automatic translator suggests but now the experiment gets stuck at “initialising…”.

The setTimeout function was doing what I wanted it to do though.


A thought I had when I pasted the JS code is whether I should set continueRoutine back to True in the End Experiment tab? Could it have something to do with that? Except I assume continueRoutine is always set to False when initiating a routine.

There’s no point setting contineRoutine=True.

What I do for a delay is:

Begin Routine

responseT = 0

Each Frame

if responseT > 0 and t > responseT:
     continueRoutine = False 

When the response is made set responsrT = t + .8 (but only if responseT == 0)

1 Like

That did it!

I substituted the bit where I was using setTimeout() with your suggested code and it worked.

Thank you very much!!!