2016-01-01 22 views
1

我正試圖在psychopy編碼器中每隔100 ms更新一次gratingStim的方向。目前,我與這些線路更新屬性(或試圖):更新刺激屬性每... ms或在PsychoPy中的幀

orientationArray = orientation.split(',') #reading csv line as a list 
selectOri = 0 #my tool to select the searched value in the list 
gabor.ori = int(orientationArray[selectOri]) #select value as function of the "selectOri", in this case always the first one 
continueroutine = True 
while continueroutine: 
    if timer == 0.1: # This doesn't work but it shows you what is planned 
     selectOri = selectOri + 1 #update value 
     gabor.ori = int(orientationArray[selectOri]) #update value 
     win.flip() 

我無法找到所需的時間框架更新有道。

回答

3

每x幀做一件事的簡便方法是將modulo operation與包含在win.flip()中的循環結合使用。所以,如果你想要做的每6幀(100毫秒,60赫茲顯示器)的東西,只是這樣做的每一幀:

frame = 0 # the current frame number 
while continueroutine: 
    if frame % 6 == 0: # % is modulo. Here every sixth frame 
     gabor.ori = int(orientationArray[selectOri + 1]) 

    # Run this every iteration to synchronize the while-loop with the monitor's frames. 
    gabor.draw() 
    win.flip() 
    frame += 1 
+0

它的工作,非常感謝你的回答!我只是在循環之前使用了autoDraw(),而不是draw()函數,這給了我一個閃爍的刺激。 –

+0

這是閃爍,因爲你只畫了大約每六幀。其他五個框架是空白的。 –