簡體   English   中英

基於鼠標位置的心理事件

[英]psychopy event based on mouse position

我正在設置一個Fitts法則實驗,我希望參與者單擊“開始”按鈕,直線移動鼠標,然后單擊目標。 單擊開始后,如果參與者在垂直方向上將鼠標移得太遠或太遠,我希望顯示白屏30秒並且不接受任何輸入,然后移至下一個試用版。

目前,無論如何,實驗的行為似乎是我超出了可接受范圍,並且始終執行if語句。

這是我現在擁有的代碼:

from psychopy import core

start = mouse.isPressedIn(polygon, buttons=[0])


if start==True:
    thisExp.addData('starttime',core.getTime())
    x, y = mouse.getPos()
    mouse.x.append(x)
    mouse.y.append(y) 
    if y>10 or y<-10:         #this is the statement that isn't resulting in what I would expect
thisExp.addData('penalty',1)

finish = mouse.isPressedIn(polygon2, buttons=[0])

if finish==True:
    thisExp.addData('stoptime',core.getTime())
    continueRoutine=False

我還沒有弄清楚嵌套if語句下需要的所有內容。 現在,我只是試圖確保其正常工作。 即使查看csv文件中收集的mouse.y列表數據,它也永遠不會將if語句評估為true,也永遠不會增加代價,我可以看到有些實例中y超出了我設置的范圍。

似乎是在試驗開始后立即收集鼠標位置數據,而不僅僅是在單擊多邊形之后。 但是,開始時間和停止時間似乎確實是基於單擊多邊形和polygon2的時間。 我真的不確定發生了什么。

更新:由於某種原因,直到一天后我才收到有關喬納斯的回應的通知。 我希望我能擁有它,因為它會使我在幾個小時之前走上正確的道路。 這是一個構建器代碼組件。

我的代碼每一幀都在運行。 在例程的開頭,我添加了:

checkstart = False

通過以下代碼,每個幀都可以解決此特定問題:

start = mouse.isPressedIn(polygon, buttons=[0])

if start==True:
    thisExp.addData('starttime',core.getTime())
    x, y = mouse.getPos()
    mouse.x.append(x)
    mouse.y.append(y)
    checkstart=True;

if checkstart==True:
    if y>10 or y <-10:
        thisExp.addData('penalty',1)


finish = mouse.isPressedIn(polygon2, buttons=[0])

if finish==True:
    thisExp.addData('stoptime',core.getTime())
    continueRoutine=False

我仍然不知道為什么在單擊多邊形之前要收集鼠標位置,但這對我來說實際上並不重要。 我可以將單擊鼠標的幀的數據匹配到與開始按鈕相對應的位置,以獲取鼠標路徑跟蹤的開始。

我的代碼每一幀都在運行。 在例程的開頭,我添加了:

checkstart = False

通過以下代碼,每個幀都可以解決此特定問題:

start = mouse.isPressedIn(polygon, buttons=[0])

if start==True:
    thisExp.addData('starttime',core.getTime())
    x, y = mouse.getPos()
    mouse.x.append(x)
    mouse.y.append(y)
    checkstart=True;

if checkstart==True:
    if y>10 or y <-10:
        thisExp.addData('penalty',1)


finish = mouse.isPressedIn(polygon2, buttons=[0])

if finish==True:
    thisExp.addData('stoptime',core.getTime())
    continueRoutine=False

我仍然不知道為什么在單擊多邊形之前要收集鼠標位置,但這對我來說實際上並不重要。 我可以將單擊鼠標的幀的數據匹配到與開始按鈕相對應的位置,以獲取鼠標路徑跟蹤的開始。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM