def get_trial_outcomes(dfns): trialdata = {} # initiate output dict for dfn in dfns: df = None df = pymworks.open(dfn) # open the datafile devs = df.get_events('#stimDisplayUpdate') # get all display update events # stims = pymworks.events.display.to_stims(devs) resptypes = ['session_correct_lick','session_correct_ignore',\ 'session_bad_lick','session_bad_ignore'] #,\ # 'aborted_counter'] # list of response variables to track... outevs = df.get_events(resptypes) # get all events with these vars responses = [] for r in resptypes: # get list of incrementing variables revs = df.get_events(r) incr_resp = session_incremented(revs) responses.append(incr_resp) responses = list(itertools.chain.from_iterable(responses)) real_responses = [r for r in responses if r.value != 0] trials = pymworks.events.display.to_trials(devs, responses,\ remove_unknown=True) # get rid of orphan events #synctrials = syncdicts(stims,real_responses,direction=-1) #trash = [t for t in synctrials if t is None] #trials = [t for t in synctrials if t not in trash] trialdata[dfn] = trials return trialdata
def process_datafiles(dfns, stats): data = {} for dfn in dfns: logging.debug("Datafile: %s" % dfn) df = None df = pymworks.open(dfn) r = {} for s in stats: r[s] = stats[s][0](df) logging.debug("\t%s: %s" % (s, r[s])) df.close() data[dfn] = r return data
def process_datafiles(dfns, stats): data = {} try: for dfn in dfns: logging.debug("Datafile: %s" % dfn) df = None df = pymworks.open(dfn) r = {} for s in stats: r[s] = stats[s][0](df) logging.debug("\t%s: %s" % (s, r[s])) df.close() data[dfn] = r return data except KeyError: print "NO KEY FOUND: %s", dfn
def process_datafiles(dfns, stats): data = {} for dfn in dfns: logging.debug("Datafile: %s" % dfn) df = None df = pymworks.open(dfn) r = {} for s in stats: try: r[s] = stats[s][0](df) logging.debug("\t%s: %s" % (s, r[s])) except TypeError: print "stat: ", s, "file: ", dfn df.close() data[dfn] = r return data
def process_outcomes(dfns, stats): data = {} for dfn in dfns: df = None df = pymworks.open(fn) r = {} evs = df.get_events('#stimDisplayUpdate') outcomes = df.get_events(('session_correct_lick', 'session_correct_ignore',\ 'session_bad_lick', 'session_bad_ignore')) ts = pymworks.events.display.to_trials(evs, outcomes) gts = datautils.grouping.groupn(ts, ('name', 'outcome')) nOutcomes = datautils.grouping.ops.stat(gts, len) respkeys = [k for k in nOutcomes.keys()] corrlicks = [] badignores = [] corrignores = [] badlicks = [] for k in respkeys: resptypes = nOutcomes[k].keys() for t in resptypes: if 'correct_lick' in t: corrlicks.append(nOutcomes[k][t]) if 'bad_ignore' in t: badignores.append(nOutcomes[k][t]) if 'correct_ignore' in t: corrignores.append(nOutcomes[k][t]) if 'bad_lick' in t: badlicks.append(nOutcomes[k][t]) correct_licks = sum(corrlicks) bad_ignores = sum(badignores) correct_ignores = sum(corrignores) bad_licks = sum(badlicks) df.close() data[dfn] = r return data
def parse_trials(dfns, remove_orphans=True): trialdata = {} # initiate output dict for dfn in dfns: df = None df = pymworks.open(dfn) # open the datafile sname = os.path.split(dfn)[1] trialdata[sname] = [] modes = df.get_events('#state_system_mode') run_idxs = np.where(np.diff([i['time'] for i in modes])<20) bounds = [] for r in run_idxs[0]: stop_ev = next(i for i in modes[r:] if i['value']==0) bounds.append([modes[r]['time'], stop_ev['time']]) print "................................................................" # print "----------------------------------------------------------------" print "Parsing file\n%s... " % dfn print "Found %i start events in session." % len(bounds) print "................................................................" for bidx,boundary in enumerate(bounds): print "----------------------------------------------------------------" print "SECTION %i" % bidx print "----------------------------------------------------------------" tmp_devs = df.get_events('#stimDisplayUpdate') # get *all* display update events tmp_devs = [i for i in tmp_devs if i['time']<= boundary[1] and i['time']>=boundary[0]] dimmed = df.get_events('flag_dim_target') dimmed = np.mean([i.value for i in dimmed]) # set dim flag to separate trials based on initial stim presentation resptypes = ['session_correct_lick','session_correct_ignore','session_bad_lick','session_bad_ignore'] #,\ # 'aborted_counter'] # list of response variables to track... outevs = df.get_events(resptypes) # get all events with these vars outevs = [i for i in outevs if i['time']<= boundary[1] and i['time']>=boundary[0]] # responses = [] # for r in resptypes: # get list of incrementing variables # revs = df.get_events(r) # incr_resp = [r for r in revs if r['time']>=boundary[0] and r['time']<=boundary[1]] # incr_resp = session_incremented(revs) # responses.append(incr_resp) # responses = list(itertools.chain.from_iterable(responses)) # real_responses = [r for r in responses if r.value != 0] # remove initial 0 value set at session start # R = sorted(real_responses, key=lambda e: e.time) # sort by time R = sorted([r for r in outevs if r.value > 0], key=lambda e: e.time) T = pymworks.events.display.to_trials(tmp_devs, R, remove_unknown=False)# match stim events to response events if dimmed: # don't double count stimulus for "faded" target stimuli trials = [i for i in T if i['alpha_multiplier']==1.0] else: trials = T print "N total response events: ", len(trials) if remove_orphans: # this should always be true, generally... orphans = [(i,x) for i,x in enumerate(trials) if x['outcome']=='unknown'] trials = [t for t in trials if not t['outcome']=='unknown'] # get rid of display events without known outcome within 'duration_multiplier' time print "Found and removed %i orphan stimulus events in file %s" % (len(orphans), dfn) print "N valid trials: %i" % len(trials) trialdata[sname].append(trials) return trialdata
# print 'Distractor count off by %d, in %s' % (tmp_nDistractors-(tmp_correct_ignores+tmp_bad_licks), fn) difference = tmp_nDistractors-(tmp_correct_ignores+tmp_bad_licks) distractor_count_check.append([fn, difference]) if ((tmp_correct_licks+tmp_bad_ignores) == tmp_nTargets) \ and ((tmp_correct_ignores+tmp_bad_licks) == tmp_nDistractors): good_counts.append([fn]) if target_count_check != [] or distractor_count_check != []: print "Targets: ", target_count_check print "Distractors: ", distractor_count_check else: print "Session trial counts good." # get stimulus display update events, and parse them into trials: df = pymworks.open(fn) evs = df.get_events('#stimDisplayUpdate') outcome_events = df.get_events(('correct_lick', 'bad_lick', 'correct_ignore', 'bad_ignore')) stims = pymworks.events.display.to_stims(evs) trials = pymworks.events.display.to_trials(evs, outcome_events) if len(stims) != len(trials): print "Stims vs Trials: %s, %d" % (fn, len(stims)-len(trials)) elif len(stims) == 0 or len(trials) == 0: print len(stims), len(trials), fn else: print "Events by stim and trial are matched." # get targetprob events within the time-range of trials:
def get_object_rot(datadir): ''' Object rotations are made by rotating blob in POVray. All stimulus-rotation values will be 0. Get true rotation relative to default using image path name. ''' processed_dir = os.path.join(os.path.split(datadir)[0], 'processed') animals = os.listdir(processed_dir) animals = [i for i in animals if i.endswith('.pkl')] animals = [os.path.splitext(a)[0] for a in animals] for animal in animals: fn = os.path.join(processed_dir, animal+'.pkl') with open(fn, 'rb') as f: curr_trials = pkl.load(f) session_dates = [] for t in curr_trials.keys(): subject, date, epoch = parse_filename(t) session_dates.append(date) for t in curr_trials.keys(): print t if len(curr_trials[t])==0: continue else: if len(curr_trials[t])==1: ctrials = curr_trials[t][0] else: ctrials = curr_trials[t] df = pymworks.open(os.path.join(datadir, subject, t)) # if no morphs, move on... # mtrials = [i for i in ctrials if 'morph' in i['name']] # if len(mtrials)>0: # continue # Get TRUE SIZES AND ROTATIONS: AspRat_name = 'StimAspectRatio' AspRat = df.get_events(AspRat_name)[-1].value sizs = [round(i['size_x']/AspRat) for i in ctrials] print set(sizs) stims = [i['name'] for i in ctrials] rots = [] for s in stims: if 'Blob' in s: rots.append(s.rsplit('y', 1)[1].rsplit('.',1)[0]) else: rots.append(0) for sz,rot,ctrial in zip(sizs, rots, ctrials): try: ctrial['actual_rotation'] = rot ctrial['actual_size'] = str(sz) except KeyError: print ctrial curr_trials[t] = ctrials save_dict(curr_trials, os.path.split(fn)[0], os.path.split(fn)[1]) print "Saved to %s" % fn
# devs = [e for e in evs if e.value] # im_names = [i['name'] for d in devs for i in d.value if '.png' in i['name']] # morphs = [i for i in im_names if 'morph' in i] # print len(morphs) # from collections import Counter # from pandas import Series # fn = [i for i in fns if '_SD' in i] #[0] # print fn # # f = fn for f in fns: # f = fn[4] print f df = pymworks.open(os.path.join(file_dir, f)) # Check stimDisplayUpdate events vs announceStimulus: stim_evs = df.get_events('#stimDisplayUpdate') devs = [e for e in stim_evs if not e.value==[None]] idevs = [i for i in devs for v in i.value if 'png' in v['name']] ann_evs = df.get_events('#announceStimulus') aevs = [e for e in ann_evs if type(e.value) is dict] sevs = [i for i in aevs if 'png' in i.value['name']] if not len(idevs)==len(sevs): print "MISMATCH in event counts in DF: %s" % f print "-------------------------" print "#stimDisplayUpdate %i and #announceStimulus %i." % (len(idevs), len(sevs))
def parse_trials(dfns, remove_orphans=True): """ Parse session .mwk files. Key is session name values are lists of dicts for each trial in session. Looks for all response and display events that occur within session. dfns : list of strings contains paths to each .mwk file to be parsed remove_orphans : boolean for each response event, best matching display update event set this to 'True' to remove display events with unknown outcome events """ trialdata = {} # initiate output dict for dfn in dfns: df = None df = pymworks.open(dfn) # open the datafile sname = os.path.split(dfn)[1] trialdata[sname] = [] modes = df.get_events('#state_system_mode') # find timestamps for run-time start and end (2=run) run_idxs = np.where(np.diff([i['time'] for i in modes])<20) # 20 is kind of arbitray, but mode is updated twice for "run" bounds = [] for r in run_idxs[0]: try: stop_ev = next(i for i in modes[r:] if i['value']==0 or i['value']==1) except StopIteration: end_event_name = 'trial_end' print "NO STOP DETECTED IN STATE MODES. Using alternative timestamp: %s." % end_event_name stop_ev = df.get_events(end_event_name)[-1] print stop_ev bounds.append([modes[r]['time'], stop_ev['time']]) # print "................................................................" print "****************************************************************" print "Parsing file\n%s... " % dfn print "Found %i start events in session." % len(bounds) print "****************************************************************" for bidx,boundary in enumerate(bounds): # print "................................................................" print "SECTION %i" % bidx print "................................................................" tmp_devs = df.get_events('#stimDisplayUpdate') # get *all* display update events tmp_devs = [i for i in tmp_devs if i['time']<= boundary[1] and\ i['time']>=boundary[0]] # only grab events within run-time bounds (see above) dimmed = df.get_events('flag_dim_target') dimmed = np.mean([i.value for i in dimmed]) # set dim flag to separate trials based on initial stim presentation resptypes = ['session_correct_lick','session_correct_ignore',\ 'session_bad_lick','session_bad_ignore'] #,\ # 'aborted_counter'] # list of response variables to track... outevs = df.get_events(resptypes) # get all events with these vars outevs = [i for i in outevs if i['time']<= boundary[1] and\ i['time']>=boundary[0]] R = sorted([r for r in outevs if r.value > 0], key=lambda e: e.time) T = pymworks.events.display.to_trials(tmp_devs, R,\ remove_unknown=False) # match stim events to response events if dimmed: # don't double count stimulus for "faded" target stimuli trials = [i for i in T if i['alpha_multiplier']==1.0] else: trials = T print "N total response events: ", len(trials) if remove_orphans: # this should always be true, generally... orphans = [(i,x) for i,x in enumerate(trials) if\ x['outcome']=='unknown'] trials = [t for t in trials if not t['outcome']=='unknown'] # get rid of display events without known outcome within 'duration_multiplier' time print "Found and removed %i orphan stimulus events in file %s"\ % (len(orphans), dfn) print "N valid trials: %i" % len(trials) trialdata[sname].append(trials) return trialdata
def get_morph_stats(datadir, baseline, show_curve=True): if baseline is True: processed_dir = os.path.join(os.path.split(datadir)[0], 'processed_premorphs') else: processed_dir = os.path.join(os.path.split(datadir)[0], 'processed') animals = os.listdir(processed_dir) animals = [i for i in animals if i.endswith('_trials.pkl')] animals = [os.path.splitext(a)[0] for a in animals] P = dict() for animal in animals: P[animal] = dict() fn = os.path.join(processed_dir, animal+'.pkl') with open(fn, 'rb') as f: curr_trials = pkl.load(f) session_dates = [] for t in curr_trials.keys(): print t subject, date, epoch = parse_filename(t) session_dates.append(date) true_middle_idx = False # Bad indexing, incorrect assignment of halway point bw morphs in MW M = dict() for t in sorted(curr_trials.keys(), key=natural_keys): print t if len(curr_trials[t])==0: continue elif len(curr_trials[t])==1 or len(curr_trials[t])==2: ctrials = [] check_idx = 0 while ctrials==[]: ctrials = curr_trials[t][check_idx] check_idx += 1 else: print "LEN: ", len(curr_trials[t]) ctrials = curr_trials[t] df = pymworks.open(os.path.join(datadir, subject, t)) # if no morphs, move on... mtrials = [i for i in ctrials if 'morph' in i['name']] if len(mtrials)==0: continue # Assign appropriate 1/2-way point to calculate percent RIGHT choice (or LEFT): # BEFORE 08/18/2016 -- incorrect indexing, so "halway" should be 11. # Otherwise, halfway should be 10. if '160818' in date: true_middle_idx = True # Keep this flag ON for all dates after this. if true_middle_idx is True: middle_idx = 10 else: middle_idx = 11 # Do this funky stuff to get default size: sizes = [i['size_x'] for i in ctrials] sizes = list(set(sizes)) tmp_default_size = 40*df.get_events('StimAspectRatio')[0].value diffs = np.array(sizes) - tmp_default_size find_match = np.where(diffs==min(diffs, key=lambda x: abs(float(x) - tmp_default_size))) default_size = sizes[find_match[0][0]] anchor_trials = [i for i in ctrials if '_y0' in i['name'] and i['size_x']==default_size] anchor_names = list(set([i['name'] for i in anchor_trials])) morph_names = sorted(list(set([i['name'] for i in mtrials])), key=natural_keys) morphs = dict() for m in morph_names: morphs[m] = dict() morphs[m]['success'] = sum([1 for i in mtrials if i['name']==m and i['outcome']=='success']) morphs[m]['failure'] = sum([1 for i in mtrials if i['name']==m and i['outcome']=='failure']) morphs[m]['ignore'] = sum([1 for i in mtrials if i['name']==m and i['outcome']=='ignore']) morphs[m]['total'] = sum([morphs[m]['success'] + morphs[m]['failure'] + morphs[m]['ignore']]) for m in anchor_names: if '_N1' in m: # THIS IS SPACESHIP -- AG group, this is RIGHT aname = 'morph0.png' elif '_N2' in m: # THIS IS BUNNY -- this is LEFT aname = 'morph21.png' if aname not in morphs.keys(): morphs[aname] = dict() morphs[aname]['success'] = sum([1 for i in anchor_trials if i['name']==m and i['outcome']=='success']) morphs[aname]['failure'] = sum([1 for i in anchor_trials if i['name']==m and i['outcome']=='failure']) morphs[aname]['ignore'] = sum([1 for i in anchor_trials if i['name']==m and i['outcome']=='ignore']) morphs[aname]['total'] = sum([morphs[aname]['success'] + morphs[aname]['failure'] + morphs[aname]['ignore']]) M[t] = morphs # all_morph_names = ['morph%i.png' % int(i) for i in range(22)] all_morph_names = ['morph%i.png' % int(i) for i in range(22)] P[animal]['session'] = dict() session_keys = ['percent', 'total', 'success', 'failure', 'ignore'] # initiate dict() for each session/morph: for session_key in session_keys: P[animal]['session'][session_key] = dict() for msession in M.keys(): P[animal]['session'][session_key][msession] = dict() for mkey in M.keys(): for morph in all_morph_names: morph_num = int(re.findall("[-+]?\d+?\d*", morph)[0]) if morph not in M[mkey].keys() or M[mkey][morph]['total']==0: for skey in P[animal]['session'].keys(): P[animal]['session'][skey][mkey][str(morph_num)] = 0. else: for skey in P[animal]['session'].keys(): # if just need totals for a given morph in a given session: if skey is not 'percent': P[animal]['session'][skey][mkey][str(morph_num)] = float(M[mkey][morph][skey]) # otherwise, need to calculate %-choose-RIGHT (or LEFT) port: # SEE NOTE BELOW on halway cutoff point... elif skey == 'percent': if morph_num <= middle_idx: # 11: #morph_num <= 11: P[animal]['session'][skey][mkey][str(morph_num)] = float(M[mkey][morph]['success']/float(M[mkey][morph]['total'])) elif morph_num > middle_idx: #>= 11: #> 11: P[animal]['session'][skey][mkey][str(morph_num)] = float(M[mkey][morph]['failure']/float(M[mkey][morph]['total'])) ALL = dict() for morph in sorted(all_morph_names, key=natural_keys): ALL[morph] = dict() ALL[morph]['success'] = [] ALL[morph]['failure'] = [] ALL[morph]['ignore'] = [] ALL[morph]['total'] = [] for i in M.keys(): if morph in M[i].keys(): ALL[morph]['success'].append(M[i][morph]['success']) ALL[morph]['failure'].append(M[i][morph]['failure']) ALL[morph]['ignore'].append(M[i][morph]['ignore']) ALL[morph]['total'].append(M[i][morph]['total']) else: ALL[morph]['success'].append(0) ALL[morph]['failure'].append(0) ALL[morph]['ignore'].append(0) ALL[morph]['total'].append(0) percents = dict() totals = dict() successes = dict() failures = dict() ignores = dict() for m in sorted(all_morph_names, key=natural_keys): morph_num = int(re.findall("[-+]?\d+?\d*", m)[0]) print morph_num totals[m] = float(sum(ALL[m]['total'])) successes[m] = float(sum(ALL[m]['success'])) failures[m] = float(sum(ALL[m]['failure'])) ignores[m] = float(sum(ALL[m]['ignore'])) if m not in ALL.keys() or sum(ALL[m]['total'])==0: percents[m] = 0 else: # With nmorphs = 20, morphs 1-10.png are CHOOSE-RIGHT. # For now, plot %-choose-right (i.e., morphs1-10) # This means, "success" for morphs1-10, and "failure" for morphs11-20 (i.e,. animal went RIGHT, when should have gone LEFT) # ALL STUFF BEFORE 08/17/2016 was incorrectly assignign the halfway point in MW protocol: # i.e,. was assigning indices <=10 to "left" and >10 to "right" # This should really be: <=9 to left, >=10 to right... fixed on 08/17 # SEE ABOVE, for session-parsed %s... if morph_num <= middle_idx: #< 11: percents[m] = float(sum(ALL[m]['success'])) / float(sum(ALL[m]['total'])) elif morph_num > middle_idx: #>= 11: percents[m] = float(sum(ALL[m]['failure'])) / float(sum(ALL[m]['total'])) P[animal]['percent_right'] = percents print percents P[animal]['totals'] = totals P[animal]['success'] = successes P[animal]['failure'] = failures P[animal]['ignore'] = ignores x = [] xlabel = [] for p in sorted(percents.keys(), key=natural_keys): x.append(percents[p]) xlabel.append(p) x = np.flipud(x) xlabel = np.flipud(x) fig = plt.figure() plt.plot(x, 'r*') plt.ylabel('percent choose RIGHT port') plt.xlabel('morph #') subject = animal.split('_')[0] plt.title('%s' % subject) imname = '%s.png' % subject outdir = os.path.join(os.path.split(datadir)[0], 'figures') if not os.path.exists(outdir): os.makedirs(outdir) fig.savefig(outdir + '/' + imname) print outdir + '/' + imname if show_curve is True: plt.show() return P
def parse_trials(dfns, remove_orphans=True): """ Parse session .mwk files. Key is session name values are lists of dicts for each trial in session. Looks for all response and display events that occur within session. dfns : list of strings contains paths to each .mwk file to be parsed remove_orphans : boolean for each response event, best matching display update event set this to 'True' to remove display events with unknown outcome events """ trialdata = {} # initiate output dict for dfn in dfns: df = None df = pymworks.open(dfn) # open the datafile sname = os.path.split(dfn)[1] trialdata[sname] = [] modes = df.get_events('#state_system_mode') # find timestamps for run-time start and end (2=run) # run_idxs = np.where(np.diff([i['time'] for i in modes])<20) # 20 is kind of arbitray, but mode is updated twice for "run" start_ev = [i for i in modes if i['value']==2][0] # stop_ev_ev = [i for i in modes if i['time']>start_ev['time'] and (i['value']==0 or i['value']==1)] run_idxs = [i for i,e in enumerate(modes) if e['time']>start_ev['time']] bounds = [] for r in run_idxs: #[0]: try: # stop_ev = next(i for i in modes[r:] if i['value']==0 or i['value']==1) stop_ev = next(i for i in modes[r:] if i['value']==0 or i['value']==1) except StopIteration: end_event_name = 'trial_end' print "NO STOP DETECTED IN STATE MODES. Using alternative timestamp: %s." % end_event_name stop_ev = df.get_events(end_event_name)[-1] print stop_ev bounds.append([modes[r]['time'], stop_ev['time']]) bounds[:] = [x for x in bounds if not x[1]-x[0]<1] # print "................................................................" print "****************************************************************" print "Parsing file\n%s... " % dfn print "Found %i start events in session." % len(bounds) print "****************************************************************" for bidx,boundary in enumerate(bounds): if (boundary[1]-boundary[0])<1: del bounds[bidx] # print "................................................................" print "SECTION %i" % bidx print "................................................................" #M1:#tmp_devs = df.get_events('#stimDisplayUpdate') # get *all* display update events # tmp_devs = [i for i in tmp_devs if i['time']<= boundary[1] and\ # i['time']>=boundary[0]] # only grab events within run-time bounds (see above) #M1:#devs = [e for e in tmp_devs if not e.value[0]==[None]] # Check stimDisplayUpdate events vs announceStimulus: stim_evs = df.get_events('#stimDisplayUpdate') devs = [e for e in stim_evs if not e.value[0]==None] idevs = [i for i in devs for v in i.value if 'png' in v['name']] ann_evs = df.get_events('#announceStimulus') # SEE: AG8_160705.mwk -- issue with sevs... try: sevs = [i for i in ann_evs if 'png' in i.value['name']] except TypeError as e: print dfn print e if not len(idevs)==len(sevs): print "MISMATCH in event counts in DF: %s" % dfn print "-------------------------" print "#stimDisplayUpdate %i and #announceStimulus %i." % (len(idevs), len(sevs)) #M1:#devs = [e for e in stim_evs if e.value[0] is not None] im_names = sorted([i['name'] for d in idevs for i in d.value if '.png' in i['name']], key=natural_keys) #im_names = sorted([i['name'] for d in devs for i in d.value if '.png' in i['name']], key=natural_keys) resptypes = ['success','ignore','failure'] #,\ # 'aborted_counter'] # list of response variables to track... outevs = df.get_events(resptypes) # get all events with these vars outevs = [i for i in outevs if i['time']<= boundary[1] and\ i['time']>=boundary[0]] R = sorted([r for r in outevs if r.value > 0], key=lambda e: e.time) T = pymworks.events.display.to_trials(stim_evs, R,\ remove_unknown=False) # match stim events to response events trials = T print "N total response events: ", len(trials) if remove_orphans: # this should always be true, generally... orphans = [(i,x) for i,x in enumerate(trials) if\ x['outcome']=='unknown'] trials = [t for t in trials if not t['outcome']=='unknown'] # get rid of display events without known outcome within 'duration_multiplier' time print "Found and removed %i orphan stimulus events in file %s"\ % (len(orphans), dfn) print "N valid trials: %i" % len(trials) trialdata[sname].append(trials) return trialdata
def get_non_floats(fn, name=''): df = pymworks.open(fn) evs = df.get_events(name) for ev in evs: if type(ev.value) != float: print fn