Howdy, Stranger!

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

Supported by

Randomization of sketchpad duration

Hi, I'm new to OpenSesame and python.

I want a sketchpad to have a randomized duration (eg between 400 and 1000 ms).

I found this discussion which seems to be exactly what I want: https://forum.cogsci.nl/discussion/1975/solved-randomized-duration-of-sketchpad-presentation

So, I have added an inline script with:

import random
var.stim_duration = random.randint(400,1000)

Then I have my sketchpad with duration listed as [stim_duration], including the square brackets.

When I run the task, it terminates, and indicates that "The variable 'stim_duration' does not exist"

When I look at my variable inspector, stim_duration is listed (though it is not bolded).

What am I doing wrong?

Robin

Comments

  • Hi @rlaycock ,


    Welcome to the forum and good to hear that you got so far in finding the solution! :)

    It sounds like you are trying to use the variable "stim_duration" before it defined in the inline_script item. Did you make sure that:

    • You placed the inline_script item before the sketchpad that uses [stim_duration]?
    • You placed the Python script in the Prepare tab (and not in the Run tab) of the inline_script item?

    For more information about OpenSesame's prepare-run strategy, see here:



    If this doesn't solve the issue, feel free to upload your experiment here so that we can have a closer look.


    Cheers,


    Lotje

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

  • @lvanderlinden

    Hi Lotje,

    many thanks for your reply. And thanks also for fixing this issue!

    I did have the inline script before my sketchpad, but I was not aware of the difference between Prepare and Run. Once I put in in Prepare that fixed it.

    Thanks again.

    Robin

  • Great Robin, thanks for getting back to us with the solution! :)

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

Sign In or Register to comment.