视觉模拟量表精神病
visual analogue scale psychopy
我正在 PsychoPy (v. 1.90.1) 中开发一个元认知实验,我需要一个视觉模拟量表来衡量信心。但是,我找不到从 Psychopy VAS 的四肢中删除数值(0
和 1
)的方法。
有什么办法可以隐藏它们吗?
我需要单词标签 ("Not at all confident"
, "Extremely confident"
),但我还希望将答案记录在 0-100
量表(或等效的 0-1
) 就像模拟量表一样(所以切换到分类不会做)。
有什么建议吗?
提前致谢。
索尼娅
看看 the documentation,尤其是 labels
和 scale
。这是一个解决方案:
# Set up window and scale
from psychopy import visual
win = visual.Window()
scale = visual.RatingScale(win,
labels=['Not at all confident', 'Extremely confident'], # End points
scale=None, # Suppress default
low=1, high=100, tickHeight=0)
# Show scale
while scale.noResponse:
scale.draw()
win.flip()
# Show response
print scale.getRating(), scale.getRT()
您可能还对新的 Slider 感兴趣,它包含在当前的 PsychoPy 测试版中,并将成为下一个版本的一部分。这是一个 Python 3 代码示例如何使用它:
from psychopy.visual.window import Window
from psychopy.visual.slider import Slider
win = Window()
vas = Slider(win,
ticks=(1, 100),
labels=('Not at all confident', 'Extremely confident'),
granularity=1,
color='white')
while not vas.rating:
vas.draw()
win.flip()
print(f'Rating: {vas.rating}, RT: {vas.rt}')
在重新使用之前,您必须调用 vas.reset()
。
我可以扩展@hoechenberger 的回答以添加对
的支持
- 每次试验的随机开始(将
markerPos
设置为以刻度线为单位的随机值)
- 按键支持(只需使用按键来调整
markerPos
,完成后将其分配给 rating
)
- 自定义步长(当您理解 (2) 时,这可能很明显)
- Python2.7(无需在此处强制使用 Py3.6 :wink: )
代码如下:
from psychopy import visual
from psychopy import event
from numpy.random import random
stepSize = 2
win = visual.Window()
vas = visual.Slider(win,
ticks=(0, 1),
labels=('Not at all confident', 'Extremely confident'),
granularity=1,
color='white')
for thisTrialN in range(5):
vas.reset()
vas.markerPos = random() # randomise start
while not vas.rating:
# check keys
keys = event.getKeys()
if 'right' in keys:
vas.markerPos += stepSize
if 'left' in keys:
vas.markerPos -= stepSize
if 'return' in keys:
# confirm as a rating
vas.rating = vas.markerPos
# update the scale on screen
vas.draw()
win.flip()
print('Rating: {}, RT: {}'.format(vas.rating, vas.rt))
我正在 PsychoPy (v. 1.90.1) 中开发一个元认知实验,我需要一个视觉模拟量表来衡量信心。但是,我找不到从 Psychopy VAS 的四肢中删除数值(0
和 1
)的方法。
有什么办法可以隐藏它们吗?
我需要单词标签 ("Not at all confident"
, "Extremely confident"
),但我还希望将答案记录在 0-100
量表(或等效的 0-1
) 就像模拟量表一样(所以切换到分类不会做)。
有什么建议吗?
提前致谢。
索尼娅
看看 the documentation,尤其是 labels
和 scale
。这是一个解决方案:
# Set up window and scale
from psychopy import visual
win = visual.Window()
scale = visual.RatingScale(win,
labels=['Not at all confident', 'Extremely confident'], # End points
scale=None, # Suppress default
low=1, high=100, tickHeight=0)
# Show scale
while scale.noResponse:
scale.draw()
win.flip()
# Show response
print scale.getRating(), scale.getRT()
您可能还对新的 Slider 感兴趣,它包含在当前的 PsychoPy 测试版中,并将成为下一个版本的一部分。这是一个 Python 3 代码示例如何使用它:
from psychopy.visual.window import Window
from psychopy.visual.slider import Slider
win = Window()
vas = Slider(win,
ticks=(1, 100),
labels=('Not at all confident', 'Extremely confident'),
granularity=1,
color='white')
while not vas.rating:
vas.draw()
win.flip()
print(f'Rating: {vas.rating}, RT: {vas.rt}')
在重新使用之前,您必须调用 vas.reset()
。
我可以扩展@hoechenberger 的回答以添加对
的支持- 每次试验的随机开始(将
markerPos
设置为以刻度线为单位的随机值) - 按键支持(只需使用按键来调整
markerPos
,完成后将其分配给rating
) - 自定义步长(当您理解 (2) 时,这可能很明显)
- Python2.7(无需在此处强制使用 Py3.6 :wink: )
代码如下:
from psychopy import visual
from psychopy import event
from numpy.random import random
stepSize = 2
win = visual.Window()
vas = visual.Slider(win,
ticks=(0, 1),
labels=('Not at all confident', 'Extremely confident'),
granularity=1,
color='white')
for thisTrialN in range(5):
vas.reset()
vas.markerPos = random() # randomise start
while not vas.rating:
# check keys
keys = event.getKeys()
if 'right' in keys:
vas.markerPos += stepSize
if 'left' in keys:
vas.markerPos -= stepSize
if 'return' in keys:
# confirm as a rating
vas.rating = vas.markerPos
# update the scale on screen
vas.draw()
win.flip()
print('Rating: {}, RT: {}'.format(vas.rating, vas.rt))