Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[solved] ISI

edited December 2020 in OSWeb

Hi there

I am using the inline script with the following details:

import random

ISI_options = [1000,1500,2000,2500]

ISI = random.choice(ISI_options)

exp.set('ISI', ISI)


When I use OSWEB, it shows an error as follows:

Uncaught TypeError: Cannot read property 'apply' of undefined


Please could you kindly advice what to do helps replacing the relevant commands to have it run on the OSWeb?


Peace,

Masoud

Comments

  • Hi @mfp49 ,


    Herewith the JavaScript translation. Make sure to put this code in an inline_javascript item rather than the classical Python inline_script item.


    // Define the array with the possible ISI durations:
    var ISIArray = [1000, 1500, 2000, 2500]
    // Get a random number between 0 and the length of the array:
    var randomNumber = Math.floor(Math.random()*ISIArray.length)
    // Use this number as the index to determine the selected ISI
    var ISI = ISIArray[randomNumber]
    // Store the ISI in the vars object
    vars.ISI = ISI
    


    I attached a simple example experiment.


    Cheers,


    Lotje


    Did you like my answer? Feel free to Buy Me A Coffee :)

  • Dear Lotje

    Many thanks. Works perfect!

  • Great to hear @mfp49

    Did you like my answer? Feel free to Buy Me A Coffee :)

Sign In or Register to comment.