go-NoGo タスクの場合、psychopy の data.TrialHandler クラスを使用して写真を整理したいと思います。
trials = data.TrialHandler(ImageList, nReps=1, method='random')
ここで、サイコピーが辞書に入り、最初の一連の画像 (例: A_n) を提示し、その後、6 番目のセットまで 2 番目のセットに移動するループをコーディングしたいと考えています。私は次のことを試しました:
import glob, os, random, sys, time
import numpy.random as rnd
from psychopy import visual, core, event, monitors, gui, logging, data
im_a = glob.glob('./a*') # upload pictures of the a-type, gives out a List of .jpg-files
im_n = glob.glob('./n*') # n-type
im_e = glob.glob('./e*') # e-type
# combining Lists of Pictures
A_n = im_a + im_n
N_a = im_n + im_a
A_e = im_a + im_e
E_a = im_e + im_a
E_n = im_e + im_n
N_e = im_n + im_e
# making a Dictionary of Pictures and Conditions
PicList = [A_n, N_a, A_e, E_a, E_n, N_e] # just the six Combinations
CondList = [im_a,im_n,im_a,im_e,im_e,im_n] # images that are in the GO-Condition
ImageList = []
for imagelist, condition in zip(PicList, CondList):
ImageList.append({'imagelist':imagelist,'condition':condition}) # to associate the picturelist with the GO Conditionlist
ヘッダーについて、追加の質問をします: Combining and associating multiple dictionaries
# Set Experiment
win = visual.Window(color='white',units='pix', fullscr=False)
fixCross=visual.TextStim(win,text='+',color='black',pos=(0.0,0.0), height=40)
corrFb = visual.TextStim(win,text='O',height=40,color='green',pos=[0,0])
incorrFb = visual.TextStim(win,text='X',height=40, color='red',pos=[0,0])
# Start Experiement
trials = data.TrialHandler(ImageList, nReps=1, method='random')
rt_clock = core.Clock()
bitmap = visual.ImageStim(win)
for liste in ImageList[0:5]: # to loop through all 6 conditions
keys = []
for i,Pictures in enumerate(liste): # to loop through all pictures in each condition
bitmap.setImage(Pictures) # attribute error occurs, not if I use Pictures[0][0], even though in this case every pictures is the same
bitmap.draw()
win.flip()
rt_clock.reset()
resp = False
while rt_clock.getTime() < 2.0: # timelimit is defined 2 s
if not resp:
resp = event.getKeys(keyList=['space'])
rt = rt_clock.getTime()
if bool(resp) is (Pictures in CondList): # at this point python should have access to the Dictionary in which the associated GO Pictures are saved
corrFb.draw()
accu=1 # doesn't work yet
else:
incorrFb.draw()
accu=0
win.flip()
core.wait(0.5)
trials.addData('rt_'+str(i), rt) # is working well when loop: if trial in trials: ...; in this case trialHAndler is not used, therefor trials.addData is not working
trials.addData('accu_'+str(i), accu)
trials.saveAsExcel(datanames)
core.quit()
このコードにはいくつかの問題があります: まず、1 つの画像を 6 回だけ表示しますが、6 つの異なる画像は表示しません [1]。
第二に、まったく別の問題 [2] は、時間の測定と、試行ごとに試行担当者が行っている精度の保存です。したがって、各試行のすべての RT が合計されます。各画像のRTを取得したい。私は、刺激のための追加のstimuls.trialhandlerや、最後に最後のRTを提供するextraloopのようないくつかのことを試しましたが、それぞれではありません. --> 以下に回答します!!!
for stimuli in stimulus: stimulus.addData('rt', rt)
これらの 4 つの質問は 1 つの質問に対して多くのことを知っていますが、誰かがこれらを解決する方法について良いアイデアを教えてくれるかもしれません... みんなありがとう!