1

私のタスクは、複数のオブジェクトを追跡するタスクのバリエーションです。画面上に 7 つの円があります。ランダムに 3 つの円を選択して色 (赤、緑、青) を簡単に変更し、参加者にこれらの円を追跡するように指示します。色が変わると、すべての円が同じ色に変わり、一定時間円が動きます。円の動きが止まると、参加者が 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
4

1 に答える 1

0

この行では、文字列オブジェクトと別の文字列オブジェクトではなく、TextStim オブジェクトと Circle 刺激オブジェクトからフォーマットされた文字列を作成しようとしています。

ResponsePrompt = visual.TextStim(win, text = "Select the %s circle") %TrialTarget

つまり、あなたがそれを1つとして作成しているので、明らかにvisual.TextStimであり、Circleのリストからランダムにサンプリングするので、visual.Circle刺激ResponsePromptだと思います。TrialTarget

私はあなたが実際に色ラベルをプロンプト テキストに組み込みたいと思っていると思います。したがって、両方の問題 (型の非互換性とフォーマット構文) を修正するにはcols、 say と呼ばれるの要素の 1 つを実際に取得し、次のtrialColourようなものを使用する必要があります。

ResponsePrompt = visual.TextStim(win, text = "Select the %s circle" % trialColour)

つまり、これtrialColourは実際には文字列であり、フォーマット操作は角かっこ内にあるため、テキスト文字列に直接適用されます"Select the %s circle"

これで当面の問題が解決するはずです。random.shuffle()の代わりにリストをシャッフル するために を使用して調査することもできますrandom.sample()

于 2015-11-10T04:16:14.907 に答える