Welcome!

Sign in with your CogSci, Facebook, Google, or Twitter account.

Or register to create a new account.

We'll use your information only for signing in to this forum.

Supported by

[solved] Variable Interstimulus Interval (ISI)

anna_sedda81anna_sedda81 Posts: 2
edited November 2012 in OpenSesame

Hello :)

First, thanks for making this software available: it solves a lot of problems!

I have a question about the Interstimulus Interval, particularly I do not understand how to set the duration of, let's say, a black screen between trials to variable. I see that I can have a fixed duration (ie 500 ms), but how do I specify that I would like a duration between 400 and 600 ms?

Thanks in advance and sorry if this question has already been posted (I was unable to find it)

Anna

Comments

  • lvanderlindenlvanderlinden Posts: 292
    edited March 9

    Hi Anna,

    You will need a little bit of Python inline coding to have a random rather than a fixed stimulus duration. This can be achieved very easily as follows:

    • Append an inline_script item to your trial sequence and place it before the sketchpad which duration you want to vary randomly.
    • Make a variable for the duration by placing the following piece of code in the Prepare phase tab of the inline_script item (see comments for more information about the Python code):
    # Determine random ITI
    # Make a list of potential durations, between 400–600 ms, with steps of 
    # 10 ms (change the step size if wanted):
    
    var.step_size = 10
    var.start_val = 400
    var.end_val = 600
    
    l = range(var.start_val, var.end_val, var.step_size)
    
    # Shuffle the list:
    import random
    var.ITI = random.choice(l)
    
    # You can now use the variable ITI, by using the square-brackets method,
    # in the sketchpad of which you want to vary the duration
    
    
    • After doing this, you can simply use the new variable 'ISI' in the Duration box in your sketchpad item by applying the square-bracket method, like so:

    [ISI]

    Finally, note the following: You cannot give self-made variables names that are already in use by OpenSesame. So, for example, we could not have called the new variable 'duration', because a variable with the same name already exists.

    I hope this helps! Please let us know if you have any further questions!

    Best wishes,

    Lotje

    Lotje van der Linden - http://www.cogsci.nl
    FACEBOOK

  • anna_sedda81anna_sedda81 Posts: 2
    edited 8:00PM

    Thanks a lot Lotje it works perfectly :)

  • zsczsc Posts: 33

    Dear all

    Thank you @lvanderlinden for the code! I adopted your code and added the interstimulus interval I need (in my case: 1100ms, 1300ms or 1500ms). There is just one problem: the ISI is randomly picked at the beginning of the experiment but then stays the same for each trial (e.g. 1100ms is randomly picked at the beginning and stays at 1100ms for the rest of the experiment). I’d like the ISI to change from trial to trial (to minimize expectation effects) , is there a way to do that? Would be great if someone could help me!

    Thank you for your help!
    Kind regards

  • eduardeduard Posts: 977

    Hi Zsc,

    This sounds like you specify the ISIs in the wrong loop. If you move a level deeper into your experiment (the trial loop) and specifiy the ISI there just the way you did it so far, it should work.

    Does this make sense?

    Eduard

    Thanked by 1zsc
  • zsczsc Posts: 33

    Dear Eduard

    Thank you for the quick answer! I moved the inline scipt into the trial loop (and before the sketchpad which duration I want to vary). Now I get this message: "The variable 'ISI' does not exist".

    The order of my experiment is as follows:
    experiment -> instructions -> block_loop -> trial_sequence -> inline_script (variable ISI) -> fixation (sketchpad which duration I want to vary) -> sketchpad with my stimuli -> response -> logger

    Sorry for asking all these questions, I guess it's an easy problem to solve but I'm still quite new to OpenSesame :)

    Thanks and kind regards

  • eduardeduard Posts: 977

    Could you upload your experiment? It sounds like you moved your script too deep, but I'd need to have a look to be sure.

    Edaurd

    Thanked by 1zsc
  • zsczsc Posts: 33

    Dear Eduard

    Thank you for your help! I think I figured it out (at least it looks good in the excel file), but I’ll still upload my experiment in the attachment because there might be a better way to solve my problem (maybe there’s a more parsimonious way to implement a variable ISI)?

    And I have two follow-up questions:

    1. I added 2 response keyboards: the stimuli (arrows) appear for 100ms and after that the participants have 1500ms to answer (sketchpad pause). Usually they will not be able to answer in the timeframe of 100ms but I still want to make sure if they are pressing the key before the 1500ms timeframe (mostly to see if they press the buttons without seriously trying to answer correctly). The problem is, that the average response time is always 800ms ((100ms + 1500ms))/2) and the answer is always incorrect (in the excel file). Is it possible to create a variable that checks whether the participant pressed a key in the 100ms timeframe and if so if he did it correctly and otherwise just record the correct answer in the 1500ms timeframe? I know it sounds a bit complicated, please do ask if I wasn’t able to explain my problem!

    2. I’m using an established paradigm from a study and in this study the first trial starts off with a 500ms fixation point. After that the variable ISI is used. Is it possible to show the 500ms fixation point once and after that only the variable ISI.

    This graphic by Alderman et al. (2015) is very helpful to understand the structure:

    Thanks again for your help!!
    Kind regards

  • zsczsc Posts: 33

    Dear all

    It looks like I wasn’t able to explain my problem properly so I’ll try again. I want to program an eriksen flanker task: The stimuli (arrows) appear for 100ms followed by a 1500ms response window. A random interstimulus interval occurs following the participant’s response (the graphic by Alderman et al. I posted above shows the structure of the task).

    I created a sketchpad including the stimuli (arrows) and an empty sketchpad which corresponds to the 1500ms response window. How can I collect the responses in this 1500ms response window (empty sketchpad) when the stimuli (arrows) are defined in the other sketchpad? Does this make more sense?

    I would be thankful if someone could help me with this problem!
    Kind regards

  • eduardeduard Posts: 977

    hI,

    I adapted your script a little, it should do now what you expect it to do. Note, I didn't solve the issue that you described (collecting 2 keyboard responses), instead it is possible to look at the responses afterwards and decide based on response times whether everything is alright (no response give / anticipatory responses can be excluded). As you already mentioned, to get the correct RTs, you need to add 100ms.

    Measuring the RT starting from the stimulus display, is certainly possible and not too difficult, but you would have to do some inline_scripting. As it is not really necessary, I didn't implement it.

    Does this help?
    Eduard

    Thanked by 1zsc
  • zsczsc Posts: 33
    edited March 23

    Dear Eduard

    Yes, that helps! Thank you very much!
    I have one more question concerning variable fixation and stimulus duration:

    Each trial in my experiment starts with a fixation point and again I want the duration to be variable (this time I want the duration to vary between 250 and 750ms). Additionally I also want a variable stimulus duration (between 750ms and 1250ms). Once again I used the code @lvanderlinden posted in this forum a while ago. The code works, both the fixation point and the stimulus are shown with variable duration. The only problem is, that the duration of the fixation point and the stimulus together should add up to a maximum of 1500ms (meaning that if the fixation point is shown for 300ms then the stimulus should not exceed 1200ms). Is there a way to set the duration of a trial (with fixation point and stimlus) to a maximum of 1500ms?

    Thanks again for your help!
    Kind regards

  • zsczsc Posts: 33

    I have come up with 2 solutions for the abovementioned problem:

    The first code looks like this:

    #variable fixation duration
    var.fix_bottom = 250
    var.fix_top = 750
    
    f = range(var.fix_bottom, var.fix_top)
    
    #shuffle list:
    import random
    var.fixation = random.choice(f)
    
    
    #variable stimulus duration
    var.stim_bottom = 750
    var.stim_top = 1250
    
    s = range(var.stim_bottom, var.stim_top) 
    
    #shuffle list:
    var.stimulus = random.choice(s)
    
    #total duration
    var.total_duration = var.fixation + var.stimulus
    
    #if total duration > 1500
    if var.total_duration > 1500:
        ratio = 1500 / var.total_duration
        var.fixation = var.fixation * ratio
        var.stimulus = var.stimulus * ratio

    I was hoping that this code would automatically lower the duration of the fixation point and the stimulus if they exceed 1500ms. It works for some trials but on other trials the duration is 0ms. Did I miss something or is the code wrong (or do I have to specify something in the plugin tools)?

    The second code looks like this:

    #variable fixation duration
    var.fix_bottom = 250
    var.fix_top = 750
    
    f = range(var.fix_bottom, var.fix_top)
    
    #shuffle list:
    import random
    var.fixation = random.choice(f)
    
    
    #variable stimulus duration
    var.stim_bottom = 750
    var.stim_top = 1500 - var.fixation
    
    s = range(var.stim_bottom, var.stim_top) 
    
    #shuffle list:
    var.stimulus = random.choice(s)

    This code works just fine, the only downside is that the duration of the stimulus is dependent on the duration of the fixation point to some extent.

    Could someone tell me why the first code doesn't work as I expected (i.e. duration of fixation point should be between 250-750ms; duration of stimulus between 750-1250ms; and both together should never exceed 1500ms)? And which code would you recommend?

    Thanks for your help
    Kind regards

  • eduardeduard Posts: 977

    Hi,

    Choose the code that works. The script is simple enough that computation time and efficiency don't matter. And if the code does what you want, your settled.

    #variable fixation duration
    var.fix_bottom = 250
    var.fix_top = 750
    
    f = range(var.fix_bottom, var.fix_top)
    #shuffle list:
    import random
    var.fixation = random.choice(f)
    
    #variable stimulus duration
    var.stim_bottom = 750
    var.stim_top = 1250
    s = range(var.stim_bottom, var.stim_top) 
    #shuffle list:
    var.stimulus = random.choice(s)
    #total duration
    var.total_duration = var.fixation + var.stimulus
    if var.total_duration > 1500:
        ratio = 1500.0 / var.total_duration # note the added .0 --> float division!
        var.fixation = var.fixation * ratio
        var.stimulus = var.stimulus * ratio
    

    The problem with the first code is that you divide to integers. Python will make the result also being an integer even if it is actually a float (see here for example:http://stackoverflow.com/questions/2958684/python-division).

    Does it work now?

    Eduard

    Thanked by 1zsc
  • zsczsc Posts: 33

    Dear Edward

    Brilliant, it works! Thank you so much for your help!

    Kind regards

Sign In or Register to comment.