Howdy, Stranger!

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

Supported by

[solved] double space bar

edited October 2013 in OpenSesame

hi

in some stage of my experiment the responses can be either 1/2 space bar press
I want that the sketchpad will stay on screen to a defined time out

  1. how do I collect multiple space-bar responses
  2. how do I see the responses in the logger

the only discussion I found was:
http://forum.cogsci.nl/index.php?p=/discussion/157/open-collecting-free-responses-and-response-time
but it is'nt really what I need

thenx

Dror

Comments

  • edited March 2013

    Hi Dror,

    Sure, that's certainly possible. You'll need a little bit of Python inline scripting for this.

    More specifically, you could continuously pull keyboard responses (with the timeout of the keyboard_response item set to zero) until a certain time has passed (or, for example, until the participant pressed twice). After this interval, your experiment should advance to the next item (e.g. a feedback item or a logger item). During the response interval, you simply count how often the spacebar was pressed and then set this new variable with the experiment function exp.set() so that it will be available in the logger item.

    The following Python code should give you an idea of how to achieve this. Make sure you put it in the Run phase tab of an inline_script item that is appended to your trial sequence in the same way you would normally append your keyboard_response item (which you don't need anymore). So, for example, after stimulus presentation but before a feedback or logger item.

    # Determine the timeout in ms:
    timeout = 3000
    
    # Create keyboard_response item:
    from openexp.keyboard import keyboard
    my_keyboard = keyboard(exp, keylist=['space'], timeout = 0)
    
    # Determine the timestamp of the start of the response
    # interval:
    start_time = self.time()
    
    # Give the number of spacebar presses a starting
    # value, namely 0.
    nPresses = 0
    
    # Collect keyboard response until 3000 ms (or whatever
    # you set the timeout to) passed:
    
    while True:
    
        # Get new timestamp:
        current_time = self.time()
    
        # Continue only if the duration is still
        # smaller than timeout:
        if current_time - start_time < timeout:
    
            # Collect keyboard response:
            key, end_time = my_keyboard.get_key()
    
            # Add to the number of presses if response was not 
            # 'None' (meaning no key was pressed):
            if key != None:
                nPresses +=1
    
            # You could advance to the next part of your 
            # experiment as soon as space has been pressed twice.
            # If you want to keep pulling keyboard responses until
            # the timeout, even if participants already pressed
            # twice, simply remove the two following lines.
            if nPresses >= 2:
                break
    
        # If (more than) 3000 ms have passed, advance to the 
        # next part of your experiment:
        else:
            break
    
    # Set the number of spacebar presses for future use in the 
    # user interface (notably, the logger item). After doing so,
    # you will find :
    self.experiment.set('nPresses', nPresses)
    

    For more information about keyboard functions via Python inline code, see:

    An example experiment can be downloaded here (save with the extension '.opensesame').

    Does this help?

    Best,

    Lotje

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

  • edited 11:46PM

    hi Lotje
    the inline code works like a charm - that's exactly what I needed!

    one further question - I have in every trail 2 responses, one after a sketchpad and another one after a second scratchpad, do I need to use 2 different loggers/one in the end of each trail or 2 loggers that are the same loogers?

    thank's for the quick and very helpful replay
    Dror

  • edited March 2013

    Hi Dror,

    You're welcome! I'm glad to hear it's working as desired! :)

    Luckily, if you have multiple response items (for example, two keyboard_response items) you don't have to worry about logging their respective output variables separately yourself. OpenSesame takes care of this by storing them in separate variables (i.e. separate column headers in your output file) automatically. So, simply appending one logger item at the very end of your trial sequence is enough.

    More specifically, the given response, as well as it's correctness and response time, collected by a keyboard_response item named 'keyboard_response1' are stored by the following variables, respectively:

    • response_keyboard_response1 (contains the given key press, e.g. a)
    • correct_keyboard_response1 (contains the correctness (0 or 1) of the response)
    • response_time_keyboard_response1 (contains the response time in ms., e.g. 577)

    Therefore, you will always be able to dissociate those output variables from the ones collected by a keyboard_response item named 'keyboard_response2' (for which the variables are obviously named 'response_keyboard_response2', etc.).

    The usually-used variables 'response', 'correct', and 'response_time' always represent the most-recently collected variables. Therefore, in the current example, in the output file those will always be identical to the variables collected by 'keyboard_response2'.

    Does this make sense?

    I uploaded a simple example experiment here (download, change the extension from .txt into .opensesame, and open as normally):

    Don't hesitate to post any further questions!

    Best,

    Lotje

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

  • Hello,

    I'm very sorry if I step in between, but I really need help and my question is not so far correlated with the topics you discussed.

    I'm trying to implement an Intentional Binding paradigm in which a clock rotates and the participant's task is to judge when a critical event (tone/keypress) occurs.
    Everything works when the participant is only one, but I need to turn it in a "social" version in which two participants press two different space bars: in one condition they press whenever they want, in the other one it is established (before starting the experiment) who will press the spacebar first ("the initiator") and who will do it for second (the "responder").

    May I know how to get inputs from different keyboards and then to find them into the logger?
    Any help would be really appreciated!!

    Thanks in advance,
    Cecilia

  • Hi Cecilia,

    You can connect multiple keyboards to one computer, so that's no problem. Then, to be able to tell who pressed which key, I would have them press different keys (on different keyboards), rather than both press the spacebar. For example, the initiator could press the left arrow key, and the responder could press the right arrow key.

    Cheers!
    Sebastiaan

  • Hi Sebastiaan,

    thank you for the reply and apologies for my mess.
    I was able to set multiple keys (specifically, "spacebar" and letter "A") but now I'm in a new trouble.
    I created three different sketchpads, and I'd want to display:

    • the first one only when the spacebar key is pressed first
    • the second one only when the A key is pressed first
    • the third one if spacebar and A are pressed together.

    Is there a way? Can you help me?

    Best,
    Cecilia

  • Hi Cecilia,

    Here's what you could do:

    • Have two keyboard_response items in a row, let's call them kb1 and kb2.
    • Then you can use run-if statements to determine which key was pressed first, e.g. [response_kb1] = a and [response_kb2] = space
    • Keys cannot be pressed simultaneously, but if they are almost pressed simultaneously then the response time on kb2 will be very low, so you can check this again with a run-if statement: [response_time_kb2] < 100

    Cheers!
    Sebastiaan

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