Howdy, Stranger!

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

Supported by

[solved] Random interval repetition task

edited March 2014 in OpenSesame

I would like to use a random interval repetition task with two intervals: 900 msec for the short intervals and 1500 msec for the long intervals. These lengths should be sampled randomly each with a probability of 0.50. So the average pace is 1200 msec. I would like to set a restriction of no more than four of the same intervals in a row. Each bleep is a 200-Hz tone presented for 50 msec, and the intervals will be measured from the onset of the bleep to the onset of the next bleep. So in fact the advanced delay time should be 850 of 1500ms. Dependent variables are RT and error rate (failure to respond in time to the stimulus).

So for example: 850 - 850 - 1450 - 850 -1450 - 1450 etc.

Can someone advise me how to program this?

Thanks! Suzanne
s.c.vanveen@uu.nl

Comments

  • edited March 2014

    Hi Suzanne,

    The most effective way to do this, is by using a bit of inline scripting (and since you want to do things pseudo-randomly, there is no alternative). The following script can be used to create a delay, to which you can refer to in other items using [interval]. Add the following to an inline_script at the start of your trial, preferably in the Prepare phase.

    # import the random module, we will need this
    # to make random choices for us
    import random
    
    # next, check if the history list already exists; if
    # it doesn't, we create a new one (the history
    # list is there to keep track of the previous three
    # trials)
    if not hasattr(exp, 'histlist'):
        exp.histlist = []
    
    # randomly choose an interval
    interval = random.choice([850,1450])
    
    # check if the random interval is used in all of
    # the past three trials
    if exp.histlist.count(interval) >= 3:
        # choose the opposite interval
        if interval == 850:
            interval = 1450
        elif interval == 1450:
            interval = 850
    
    # store the new interval in the history list
    exp.histlist.append(interval)
    
    # delete the older entries, as we only keep track
    # of the past three trials
    while len(exp.histlist) > 3:
        exp.histlist.pop(0)
    
    # save the interval variable, so that we can use it
    # in OpenSesame's GUI
    exp.set("interval", interval)
    

    By the way: as the interval is determined in the inline_script, you could get rid of the advanced_delay altogether, and simply use the interval as the duration of the sketchpad preceding your advanced_delay.

    Good luck!

  • edited March 2014

    Hi Edwin,

    Thanks for your quick reply on my question! I added the inline script at the beginnen of my experiment/trial, in the prepare phase.
    I only don't understand what you mean with your last comment: "simply use the interval as the duration of the sketchpad preceding your advanced_delay."

    I used to have a loop with a sequence with:

    * advanced delay
    * sampler
    * synt
    * keyboard
    * logger
    

    In the sampler I added my sound: hoog200Hz.wav
    In the synt controlor, again the Hz: 200
    In the keyboard respons: cr = b, timeout = 2000

    This is the editing script for my loop:

    set repeat "40"
    set description "Repeatedly runs another item"
    set item "recall_mem1_RT"
    set column_order "beep;cr"
    set cycles "1"
    set order "random"
    setcycle 0 beep "hoog200Hz.wav"
    setcycle 0 cr "b"
    run recall_mem1_RT
    

    Where to specify the term [interval] as you mentioned?

    Cheers,
    Suzanne

  • edited March 2014

    I assumed you were using a visual stimulus. Two options:

    1) Replace the advanced_delay with a sketchpad. Set the sketchpad's duration to [interval]. Just leave the sketchpad blank, so it won't change the way the display looks.

    2) Adjust the advanced_delay's script a bit (click on the black button in the top right, it's labelled '>_'). Normally, there would be a line like this:

    set duration "200"
    

    Replace with:

    set duration "[interval]"
    

    Either way, make sure to paste the code from my previous post into the prepare phase of an inline_script at the start of your sequence.

    Good luck!

  • edited 12:58PM

    Hi edwin,
    Again, thank you for your quick reply! I understand the sketchpad adjustments. I've tried to run the experiment, but 1 line in your inline script produces an error. It's about:

    if not hasattr(exp, 'histlist'):
    exp.histlist = []

    The error is:
    Error while executing inline script
    phase: prepare
    item: inline_script
    line: 29
    exception message: name 'histlist' is not defined
    exception type: NameError

    I've tried to fix it myself but it isn't working. Do you know how I could define histlist, so this error doesn't pop up?
    Many thanks for all your help!!

    Suzanne

  • edited 12:58PM

    Hi Suzanne,

    Apologies, my mistake. The error was in line 29 actually, where I wrote hitlist rather than exp.hitlist. I've edited my previous post, which should now work (just tested it: it does on my system).

    Good luck!

Sign In or Register to comment.