psychopy.org | Reference | Downloads | Github

Online Version Not Matching 'Offline Version'

URL of experiment: https://run.pavlovia.org/Sonataforce/eab/html

Description of the problem:

Hi all. Bit of an issue… After much pain and aguish I have put together a pilot/working version of an attentional blink paradigm, which works as I want it in the ‘offline’ builder mode… But when I run it as a pilot on Pavlovia… it is doing something else.

I think the nature of the issue lies in the use of code components. I have had to use quite a few in order to get the experiment to work in builder, and namely this means terminating some of the loops early in order to satisfy some of the experiment conditions. It seems, at least from my untrained eye, that these are being ignored on the Pavlovia version.

Am I doing something incredibly silly somewhere? Or is this an ongoing issue?

Thanks!

Darren

Please show what you have actually done (i.e. show us your actual code snippets), and give other information (e.g. the version of PsychoPy you are using- relevant as some online loop issues have been addressed recently: Cannot exit loop in online Pavlovia (Using JS code component)).

Hi Michael

Thank you for getting in touch so quick. In essence, what I have managed to do in the builder mode, is from a list of 60 ‘filler’ words, to select 10 of those randomly, present them in succession. I have done this by terminating the loop early after the first ten randomly sailed words are chosen from the list as such:

I have ended some of the loops early my using in Begin Routine:

myCount3 = myCount3 + 1
if myCount3 > 10:
    trials.finished = True
    myCount3 = 0

While assigning myCount3 = o in Begin Experiment.

Is this what you meant? Or did you require the whole script? (Apologises if so).

In the meantime, I am going to try and do what was suggested in the link provided.

The reason seems to be that this code is still in Python. Python doesn’t (generally) run online. So Builder generates the experiment for you in Javascript when running online. But you are responsible for providing Javascript equivalents of any custom Python code you have inserted.

In your code components, note that there is now a “code type” button. This can be “Python”, “JS”, “Both” or “Auto -> JS”. You will want one of the last two. It is worth downloading the very latest version of PsychoPy from here, as it does now at least attempt to do some auto-translation for you if you choose that “Auto -> JS” option.

e.g. I’m not a Javascript person, but you Python code above looks like this when auto-translated:

myCount3 = (myCount3 + 1);
if ((myCount3 > 10)) {
    trials.finished = true;
    myCount3 = 0;
}

i.e. notice that Javascript likes a lot more punctuation than Python (which is why we all love Python…)

I don’t know if this will work, but hopefully it is a good start for you. Otherwise, look at online resources like:
https://www.w3schools.com/js/js_if_else.asp

OK update.

So I have downloaded the new version of PsychoPy, and I have used the Auto>JS setting, and now the count termination code component looks like this…

Screen Shot 2020-02-21 at 10.54.23

The bad news, is that it changes nothing about the issue with the loop not terminating when I want it too. Stuck, and feel a bit silly!

Ok, so after a bit of investigation… I think the first loop is working, i.e. it terminates correctly after 10 presentations of different (randomly selected) words.

Could this be a problem with the (first) loop finishing and then jumping out and ignoring the other loops I guess? Sorry if that is worded in a strange way.