Howdy, Stranger!

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

Supported by

Multiple responses and tone during coroutine

Hi,

I have been trying to implement an experiment in which subjects can give two keyboard responses while they see a fixation cross, followed by some text and a tone that is played during the text display. Only if there is a "first" response, the experiment should check for a "second" response in the trial.

Sounds easy enough, but somehow I am not able to get it to work.

Since subjects should be able to respond during the whole trial (i.e., even during fixation and befor the tone has been played), I used the coroutine plugin with two "keyboard response" items. I also tried doing this with just one keyboard response item that is reset after a response, which I could not get to work; and also tried using just an in-line script with "while" loops but was not able to present anything while OpenSesame was waiting for responses. I also tried setting the "runif" or "starttime" properties of the second keyboard response only after the first response, which unfortunately did not work.

The problems with the coroutine solution are as follows:

  • When I just set up the coroutine to end after the second response, the first response sometimes is not recognized, so I need three key presses to proceed.
  • In other cases the trials advance immediately after the first response. In these instances, the first response is logged as "None"

I then added an in-line script with a generator function that should get the coroutine to start checking for a second response only after a first response is given.

  • With this, the responses seem to be logged okay and trials only advance after two responses, but at some undefined point, python crashes. From then on, trials are of course displayed way too long and responses are not registered correctly or at all. I suspect this is due to my limited python knowledge, but as of now I could not isolate the issue.

I have attached an experiment with boiled down versions of the two variants that I tried out. 10 trials without a generator function for the coroutine and 10 trials with a generator function for the coroutine. I also attached a small logfile of a run in which I just alternated between pressing 1 and 2.

Any input would be greatly appreciated.

Best,

Marcus


Comments

  • edited January 24

    Hi Marcus,

    That's an interesting scenario. As I understand it, the main issue is to collect two key presses, and to abort the coroutines when this is done.

    Collecting two key presses is relatively easy: you can have two keyboard_response items (let's call them kb1 and kb2) running for the duration of the coroutines, and this will end up collecting two key presses, even though it's unpredictable which key is captured by which item (but that doesn't really matter either).

    Next, you can write a simple generator function that raises an AbortCoroutines() when both response variables have been given a value, i.e. when two keys have been pressed. And then you specify this generator function in the coroutines . Does that make sense? I attached a basic demo experiment below.

    def check_responses():
        
        var.response_kb1 = ''
        var.response_kb2 = ''
        yield
        while True:
            if var.response_kb1 and var.response_kb2:
                raise AbortCoroutines()
            yield
    

    

    Cheers!

    Sebastiaan

  • Hi Sebastiaan,

    thanks for your response. I used a generator function like the one you outlined, however, I did not know about the AbortCoroutines() function yet and but in "break" commands instead.

    Collecting the two responses was easy indeed. The critical issue for me was that I needed to do stuff depending on the first response, that is, really do a sequential query of the response items. After a while I figured that the coroutine plugin is functioning the way it is supposed to but, as you said, "...it's unpredictable which key is captured by which item".

    As a workaround I specified both conditions: either var.response_kb1 captures the first key press or var.response_kb2 captures the first keypress (see below).

    Thanks again.

    Best,

    Marcus

    def check_responses():
       var.response_kb1 = None
       var.response_kb2 = None
       yield
       
       # check for first response 
       while True:
          
          # check if kb1 is first response registered
          if var.response_kb1 != None and var.response_kb2 == None:
             # do some stuff here
             # check for second response    
             while True:
                yield
                if var.response_kb2 != None:
                   # do some more stuff here       
                   raise AbortCoroutines()
    
          # check if kb2 is first registered response             
          if var.response_kb1 == None and var.response_kb2 != None:
             # do some stuff here
             # check for second response    
             while True:
                yield
                if var.response_kb1 != None:
                   # do some more stuff here       
                   raise AbortCoroutines()
          yield # not sure if this one is needed
    


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