Hello,
I am trying to use some info in the dialogue box at the start of the experiment as a variable later in the same task.
Here is my code for the dialogue box:
dateStr = time.strftime("%b_%d_%H%M", time.localtime())#add the current time
info = {} #a dictionary
#present dialog to collect info
info['participant'] = ''
info['threshold'] = ''
dlg = gui.DlgFromDict(info, title = 'Vis100 TDCS Version') #(and from psychopy import gui at top of script)
if not dlg.OK:
core.quit()
def makePath(path):
try:
os.makedirs(path)
except OSError as exception:
if exception.errno != errno.EEXIST:
raise
outputParentDir = os.environ['psychopyOutputParent']
participant = info['participant']
participantFolder = outputParentDir + '/' + str(participant)
task = 'Vis100 Staircase'
taskFolder = participantFolder + '/' + task
txtPath = taskFolder+'/txt/'
xlsPath = taskFolder+'/xls/'
psydatPath = taskFolder+'/psydat/'
figurePath = taskFolder + '/figure/'
#Create directories. Doing it this way will raise any errors except directory exists errors.
makePath(outputParentDir)
makePath(participantFolder)
makePath(taskFolder)
makePath(txtPath)
makePath(xlsPath)
makePath(psydatPath)
makePath(figurePath)
#make a text file to save data
fileName = info['participant'] + dateStr
dataFile = open(txtPath+fileName+'.txt', 'w')
dataFile.write('correctStimWas stim1 stim2 correct\n ')
I am confused about where the data input from the dialogue box saves to?
When I try and create a variable ‘threshold’ later in my experiment e.g threshold = ??? I’m not sure what to write here to access the threshold input from the dialogue box.
Thanks for your help,
Christina