1

観測者が左右のキーでポリゴンの輝度(またはコントラスト)を変更するように、サイコピーの調整方法で簡単な実験を実行しようとしています。どの機能をどのように使用すればよいかわかりません。

編集:ビルダーを使用しています。

4

1 に答える 1

0

コードを使用している場合は、次のようにします。

# Set things up
from psychopy import visual, event
win = visual.Window()
polygon = visual.Polygon(win, fillColor='black')

# Keep doing this until escape key is pressed
while True:
    # React to responses by updating contrast
    key = event.waitKeys(keyList=['left', 'right', 'escape'])[0]
    if key == 'left' and not polygon.contrast < 0.1:  # if left key is pressed, change contrast if wouldn't exceed the possible values
        polygon.contrast -= 0.1
    elif key == 'right' and not polygon.contrast > 0.9:  # same here...
        polygon.contrast += 0.1
    elif key == 'escape':
        break  # stop the while loop

    # Display stimulus with updated attributes.
    polygon.draw()
    win.flip()

Builder を使用している場合は、他の刺激の下にコード コンポーネントを挿入し、わずかに変更したこのコードを「すべてのフレーム」タブに貼り付けます。

# React to responses by updating contrast
key = event.getKeys(keyList=['left', 'right'])
if key and key[0] == 'left' and not polygon.contrast < 0.1:  # if left key is pressed, change contrast if wouldn't exceed the possible values
    polygon.contrast -= 0.1
elif key and key[0] == 'right' and not polygon.contrast > 0.9:  # same here...
    polygon.contrast += 0.1

未テスト - 動作するかどうかを確認してください。

輝度を変更するには、輝度が独立変数である DKL 色空間を使用することをお勧めします。色空間に関するサイコピーのドキュメントを参照してください。これは次のように行うことができます。

polygon = visual.Polygon(win, colorSpace='dkl', fillColor=[45, 180, 1], lineColor=None)
polygon.fillColor += [5, 0, 0]  # increase luminance with constant hue and saturation
polygon.fillColor -= [5, 0, 0]  # decrease luminance....
于 2015-05-12T19:43:17.137 に答える