Я кодирую задачу Stroop для эксперимента с PsychoPy. Я пытаюсь нарисовать изображение и текстовые стимулы, но получаю сообщение об ошибке (указано ниже).
Я пытался просматривать страницы google / stackoverflow, но не понимаю сообщений об ошибках (поэтому трудно было исправить этот код).
# ------Prepare to start Routine "instructions"-------
t = 0
instructionsClock.reset() # clock
frameN = -1
continueRoutine = True
# update component parameters for each repeat
ready = event.BuilderKeyResponse()
# keep track of which components have finished
instructionsComponents = [instrText, ready]
for thisComponent in instructionsComponents:
if hasattr(thisComponent, 'status'):
thisComponent.status = NOT_STARTED
#read stimuli file
trials = open('cog2.csv', 'rb')
imageFile = 0 #imageFile = trials[trialNumber][Column]
corrAns = 1 #corrAns = trials[trialNumber][Column]
Congruent = 2 #Congruent = trials[trialNumber][Column]
stimCat = 3 #stimCat = trials[trialNumber][Column]
Superimposed = 4 #Superimposed = trials[trialNumber][Column]
Word = 5 #word = trials[trialNumber][Column]
#turn the text string into stimuli
textStimuli = []
imageStimuli = []
for trial in trials:
textStimuli.append(visual.TextStim(win, text=trials[Word])) <---- ERROR
imageStimuli.append(visual.ImageStim(win, size=[0.5, 0.5], image=trials[imageFile]))
Я пытаюсь написать стимулы для рисования из загруженного мной документа Excel (содержащего пути к изображениям jpg и слова, которые я хочу наложить на изображения).
В настоящее время я получаю сообщение об ошибке:
#### Running: C:\Users\Sophie\OneDrive\Spring '19\Research\PsychoPy\Bejj\Test_3_22_19.py #####
Traceback (most recent call last):
File "C:\Users\Sophie\OneDrive\Spring '19\Research\PsychoPy\Bejj\Test_3_22_19.py", line 203, in <module>
textStimuli.append(visual.TextStim(win, text=trials[Word]))
TypeError: '_io.BufferedReader' object is not subscriptable