Howdy, Stranger!

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

Supported by

How to accurately calculate reaction time in Python?

Hello, guys!

I hope you're doing amazing.

Today I have a problem with the reaction time calculation. I have read in several comments that it is enough just doing a subtraction between "t2" which is often the kb.get_key() and "t1" which is often "". Meaning the time when the key is registered minus the time when the 1st stimulus appears. However, doing this calculation over and over again, I obtain just the duration of my two canvases regardless of the real reaction time.

As you can see in this screenshot, I have: (a) one canvas lasting 695ms, (b) a second canvas (which is just a white mask) lasting 239, and (c) my kb_response with a timeout = 100. With this, participants should have 1,034ms available to respond. The thing is that when I do the subtraction t2 - t1, I always obtain around 934ms meaning the duration of my two canvases. Normally I should obtain between 400ms and 600ms.

I have already tried to give 339ms to my second canvas and 0ms to my kb_response timeout, but it is always the same.

In the 1st screenshot, you can see the code and in the second one, you can see the subtraction.

Another thing is that pressing the key should not make the next stimulus appear. It means that all the canvases should last what I want regardless of the participant's reaction time. But, I have the impression that pressing the key shortens the displaying time of my canvases.


  • Hi @Gio38000,

    I don't program in Python but looking at your code, there are things I'm unsure of. If you want to measure response times from the onset of Canvas 1, it is odd to define the keyboard event after canvases 1 and 2 and to give a time out of just 100ms (that means your subject has just 100 ms to respond from when the keyboard object is activated). I don't really understand the logic of the code you're presenting or the structure of your trial. Could you possibly upload your task or a short version of it?

    You might want to go back to the basics explained on this page: See if you can measure a simple RT to a single canvas, then work your way up to build your trial with the additional elements.

    Hope this helps.


    Buy Me A Coffee

  • Hi Gio,

    Yes, Fabrice is right. You're logic doesn't check out.

    I have read in several comments that it is enough just doing a subtraction between "t2" which is often the kb.get_key() and "t1" which is often ""

    Yes, that is the correct approach to measure the time between two events. Of course there are some things to consider to guarantee RTs to be as accurate as possible, but they are not relevant here.

    They main issue with your code is its linearity. If you have a clock.sleep statement, your experiment will halt and nothing else can happen, i.e. also no response. Same goes for your 100 ms timeout in the keyboard response. In addition, only during those 100 ms a response can be processed. So, in your example, the quickest RT possible is, big surprise, 934 ms!

    To achieve what you described you have to poll responses all the while your canvas presentation lasts. So, canvas and keyboard have to act in parallel. With linear code that is not possible. With a while loop it is pretty easy though. See the example script attached. I think this should get you started. If not, let me know.

    Good luck,


    Buy Me A Coffee

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 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