psychopy.org | Reference | Downloads | Github

Several excel data output files per subject

Hello all,

I am programming a simple visual search task in which following a cue and a delay period participants have to detect a tilted line (inside a geometric figure) while ignoring a vertical line (inside another geometric figure). I have adapted the scripting from the Posner cueing task to do this task. The task contains four trials and the conditions are specified in a excel csv sheet (see attached).
taskconditions.csv (275 Bytes)

The problem is that by the end of experiment I get 4 excel data output files (e.g. with mean search RTs and the accuracy) i.e., one for each individual trial. I would much rather prefer to have the data summarized in one single excel data output file.

Looking at the script below can anyone help with a solution?
Many thanks in advance
Jose

Experiment code

from psychopy import visual, event, data, core, gui

win = visual.Window([1000,568], fullscr=False, units=‘pix’)

info = {} #a dictionary
#present dialog to collect info
info[‘participant’] = ‘’
dlg = gui.DlgFromDict(info)

#add additional info after the dialog has gone
info[‘dateStr’] = data.getDateStr() #will create str of current date/time
filename = “data/” + info[‘participant’] + “_” + info[‘dateStr’]

welcometext = visual.TextStim(win, text=‘Welcome to the experiment’)
welcometext.draw()
win.flip()
event.waitKeys()

stimtriang= visual.ShapeStim(win, vertices = [[-50,-50], [50,-50], [0,50]])

stimrect = visual.Rect(win=win, units = “pix”, width = 90, height = 90)

fixation = visual.Circle(win, size = 5, lineColor = ‘white’, fillColor = ‘lightGrey’)

tiltedline = visual.Line(win=win, units = “pix”, lineColor = “black”)
tiltedline.start = [0, 20]
tiltedline.end = [0, -20]

vertline = visual.Line(win=win, units = “pix”, lineColor = “black”)
vertline.start = [0, 20]
vertline.end = [0, -20]

respClock = core.Clock()

conditions = data.importConditions(‘taskconditions.csv’)
reader = data.TrialHandler(trialList=conditions, method=‘sequential’, nReps=1)

for row in reader:

stimrect.setLineColor( row['cuecolour'] )
stimrect.pos = (0,0)
stimrect.draw()
win.flip()
core.wait(0.5)

fixation.draw()
win.flip()
core.wait(0.5)

stimrect.setLineColor( row['probecolora'] )
stimtriang.setLineColor( row['probecolorb'] )
stimrect.setPos( [row['probeposa'], 0] )
stimtriang.setPos( [row['probeposb'], 0] )
tiltedline.setPos( [row['tiltedlinepos'], 0] )
vertline.setPos( [row['vertlinepos'], 0] )
tiltedline.setOri( row['targetori'])

stimrect.draw()
stimtriang.draw()
tiltedline.draw()
vertline.draw()
win.flip()
respClock.reset()
keys = event.waitKeys(keyList = ['left','right'])
resp = keys[0]
rt = respClock.getTime()

if row['targetori']>0 and resp=='right':
   corr = 1
elif row['targetori']<0 and resp=='left':
   corr = 1
else:
   corr = 0
   
if row['validity'] == "valid":
    trial = 'valid'
elif row['validity'] == "invalid":
    trial = 'invalid'  
  
thisExp = data.ExperimentHandler(
extraInfo = info, #the info we created earlier
dataFileName = filename, # using our string with data/name_date
)

thisExp.addData('resp', resp)
thisExp.addData('rt', rt)
thisExp.addData('trial', trial)
thisExp.addData('corr', corr)
thisExp.nextEntry()