Howdy, Stranger!

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

Supported by

Random stimulus presentation time

edited December 2020 in OpenSesame

Hello!

I was trying to implement an experiment for the university in OpenSesame and found myself stuck at one moment. I need to create a sketchpad with the fixation dot, which should be shown to the participants for a random period of 0–10,000 ms.

I understand that random timing can be done using an inline script, however, every my attempt to create one ends up with plenty of bugs and experiment not working.

As far as I understand, the code should look somewhat like this and be implemented inside the trial sequence before the sketchpad. The duration

import random

random_time = random.randint(0,10000)

self.experiment.set("random01", random_time)

I just don't understand what exactly I am doing wrong... Would be grateful for any help, thanks!

Comments

  • Hi @wyeird


    You were quite close, except that the self.experiment.set() function is outdated. It is easier to use the var object like so:

    import random
    var.my_duration = random.randint(0,10000)
    print(var.my_duration)
    


    Make sure to:

    • Place your inline_script item before the sketchpad item that you want to determine the duration for
    • Use the square-bracket syntax to indicate the duration of the sketchpad item like so:
    [my_duration] 
    


    I uploaded an example.


    Cheers,


    Lotje

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

Sign In or Register to comment.