PsychoPy 使用随机点运动图 (RDK) 模拟扩展焦点

PsychoPy simulate Focus Of Expansion using Random Dot Kinematogram (RDK)

我需要使用 PsychoPy 的 RDK 功能模拟扩展焦点。

到目前为止我有以下代码。然而,这只是创建了一个朝某个方向移动的RDK。

from psychopy import visual, event, core

win = visual.Window([1000,1000], rgb=(255,255,255), fullscr=False)
fixSpot = visual.GratingStim(win,tex=None, mask="gauss", size=(0.05,0.05),color='black')


rdk = visual.DotStim(win, units='', nDots=1000, coherence=1.0, 
                    fieldPos=(0,0), 
                    fieldSize=(1,1), 
                    fieldShape='sqr', dotSize=6.0, 
                    dotLife=150, dir=0, speed=0.01, 
                    rgb=None, color=(0,0,0), 
                    colorSpace='rgb255', opacity=1.0, 
                    contrast=1.0, depth=0, element=None, 
                    signalDots='different', 
                    noiseDots='direction', name='', 
                    autoLog=True)

stop = False

while stop == False:    

    fixSpot.draw()
    rdk.draw()

    win.flip()

    if event.getKeys("a"):
        win.close()
        stop = True

我需要创建一个 RDK,其中的点从 window 中的特定位置移开。

我尝试更改参数,但无法模仿所需的功能。 我还查看并搜索了 psychopy 文档,但是没有提到 'focus of expansion'.

有什么方法可以使用 PsychoPy 做到这一点吗?如果没有,最好的选择是什么?

有趣的问题。一种方法是:

from psychopy import visual
win = visual.Window()
stim = visual.DotStim(win, nDots=50, dotLife=60, speed=0)  # a non-moving DotStim

for frame in range(100):
    stim._dotsXY *= 1.02  # accelerating X-Y expansion
    #stim.dotsXY *= stim.dotsXY * [1.02, 1.05]  # faster acceleration in y-direction
    stim.draw()
    win.flip()

这 "behind the scenes" 并操纵名为 visual.DotStim._dotsXY 的内部属性。它只是一个 2 x nDots 像这样的 numpy 数组:

print stim._dotsXY  # look at coordinates
[[ 0.02306344 -0.33223609]
 [ 0.30596334 -0.0300994 ]
 [-0.10165172 -0.08354835]
 [ 0.21854653 -0.07456332]
 [-0.39262477 -0.21594382]
...etc

...你可以在上面进行各种操作。我不太明白如何以一种巧妙的方式进行恒速扩展。

PsychoPy Coder 视图中有一个名为 starField 的演示。它具有来自单个点的随机速度(传统的 "simulations" of space 旅行使用它来表示星星处于不同的距离)。您应该能够弄清楚如何使所有点的速度相同。

该演示使用 ElementArrayStim 而不是 DotStim,因为 DotStim 有自己的方法来控制点运动,我认为您不需要那样。