def dmSim(): """ """ dm = CsvReader('./simulation/data.csv').dataMatrix() # X coordinates, where positive values indicate a deviation towards the handle dm = dm.addField('sacc1_ex', dtype=float) dm = dm.addField('sacc2_ex', dtype=float) dm = dm.addField('sacc3_ex', dtype=float) dm = dm.addField('sacc1_ey', dtype=float) dm = dm.addField('sacc2_ey', dtype=float) dm = dm.addField('sacc3_ey', dtype=float) dm = dm.addField("trialId", dtype = str) # Timestamps for each fixation dm = dm.addField('saccLat1', dtype=float) dm = dm.addField('saccLat2', dtype=float) dm = dm.addField('saccLat3', dtype=float) for i in dm.range(): trial = dm[i] trialNr = dm['count_trial_sequence'][i] dm["trialId"][i] = trialNr handleSide = trial['flip'][0] print 'Trial %d (%s)' % (trialNr, handleSide) sim = CsvReader('simulation/simulation/csv/%.4d.csv' % trialNr).dataMatrix() fixNr = 1 for fix in sim: t = fix['t'][0] dx = fix['x'][0] dy = fix['y'][0] dm["sacc%s_ey" % fixNr][i] = dy dm['sacc%d_ex' % fixNr][i] = dx dm['saccLat%d' % fixNr][i] = t fixNr += 1 if fixNr > 3: break dm.save('dm_simulation.csv') dm = dm.addField("expId", dtype = str, default = "sim") dm = dm.addField("symm", dtype = str, default = "asymm") dm = dm.addField("saccCount", default = 3) dm = dm.addField("mask_side", dtype = str, default = "control") dm = dm.addField("cond", dtype = str, default = "not_practice") dm = dm.addField("rep", dtype = str, default = "not_practice") dm = dm.addField("checkFixDotFailed", dtype = str, default = "False") dm = dm.addField("checkObjectFailed", dtype = str, default = "False") dm = dm.addField("file", dtype = str, default = "sim") return dm
# Give the landing positions the starting value '', such that # the same criteria can be applied to the real and the simulated # saccades. In the real dm's, the value '' indicates that a certain # landing position was not detected (e.g. endX2 does not exist if # participants made only one saccade). The same criterion should # be applied for the simulated dm, because sometimes participants # looked four times on the fix dot, and one time at the object, etc. # These landing positions should not get the value 0!! # This is done automatically by making the new variables (see above) # strings. Every empty cell gets the value "". # Walk through all cycles in the dm, and open the small simulation dm # corresponding to the current trial: for i in dm.range(): trial = dm[i] trialNr = dm['count_trial_sequence'][i] handleSide = trial['handle_side'][0] pictName = trial['pict'][0] boxWidth, boxHeight = boxDict[pictName] stim = trial['object'][0] # Add variables from simulation to dm: print 'Trial %d (%s)' % (trialNr, handleSide) # Open the small dm: sim = CsvReader('simulation/simulation/csv/%.4d.csv' \ % trialNr).dataMatrix()