Description of the problem: I’ve been trying to convert a jittered ITI routine from a PsychoPy study to PsychoJS but am having trouble with the code conversion.
This worked perfectly when run in PsychoPy. However, when running in Pavlovia, the jitter function is not defined. Is there a way to make this work in its current state? I looked into converting the code to Java and ended up with this instead:
jitter = Math.random()*(0.3 - 0.6) + 0.3;
I’m not too familiar with Java so the above didn’t seem to work either! If I need to use Java to get around the first problem, I would prefer a set of defined increments of 25ms, randomly chosen, as in the python version but after looking around have not been able to find the solution myself!
I can’t seem to get the jitter to range between the values i’m looking for (300 - 600ms). The third line gives me a data point which suggests there is either 0ms jitter or 1000ms jitter.
I think that your problem is that you are rounding to the nearest second.
Also, you should note that Math.round doesn’t do what you might expect in JS. You’d need to define it as the following if you want to have any decimal places.
Hi @wakecarter, seeing as you have helped Ral previously, it would be great if you could help me too… I have also have a problem with code conversion for jittered ITI and thought it might be better to reply to this thread instead of starting a new one. Yet, I think my code is more complex than Ral’s, as I also want to log the jittered ITI for the fixation cross for each trial.
I’ve attached screenshots of my Builder, as well as the fixation cross component, and the code components for the jittering and for logging the jittered ITI.
So, my Psychopy/python code can run without any issues and the ITI is successfully jittered when I run Psychopy, jittering the ITI from the set [0.4, 0.6, 0.8, 1, 1.2, 1.4].
BUT my problem is that my Javascript code doesn’t successfully jitter the ITI – the programme seems to choose one random ITI (e.g. 1.2s) from my set of values and the same ITI is then used for all trials when I run the online experiment on Pavlovia.org.
I previously have never used Javascript before so all the code conversion/translation has been based on my Googling, so please let me know if you figure out what’s wrong!