Howdy, Stranger!

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

Supported by

[solved] How do I collect the keyboard_response after a stimulus disappears?

edited January 2014 in OpenSesame

Hi, Sebastiaan. I'm jongsup, your Korean colleague who is teaching Psycholinguistics using OpenSesame at a Korean university. Hope you remember the e-mail correspondence we had last winter.

Here's my question. I want to present a target stimulus for 500ms. That is, the target stimulus should disappear in 500ms. But I want to set the timeout for keyboard_response to 2000ms. That is, the response should be recorded for 2000ms (even after the target stimulus goes away).

How can I achieve this? Can you suggest me any useful inline script for this? It seems that I need something more than the 'self.sleep()' script.

Thanks in advance for your help and efforts.

From JS

Comments

  • edited August 2013

    Hi Jongsup,

    Yes, of course I remember! Great to heard that you're actually using it now.

    Below is a quite elaborate inline script that should do what you need. Basically, it collects a response first with a timeout of 500ms. If no response is collected during that time, the display is blanked and a response is collected again for 1500ms, giving a total timeout of 2000ms. It also maintains feedback variables, etc., which is actually most of the script. Importantly, the script assumes that it is preceded my a sketchpad called my_sketchpad with a 0ms duration. So you can just present the target stimulus on a regular sketchpad.

    Hope this helps!

    Cheers,
    Sebastiaan

    # This code snippet assumes that it is
    # preceded my a sketchpad called 'my_sketchpad'
    # with a 0 duration.
    #
    # The code below collects a response for a
    # maximum of 2000ms. After 500ms the canvas
    # is blanked.
    
    from openexp.canvas import canvas
    from openexp.keyboard import keyboard
    
    # Uncomment for 0.25 or earlier
    # exp = self.experiment
    
    # Some settings
    timeout1 = 500
    timeout2 = 2000
    allowed_keys = ['z', 'm']
    
    # Create keyboard and canvas objects
    my_keyboard = keyboard(exp, keylist=allowed_keys)
    my_blank_canvas = canvas(exp)
    
    # Set actual timeout. By taking into account
    # the current time and the timestamp of
    # my_sketchpad we reduce temporal jitter
    timeout = timeout1  - self.time() + exp.get('time_my_sketchpad')
    
    # Collect a keyboard response with a stim_dur timeout
    # and show a blank canvas afterwards
    resp, time = my_keyboard.get_key(timeout=timeout)
    my_blank_canvas.show()
    
    # If no response has been given, we wait for another
    # post_stim_dur milliseconds
    if resp == None:
        timeout = timeout2 - self.time() + exp.get('time_my_sketchpad')
        resp, time = my_keyboard.get_key(timeout=timeout)
    
    # Set response, correct, and response time
    response_time = time - self.get('time_my_sketchpad')
    response = my_keyboard.to_chr(resp)
    if not self.has('correct_response'):
        correct = 'undefined'
    elif response == self.get('correct_response'):
        correct = 1
    else:
        correct = 0
    exp.set('response_time', response_time)
    exp.set('response', response)
    exp.set('correct', correct)
    
    # Maintain feedback variables. This ensures that
    # you can use the feedback item as usual
    exp.total_responses += 1
    if correct:
        exp.total_correct += 1
    exp.total_response_time += response_time
    exp.acc = 100. * exp.total_correct / exp.total_responses
    exp.avg_rt = exp.total_response_time / exp.total_responses
    exp.accuracy = exp.acc
    exp.average_response_time = exp.avg_rt
    
  • edited May 2012

    Goodness! How can I express my deepest gratitude to you, Sebastiaan? I will definitely test this inline script with my students, and may ask you further questions. At the moment, I want to let you know that I have taught more than 80 students how to use OpenSesame this semester here in Korea. We all admire your help and achievement!

    JS

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