【发布时间】:2015-11-10 02:31:36
【问题描述】:
我的任务是多对象跟踪任务的变体。屏幕上有7个圆圈。它随机选择 3 个圆圈来短暂更改颜色(红色、绿色、蓝色),以指示参与者跟踪这些圆圈。颜色改变后,所有的圆圈都会变成相同的颜色,圆圈会移动一段时间。当圆圈停止移动时,将出现响应提示,参与者将在其中选择三个彩色圆圈之一(“选择红色/绿色/蓝色圆圈”)。我很难将要选择的色环插入格式化字符串。我不断收到错误消息:%: 'TextStim' 和 'list' 不支持的操作数类型
我不确定是否需要或如何转换这些列表,因此非常感谢任何帮助!
n_targets = 7 #seven locations
circles = [] #setting up the circle stimuli
for i in range(n_targets):
tmp = visual.Circle(win,radius = 27,units = 'pix',edges = 32,fillColor='white',lineColor = 'black',lineWidth = 1, pos=(posx[i],posy[i]))
circles.append(tmp)
cols = ['blue','red','green'] #3 colors the circles will change to
targets = random.sample(circles,3) #randomly select 3 of the 7 circles
TrialTarget = random.sample(targets, 1) #select 1 of the 3 circles to be the target for the trial
#code for movement would go here (skipping since it is not relevant)
#at end of trial, response prompt appears and ask user to select target and is where error occurs
ResponsePrompt = visual.TextStim(win, text = "Select the %s circle") %TrialTarget
【问题讨论】:
-
如果对类型错误有疑问,请随意添加一些调试语句,例如
print(type(TrialTarget)) -
(但在你想运行时也将它们删除 - 大量打印语句可能会在一段时间后导致崩溃)
标签: string list psychopy formatted