Howdy, Stranger!

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

Supported by

Unwanted jitter in keyboard response

Hi everyone, I'm having an issue with timing of my response collection, your help would be much appreciated!


I've implemented a task using an inline script where keyboard responses are collected. Participants make multiple key presses, which should be collected until a maximum reaction time is reached. However, I can't seem to find a way to implement this without getting jittered max rt's. Below is a simplified version of what I'm trying to do:


my_canvas.show() 

max_rt = 3000 # maximum reaction time

my_keyboard = keyboard(keylist=["1", "2"])

t0 = clock.time() # start tracking duration of trial

resp=[] # for storing keyboard responses each trial
while clock.time() - t0 < max_rt: 	# collect responses until time's up
	# get keyboard responses
	key = my_keyboard.get_key(timeout=max_rt)
	resp.append(key)

print("rt given: " + str(clock.time() - t0))


This is implemented in a loop sequence, in which it is preceded by a fixation dot.


Using this code, when there is no key press, the correct max rt is given. However, after some key presses, the while loop continues well past the max rt (I've seen it go over 5600 when set to 3000). It happens even when displaying a blank canvas, and changing backends doesn't make a difference.


I've tried implementing it in other ways to no avail, for example changing the conditions of the while loop:

while True: 	
	if clock.time() - t0 >= max_rt:
              break


Does anyone know why this is happening, and is there another way to implement this in an inline script (it's important in my case to do so)?

Comments

  • Hi @phidget ,

    Can you try to see if parentheses around your arithmetic have an effect? So change

    while clock.time() - t0 < max_rt: 
    

    to

    while (clock.time() - t0) < max_rt: 
    

    my hunch is that this is a precedence issue, as the < and > operators might have precedence over the - , which makes you effectively first evaluate `t0 < max_rt`

    Buy Me A Coffee

  • Hi @Daniel,


    Thanks for your response. Unfortunately adding parentheses does not solve the issue.

  • Hi, I think the reason is that your while loop has a timeout of 3000 ms, but your response collection as well. Therefore, it could happen that the response collection finishes running, but the while loop has not yet finished, and the next response collection is initiated, so that you would have to wait for another 3000 ms. In total, a delay until up to 6000 would be possible. Why you get numbers like 5600 ms, I don't quite understand though.

    In any case, if you set the timeout of the response collection to 0 ms, you would get the behaviour that you want to have I think. Can you try that?

    Eduard

    Buy Me A Coffee

  • Thanks eduard, you were right, the reason for the extra time given was due to having a timeout in the while loop condition as well as in the argument to the get_key function.

    Changing the keyboard timeout to 0 makes the loop never end until a key is pressed regardless of the while loop condition. But I was able to fix the issue by changing the timeout of the response collection to the following:

    key = my_keyboard.get_key(timeout=max_rt-(clock.time()-t0)) 
    


    Thanks for your help!

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