[英]how can i get reaction time in python?
我無法獲得正確的反應時間。
以下是我為實現這一目標所做的嘗試:
kb = keyboard.Keyboard()
RT = core.Clock()
def run(data):
trial=0
for j in range(1,5):
for i in data:
kb.clock.reset()
excelTrialEq = trial
print (i)
myword.text=i[0]
myword.draw()
mywin.flip() #draw letter
RT.reset()
RT.add((0.25) + i[1]
core.wait(0.25)
mywin.flip() #draw blank(ISI)
while RT.getTime() < 0 : pass # wait till end stimulus showing + ISI
我希望輸出像
['M', 1]
1 2 M 1
space, 0.50980908090
...
但實際輸出是
['M', 1]
1 2 M 1
['K', 1]
space -0.25774913992427173
...
從代碼中並不清楚要做什么。 但是,如果我理解正確,您會在屏幕上顯示一些內容,然后等待用戶按下空格鍵。 最簡單的操作是:
import time
#When the item appears on the screen
startTime = time.time()
#When the user presses space
endTime = time.time()
reactionTime = endTime - startTime
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.