Variable stimulus duration (or Interstimulus Interval) in Pavlovia

Hi!

I’d like to transfer an experiment with a variable Intertrial Interval (ITI) from Psychopy3 online to Pavlovia.

I’ve been able to get the variable ITI to work in multiple ways locally. These all involve putting on a stimulus for variable duration (or a variable startpoint), defining a parameter for ITI before or at the start of the routine (i.e. in code at the beginning of the experiment, or in a conditions file), then putting the parameter name in the ‘duration’ or ‘start time’ section of the stimulus in Builder.

However, when I try to put this on Pavlovia, the duration can’t be varied. I’ve realised this occurs because locally, the Python code imports numpy in order to put the variable duration, i.e.:

from numpy import (sin, cos, tan, log, log10, pi, average,
sqrt, std, deg2rad, rad2deg, linspace, asarray)
[…]
if tThisFlipGlobal > blank_between.tStartRefresh + asarray(ITI)-frameTolerance:

(here ITI is my variable name and asarray is imported from numpy).

This import does not convert to JS (as explained in @wakecarter 's Crib Sheet). Therefore, in the JS converted version for Pavlovia they just attempt to use the function ‘asarray’, which doesn’t work so it crashes.

Is there a way to implement a variable stimulus duration in an online experiment which doesn’t encounter this problem?

Thank you so much :slight_smile:

I have no issues with variable durations. However, I have not yet upgraded from 2020.2.10 due to the new bugs in 2021 that haven’t been fixed yet.

I’m sure there is a workaround for the issue you are experiencing but I’m reluctant to put much thought into it if it’s a 2021 bug

That’s useful to know, thank you! I am using the 2021 version and I’m sure I’ll find a solution. Something someone has suggested is to just define an ‘asarray’ function at the start which returns the input in the JS version. i.e.:

function asarray(name) {
return name;
}

I’m trying to do this but am getting an ‘Unhandled Internal Error’ when I try to sync it… do you know why this might be? Is there a problem with defining new functions in the Code_JS component at the start, am I doing something wrong, or could this be another bug in the 2021 version? (No worries if this is just something 2021-version-based)

Hey y’all,

To keep the thread uncluttered, shall we discuss this further in the other thread (where you also posted the error message given by PsychoPy). Error message: asarray not defined - #6 by verdi

1 Like

Sure, thank you! Sorry about that.

1 Like