在 PsychoPy 中每 ... ms 或帧更新一次刺激属性
Update stimulus attribute every ... ms or frame in PsychoPy
我试图在 psychopy 编码器中每 100 毫秒左右更新一次 gratingStim 的方向。目前,我正在用这些行更新(或尝试)属性:
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()
我找不到在所需时间范围内更新的正确方法。
每隔 x 帧执行某项操作的一种巧妙方法是将 modulo operation 与包含 win.flip()
的循环结合使用。因此,如果您想每 6 帧执行一次操作(在 60 Hz 显示器上为 100 毫秒),只需在每一帧执行此操作:
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
我试图在 psychopy 编码器中每 100 毫秒左右更新一次 gratingStim 的方向。目前,我正在用这些行更新(或尝试)属性:
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()
我找不到在所需时间范围内更新的正确方法。
每隔 x 帧执行某项操作的一种巧妙方法是将 modulo operation 与包含 win.flip()
的循环结合使用。因此,如果您想每 6 帧执行一次操作(在 60 Hz 显示器上为 100 毫秒),只需在每一帧执行此操作:
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