実験のために、中央部分が表示されているように、ウィンドウ全体にガウス フィルターが必要です。私は PsychoPy を使用しているので、基本的には、中央 (基になる刺激がエッジで -1 に行くのが見える場所) の N x M 配列 (N と M はウィンドウのピクセル単位のサイズ) が必要です。この配列を GratingStim 内のマスクとして使用します.これまでのところ、私は ndimage.filters.gaussian_filter(filter_input, sigma = 7) を試してきました
しかし、私はこの機能に問題があります。filter_input が 1 または 0 の NxM 行列である場合、ndimage 関数はそれらを変更しません。filter_input が乱数を含む行列の場合、それらはすべて適切に変更されます。しかし、私はまだ望んでいる結果を得ることができません。PsychoPy マスクが -1 と 1 の間の値のみを許可するという事実を認識していますが、現在は以下のコードにあるように、マスクが -1 であるため何も表示されないはずです。
より具体的に言うと、なぜ ndimage.filters.gaussian_filter(filter_input, sigma = 7) はそのように動作するのでしょうか? 割り当てられた値がガウス 2 次元分布を持つように、NxM 行列のすべての点に値を割り当てるにはどうすればよいですか? 後で、1 より大きい値と -1 より小さい値を切り取ることができました。
私の質問が些細なことでしたら申し訳ありません。私は PsychoPy でいくつかのプログラミングを行ってきましたが、numpy と scipy は初めてです...
ご協力いただきありがとうございます!
コード例を次に示します。
# -*- coding: utf-8 -*-
from psychopy import visual, event
import numpy as np
from scipy import ndimage
win = visual.Window([500,500])
#draw rectangle
perc25 = visual.Rect(win, width = 0.6,height=0.4, lineColor='red',fillColor = 'red', pos=(0.0, 0.1)) #notloesu
perc25.draw()
#add circle with fuzzy edges
perc75 = visual.GratingStim(win, sf=0, size=0.5, color='green',pos=(0.0, -0.1), mask = 'raisedCos', maskParams={'fringeWidth':0.6})
perc75.draw()
#create the matrix that should result in a gaussian filter laied centrally over the entire window
#desired Result: some red in the upper part of the visible circle in the middle, the rest beeing green
filter_input = (np.ones([500,500]))*(-1.)
gaussian = ndimage.filters.gaussian_filter(filter_input, sigma = 0.2)
print(filter_input == gaussian)
#i know it's ugly, I just can't think of another way to apply the filter to the entire image and I haven't found anything in the internet
unnecesary_stim_to_get_the_mask_over_the_window = visual.GratingStim(win, sf=0, size=0.0000001, color='green',pos=(0, 0), mask = gaussian)
unnecesary_stim_to_get_the_mask_over_the_window.draw()
win.flip()
event.waitKeys()
