Unable to set specific duration for specific stimuli

Hello everybody,

Description of the problem: Using the builder, I am currently trying to build an online experiment in which each stimulus has a specific duration. However, when I set in the Stop parameter the name of my column of the .csv file containing the timing with the $ (e.g., $myDuration), in Pavlovia I get the following message right before the stimulus: * ReferenceError: asarray is not defined

How can I solve?

Thank you

Daniele

1 Like

Hi
In the newest version I don’t think you need the $ sign in the duration

Best wishes
Glen

Thank you, but that actually does not solve the issue.

Daniele

What type of stimuli? I don’t think durations for sound components work.

Verbal stimuli, I need each stimulus to stay on the screen for a fixed time (different across various stimuli conditions).

Thank you

Daniele

By verbal I’m assuming audio.

Create a sound component in an earlier routine and set the start time to after you want the routine to end. You may therefore need to end the routine using continueRoutine=False

You can then start and stop the sound in code using .play() and .stop()

Sorry, to me verbal is a string of letter :slight_smile:

Please could you show a screenshot of your text component?

I would like to show the text stimuli in the left column for a given time (right column)

Schermata 2021-03-02 alle 15.34.10

@Glen is right that you don’t need the $ in duration as it’s already marked as literal.

This is most likely a quirk of the JavaScript translation - in Pyhon, asarray is used to ensure that whatever value you give as the duration, it’s easy to operate on. It may be that an equivalent function either doesn’t exist in JavaScript or has a different name - which we need to account for when creating the JavaScript code. I’ll bring this up with the JS team and make sure we’re in sync!

2 Likes

Thank you!

Daniele

Hello all. Any further developments on this issue? I ran into the same problem, I am trying to set variable stimuli durations but I receive the same error message when testing in pavlovia. @Daniele_G have you found a workaround?

Thanks!

Dear Ricardo,
Sorry, we changed our task, so no developments.

Daniele

In an earlier version this year, I used the following code in the Begin Routine JS part of a custom code component to implement a jitter and save it to the log:

jitter = (0.6 + Math.random() * 0.4);
psychoJS.experiment.addData("jitter", jitter);

I used to put in “$jitter” in the duration part of the respective text component that needed to be jittered.

Now, the following changed:

in addition to defining jitter the way described above I now write the following in the start experiment JS part (as suggested by wakecarter somewhere else):

asarray=function(jitter) {
return jitter;
}

also, I now need to put “jitter” without the dollar sign in the duration part of the respective text component that needs to be jittered

What version of PsychoPy are you using? I’m hoping that this isn’t needed for 2021.1.3 onwards.

OK that’s great news! I am using 2021.1.2 but hesitant to upgrade so I don’t break anything else!

Unless you’re mid data collection then I’d recommend that you upgrade.