Howdy, Stranger!

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

Supported by

[solved] vary a sketchpad duration according to the previous response time

edited July 2013 in OpenSesame

I want a sketchpad duration to vary according to a previous RT. Setting the duration '2000-[response_time]' does not work it seems because "-" is not recognized as an operator. How can I do this?

Comments

  • edited 12:13PM

    Hi,

    The 'duration' box in a sketchpad item only takes fixed variables. As a solution, you can calculate the desired duration in an inline_script item placed immediately before your sketchpad item. Next, you can use the square-bracket method (e.g. [my_duration]) in the duration box.

    You can calculate the desired duration by placing something like the following code in the Prepare phase tab of your inline script:

    # Set the maximum:
    max = 2000.
    
    # Determine the RT on the previous trial by 
    # using the experiment function self.get().
    
    # See: http://osdoc.cogsci.nl/python-inline-code/experiment-functions/#experiment.get
    dur = max - self.get("response_time")
    
    # Set the resulting duration so that the variable becomes
    # available in the interface (i.e. in your case a sketchpad item)
    # as well:
    
    # See: http://osdoc.cogsci.nl/python-inline-code/experiment-functions/#experiment.set
    exp.set("my_duration", dur)
    

    This code will work on all trials except the first trial of your experiment, because at that time the variable 'response_time' does not have a value yet. Therefore, you should also append a second inline_script item to the very beginning of your experiment, and give 'response_time' a starting value. You can do this by placing something like this in the Prepare phase tab:

    # Give the variable 'response_time' a starting
    # value such that it already exists for the very first 
    # trial (otherwise OpenSesame will give an error
    # saying that the variable 'response_time' does
    # not exist):
    
    exp.set("response_time", 0)
    

    Your experimental overview should look something like this:

    image

    Does that make sense?

    Best wishes,

    Lotje

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

  • edited 12:13PM

    Great! It perfectly works. Thanks a lot.

  • edited 12:13PM

    Hi,

    I just realized that with your help I collect the rt of the previous trial, but I would like to collect the rt of the current one.
    I tried several things but coulnd not find any solution for the moment. Would you have any idea, please?
    Best,

  • edited 12:13PM

    I found the beginning of a solution.
    When I use your code in the "Run Phase" and I display response_time in the debug window, my_duration displays the correct current RT.

    My last remaining problem is that, now, I cannot access to the variable "my_duration" on another sketchpad (placed after the inline of course). I tried to declare it as "global" but that does not work.

  • edited 12:13PM

    My problem was not an access problem. I forgot to give "my_duration" a starting value as you mentioned...
    Thanks again for your help!

  • edited 12:13PM

    Hi,

    I'm not sure whether you already worked it out, but here's a small tip anyway. You can 'pad' the remaining time after a response with this simple script:

    total_time = 5000 # The response time + the padding time
    padding_time = total_time - self.get('response_time')
    if padding_time > 0:
        self.sleep(padding_time)
    

    So let's say that you have sketchpad1, followed by a keyboard_response, and then you want to 'pad' the remaining 5 seconds while showing sketchpad2. You can do this with the following sequence:

    • sketchpad1 (duration = 0)
    • keyboard_response
    • sketchpad2 (duration = 0)
    • inline_script (with the code show above)

    Does that make sense? So you don't use the 'duration' parameter of the sketchpad, but simply use an inline_script item.

    Hope this helps!

    Cheers,
    Sebastiaan

  • edited 12:13PM

    thank you very much, it perfectly works as I wanted with this strategy.

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