在PsychoPy中每隔...... ms或帧更新刺激属性

时间:2016-01-01 18:55:29

标签: psychopy

我试图在心理编码器中每100毫秒左右更新一次meshStim的方向。目前,我正在使用以下行更新属性(或尝试):

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

我无法找到在所需时间范围内更新的正确方法。

1 个答案:

答案 0 :(得分:3)

每隔x帧执行一些操作的简洁方法是将modulo operation与包含win.flip()的循环结合使用。因此,如果您想每6帧(60 Hz监视器上100 ms)执行某些操作,请在每个帧中执行此操作:

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