假竞争刺激

Fake-rivalry stimulus

对于使用颜色斑点的双眼竞争实验(使用高斯掩模使用 GratingStim 创建),我需要绘制一个假的竞争刺激。也就是说,我需要一个圆形颜色斑点,例如顶部有一种颜色(颜色斑点的 25%),下方有另一种颜色(颜色斑点的 75%)。此外,我希望双色假竞争斑点像我真正的竞争刺激物一样具有高斯掩模。在假的竞争刺激中有一个模糊的颜色过渡也很好。我希望你明白我的意思。

我想到的一个解决方案是绘制两个边缘模糊的矩形,然后在它们上面放置一个高斯 alpha 蒙版。为了获得正确的颜色比例,我只需要将两个矩形移动到蒙版后面。有没有办法在整个 window 上放置一个 alpha-maks?

另一种解决方案是按照post中的建议使用 ShapeStim,解释如何绘制半圆:https://groups.google.com/forum/#!msg/psychopy-users/L9TYIrf9eJk/m0zIj0N23bMJ我将不得不处理顶点,但我认为它应该工作。唯一让我担心的是 ShapeStim 没有遮罩属性来模糊边缘。

你能想出办法吗? 非常感谢!

莉拉

系统规格: iOS 10.11.1

上的 Psychopy v1.83.01 运行

这行得通吗?然后,您可以将 blob 定位到您想要的位置,例如一只眼睛。不需要做整个window的事情。

# Set up stimuli
from psychopy import visual, event
win = visual.Window([500,500])
blob_large = visual.GratingStim(win, sf=0, mask='gauss', size=1, color='red')
blob_small = visual.GratingStim(win, sf=0, mask='gauss', size=0.5, color='green', maskParams={'sd':6})

# Draw them on top of each other
blob_large.draw()
blob_small.draw()
win.flip()

# Wait for keyboard before quitting.
event.waitKeys()

更新我的问题:以下示例代码解决了问题:

# -*- coding: utf-8 -*-
# adapted from https://groups.google.com/forum/#!msg/psychopy-users/69p-aAWiDGI/e4iT43cHDeEJ
from psychopy import visual, event

win = visual.Window([500,500])

#stimuli
perc25 = visual.GratingStim(win, sf=0, size=1, color='RED',pos=(0.0, 0.0), mask = 'raisedCos', maskParams={'fringeWidth':0.8}) 
perc75 = visual.GratingStim(win, sf=0, size=0.8, color='green',pos=(0.0, -0.15), mask = 'raisedCos', maskParams={'fringeWidth':0.6}) 

#prepare for the screenshot
Stimlist = [perc25, perc75]
delta = .5# larger is bigger, slower
dx = delta * win.size[1]/win.size[0]
dy = delta
rect = (-dx, +dy, +dx, -dy)#size of the screenshot
screenshot = visual.BufferImageStim(win, stim=Stimlist,rect = rect, mask = 'gauss', pos=(0.0, 0.0)) # mask can also be 'raisedCos' with a smaller delta, for exmple .2
screenshot.draw()

win.flip()
event.waitKeys()

第二次更新,更好的结果:

# Set up stimuli
from psychopy import visual, event
import numpy as np
from scipy.stats import gaussian_kde

win = visual.Window([500,500])
win2 = visual.Window([500,500])

#magic numpy stuff /scipy stuff, adapted from http://docs.scipy.org/doc/scipy-0.15.1/reference/generated/scipy.stats.gaussian_kde.html
mean1 = [0, 0]
 #the smaller the value, the bigger the visible blob
cov1 = [[0.03, 0], [0, 0.09]]  #in this mask, it should be 50/50

cov2 = [[0.05,0],[0,0.4]]       #in this mask, the color with this mask is the smaller one

m1, m2 = np.random.multivariate_normal(mean1, cov1, 2000).T# * np.random.multivariate_normal(mean2, cov2, 5000).T 
for i in xrange(len(m2)):
    if m2[i] >= 0:
       m2[i] = m2[i]* 0.5#np.random.multivariate_normal(mean2, cov2,1).T[0]

values = np.vstack([m1, m2])
kernel = gaussian_kde(values)

xmin = m1.min()
xmax = m1.max()
ymin = m2.min()
ymax = m2.max()

X, Y = np.mgrid[xmin:xmax:128j, ymin:ymax:128j]
positions = np.vstack([X.ravel(), Y.ravel()])
values = np.vstack([m1, m2])
kernel = gaussian_kde(values)
Z = np.reshape(kernel(positions).T, X.shape)    #this array will be the mask
Z = Z - 1
for i in xrange(128):
    for j in xrange(128):       #it will neverbe smaller than -1
        if Z[i][j] > 1: 
            Z[i][j] = 1


# Draw them on top of each other 

perc75 = visual.GratingStim(win, sf=0, size=250, color='green',pos=(0.0, 0.0), mask =Z)
perc25 = visual.GratingStim(win, sf=0, size=250, color='red',pos=(0.0, 0.0), mask = 'raisedCos', maskParams={'fringeWidth':0.8}) 

perc25.setAutoDraw(True)
perc75.setAutoDraw(True)
win.flip()
event.waitKeys()