Howdy, Stranger!

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

Supported by

[solved] Randomized duration of sketchpad presentation

edited March 2016 in OpenSesame

Hi everybody,

I desperately tried to randomized the presentation time of a picture presented in a sketchpad (duration between 400 et 1200 ms), but i don't manage to find the solution, either on Google (I probably missed the information) either by manipulating my code (with random.randint(400,100) for example)... I'm a beginner and i think I need your help.

Many thanks for your tips !

Nadam

Comments

  • edited 10:44PM

    Hi Nadam,

    If the presentation time of your sketchpad is defined as stim_duration, you have to put [stim_duration] in the field duration of the sketchpad. Before that, you have to define which value stim_duration has on a given trial. If you want it to be selected from a limited set of discrete values (e.g. 400,600,800,1000,1200), it is probably best to add a stim_durationvariable to the trial_sequence. However, if you really want it to be a random interger between 400 and 1200, you have to add an inline_script to the sequence (before the sketchpad) and paste this code in the prepare_phase:

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

    And that should be it. I hope this helped.

    Good luck,

    Eduard

    Buy Me A Coffee

  • edited 10:44PM

    Hi Nadam,

    You were already pretty close to the solution :) You need to switch your values around; random.randint(100,400). You can't enter this command in the duration box directly though. So before the sketchpad, you could insert an inline_script item where you define the variable exp.duration = random.randint(100, 400). You may have to insert import random at the top of this script as well.

    Now you can insert [duration] (with brackets) in the duration box, that should do the trick.

    Cheers,

    Josh

  • edited 10:44PM

    Double help - awesome

  • edited 10:44PM

    Many thanks to both of you ! It works !

Sign In or Register to comment.