psychopy.org | Reference | Downloads | Github

ExperimentHandler

I’m trying to program a Stroop task with coder.
I found a useful script from the forum:

from psychopy import data, gui, core
from csv import DictWriter
from random import shuffle, random
from datetime import datetime
answer_keys = {‘f’: ‘red’, ‘g’: ‘blue’, ‘h’: ‘green’}

data = {‘Expdate’: datetime.now().strftime(’%Y%m%d_%H%M’), ‘ID’: ‘’, ‘Age’: ‘’, ‘Gender’: ‘’}
dlg = gui.DlgFromDict(data, title=‘Input participant info’, fixed=‘Expdate’, order=[‘ID’, ‘Age’, ‘Gender’,‘Expdate’])

if not dlg.OK:
print(“User exited”)
core.quit()

filename = ‘part_{}{}{}_{}.csv’.format(data[‘ID’], data[‘Age’], data[‘Gender’], data[‘Expdate’])

thisExp = data.ExperimentHandler(name = ‘Your expt’, version=’’,
extraInfo = expInfo,
dataFileName = filename)

trials = data.TrialHandler(nReps = 1, method = ‘random’,
trialList = data.importConditions(r’C:\Users\New\Desktop\trails.csv’),
name = ‘trials’)

thisExp.addLoop(trials)

but when i’m trying to run it i am getting

“AttributeError: ‘dict’ object has no attribute ‘ExperimentHandler’”

anyone knows why?
thx

@Tamir_Shwartz, you have overwritten the data module with your participant data collected from the gui. To fix this error, you could change your data variable name to:

expInfo = {‘Expdate’: datetime.now().strftime(’%Y%m%d_%H%M’), ‘ID’: ‘’, ‘Age’: ‘’, ‘Gender’: ‘’}

thx but now i got:

Blockquote
ImportError: cannot import name ‘fileHandler’