Howdy, Stranger!

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

Supported by

[solved] Variable Interstimulus Interval (ISI)

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

  • edited March 2017

    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

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

  • edited 3:48PM

    Thanks a lot Lotje it works perfectly :)

  • 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

  • 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

    Buy Me A Coffee

  • 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

  • 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

    Buy Me A Coffee

  • 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

  • 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

  • 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

    Buy Me A Coffee

  • zsczsc
    edited March 2017

    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

  • 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

  • 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

    Buy Me A Coffee

  • Dear Edward

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

    Kind regards

  • Hello,

    I implemented the first solution in the discussion given by @lvanderlinden which seems to have worked for someone else.

    It works fine the first time, but after that it is causing the experiment to freeze (Python stops responding).

    Is there another method to create randomly varying intertrial intervals?

    Best,

  • Hi @mrhmatar ,


    There is the advanced_delay plugin which delays the experiment for a pre-specified average duration plus a random margin. You can set the random margin (i.e., the jitter) to be chosen from a Gaussian or a uniform distribution.


    Something like the code suggested earlier in this thread should also work. Feel free to upload the most recent version of your experiment if it still freezes.


    Cheers,


    Lotje

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

  • Hello,

    Thank you, this works perfectly!

    Regards,

  • edited March 2021

    Hi @mrhmatar , great to hear and thanks for reporting back! Did using the advanced_delay item do the trick?

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

  • edited March 2022

    Hello,

    I'm posting on this thread because I noticed someone earlier had the same error as me (but they resolved it before a solution was posted here).

    I want a stimulus duration to vary randomly across trials. I placed an inline script inside the trial sequence, just prior to the sketchpad that I want to vary.

    The script is:

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

    Then in the duration box in my sketchpad I have [stim_duration]

    When I run the experiment, it stops the experiment and tells me the error: "The variable 'stim_duration' does not exist." I've looked in the variable inspector, and i can see my variable there.

    Any advice on this would be great!

  • oops I just realised I had the scrip in 'run' instead of 'prepare' tab. Works now :)

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games