def get_summary_data( filename, whiskers, trajectories ): if os.path.exists(filename): data = numpy.load(filename) else: data = array(list( summary.features(whiskers) )) numpy.save( filename, data ) return data return summary.commit_traj_to_data_table( trajectories, data )
if not os.path.exists(os.path.split(dst)[0]): if os.path.split(dst)[0]!='': raise IOError, "Could not find destination path %s"%os.path.split(dst)[0] if not all( map( os.path.exists, args )): raise IOError, "Could not find one or more input source files." if all(map( lambda f: os.path.splitext(f)[-1] in ['.trajectories','.whiskers'], args )): if len(args)==1: src = args[0] tfile = None else: src = args[1] #know the order b.c. already sorted by file extenstion tfile = args[0] w = trace.Load_Whiskers( src ) data = numpy.array(list( summary.features(w, options.face) )) if tfile: t,tid = load_trajectories( tfile ) summary.commit_traj_to_data_table( t, data ) elif all(map( lambda f: os.path.splitext(f)[-1] in ['.trajectories','.measurements'], args )): sources = dict( map( lambda f: (os.path.splitext(f)[-1], f), args ) ) try: data = traj.MeasurementsTable( sources['.measurements'] ).asarray() except KeyError: raise UserException, "A .measurements file must be provided as one of the source files." try: t,tid = load_trajectories( sources['.trajectories'] )
if not all(map(os.path.exists, args)): raise IOError, "Could not find one or more input source files." if all( map( lambda f: os.path.splitext(f)[-1] in ['.trajectories', '.whiskers'], args)): if len(args) == 1: src = args[0] tfile = None else: src = args[ 1] #know the order b.c. already sorted by file extenstion tfile = args[0] w = trace.Load_Whiskers(src) data = numpy.array(list(summary.features(w, options.face))) if tfile: t, tid = load_trajectories(tfile) summary.commit_traj_to_data_table(t, data) elif all( map( lambda f: os.path.splitext(f)[-1] in ['.trajectories', '.measurements'], args)): sources = dict(map(lambda f: (os.path.splitext(f)[-1], f), args)) try: data = traj.MeasurementsTable(sources['.measurements']).asarray() except KeyError: raise UserException, "A .measurements file must be provided as one of the source files."
import traj from ui.whiskerdata import save_trajectories warnings.simplefilter("default",UserWarning) if __name__ == '__main__': parser = optparse.OptionParser( usage = "Usage: %prog source destination" ) options,args = parser.parse_args() if len(args) != 2: parser.error( "Expected source and destination file names but recieved %d arguments."%len(args) ) src, dst = args if not os.path.exists(os.path.split(dst)[0]): # check path, do this before doing long calculation raise IOError, "Could not find destination file %s"%dst # # Get data from source # ext = os.path.splitext(src)[1] if ext == '.whiskers': w = trace.Load_Whiskers(src) data = array(list( summary.features(w) )) elif ext == '.measurements': data = traj.MeasurementsTable(src).asarray() else: raise IOError, "Source file extension not recognized. Got: %s"%ext traj = summary._simpletraj(data) save_trajectories(dst, traj)
warnings.simplefilter("default", UserWarning) if __name__ == '__main__': parser = optparse.OptionParser(usage="Usage: %prog source destination") options, args = parser.parse_args() if len(args) != 2: parser.error( "Expected source and destination file names but recieved %d arguments." % len(args)) src, dst = args if not os.path.exists(os.path.split( dst)[0]): # check path, do this before doing long calculation raise IOError, "Could not find destination file %s" % dst # # Get data from source # ext = os.path.splitext(src)[1] if ext == '.whiskers': w = trace.Load_Whiskers(src) data = array(list(summary.features(w))) elif ext == '.measurements': data = traj.MeasurementsTable(src).asarray() else: raise IOError, "Source file extension not recognized. Got: %s" % ext traj = summary._simpletraj(data) save_trajectories(dst, traj)