def main(): if len(sys.argv) < 3: print 'plot_PSTH.py <out prefix> <in1.psf.pk> [in2.psf.pk] ...' print print 'Options:' print ' --n_bins=# Number of 1-ms bins' return # -- parse options and arguments args, opts = parse_opts2(sys.argv[1:]) of = args[0] files = args[1:] print 'OF =', of print 'FILES =', files n_bins = DEF_NBINS if 'n_bins' in opts: n_bins = int(opts['n_bins']) print ' * n_bins =', n_bins db = {} load_db(files, db, n_bins=n_bins) # -- plot init() fpic = of + '.pdf' flog = of + '.bstim.log' flog2 = of + '.snr.log' pp = PdfPages(fpic) plot_all(db, pp, log=flog, log2=flog2) pp.close() print 'Done.'
def main(): if len(sys.argv) < 3: print USAGE return args, opts = parse_opts2(sys.argv[1:]) mode = args[0] # -- parsing extra arguments (mainly for backward compatibility) if mode == 'feature': get_features(args[1], args[2], opts) elif mode == 'cluster': cluster(args[1], args[2], opts) elif mode == 'collate': collate(args[1], args[2], opts) else: raise ValueError('Invalid mode') print 'Done. '
def main(): if len(sys.argv) < 3: print 'cmp_impedance.py [opts] <impedance log 1a.txt> <impedance log' \ '1b.txt> [<log 2a.txt> <log 2b.txt>] ...' print 'cmp_impedance.py: compare pairs of impedance log files.' print 'Options:' print ' --plot=<filename.pdf>' return # -- parse options and arguments args, opts = parse_opts2(sys.argv[1:]) plot = None if 'plot' in opts: plot = opts['plot'] print '* Plotting into', plot # -- do the work files = args cmp_impedance_all(files, plot=plot)
def main(): if len(sys.argv) < 3: print USAGE return args, opts = parse_opts2(sys.argv[1:]) of = args[0] files = args[1:] print 'Output prefix:', of # -- process options if 'flist' in opts: flistpx = '' if 'flistpx' in opts: flistpx = opts['flistpx'] for f in open(opts['flist']).readlines(): fp = f.strip() if flistpx != '': fp = os.path.join(flistpx, fp) files.append(fp) print 'Using the followings:' for f in files: print ' ', f multi = False fkey = FKEY if 'multi' in opts: multi = True if 'key' in opts: fkey = opts['key'].split(',') print 'Enable multiple array data processing' print 'Multiple array data key:', fkey noerr = True for f in files: found = False for i_k, k in enumerate(fkey): if k in f: found = True break if not found: noerr = False print '** Not matching file name:', f if not noerr: print '** Error occured!' return exclude_img = None if 'exclude_img' in opts: exclude_img = opts['exclude_img'].split(',') print 'Exclude unwanted images:', exclude_img n_maxtrial = N_MAXTRIAL if 'n_maxtrial' in opts: n_maxtrial = int(opts['n_maxtrial']) print 'Setting n_maxtrial:', n_maxtrial n_bins = N_BINS if 'n_bins' in opts: n_bins = int(opts['n_bins']) print 'Setting n_bins:', n_bins assert all([os.path.exists(f) for f in files]) # -- main loop try: signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGTERM, signal_handler) convert(files, of, multi=multi, fkey=fkey, \ exclude_img=exclude_img, n_maxtrial=n_maxtrial, n_bins=n_bins) finally: print 'Cleaning up...' cleanup() print 'Done.'
def main(rseed=RSEED): if len(sys.argv) < 2: print 'Prep Mode:' print 'summarizedp_cv.py prep <d\'-CV output.pk> <combined frate.pk>' print 'Note: input pickle files are made by combine_firrate_data.py' print print 'Result Formatting Mode:' print 'summarizedp_cv.py res [options] <d\'-CV output A.pk> <d\'-CV output M.pk> <d\'-CV output P.pk>' print 'Options:' print ' --prndp Print d\' values' print ' --doplot Plot PSTHs of blanks for each channel' print ' --px=prefix Prefix of output files' print ' --bad=ch1,ch2,.. Comma separated list of 1-based bad channels' print ' --ng=ch1,ch2,... Comma separated list of 1-based not-so-good channels' print ' --topn=# Pick top # channels' return # parse options and arguments args, opts = parse_opts2(sys.argv[1:]) mode = args[0] np.random.seed(rseed) # prepare d'-cv computation if mode == 'prep': fo = args[1] fi = args[2] print '* Output d\'-CV result:', fo db = pk.load(open(fi)) res = dp_cv(db) pk.dump(res, open(fo, 'wb')) # or give the results... elif mode == 'res': doplot, prndp, topn, px = False, False, TOPN, PREF bad = [] ng = [] if 'doplot' in opts: from matplotlib import rc, use use('pdf') import pylab as pl init() doplot = True print '* DOPLOT' if 'prndp' in opts: prndp = True print '* PRNDP' if 'topn' in opts: topn = int(opts['topn']) print '* TOPN =', topn if 'bad' in opts: bad = [int(b) for b in opts['bad'].split(',')] print '* BAD =', bad if 'ng' in opts: ng = [int(b) for b in opts['ng'].split(',')] print '* NG =', ng if 'px' in opts: px = opts['px'] print '* PX =', px files = args[1:] db = load_all(files, skipchk=True) pick_top(db, topn, bad=bad, ng=ng, prndp=prndp, px=px) if doplot: ipage = plot_all(db, px=px) pl.savefig(px +'_p%d.pdf' % (ipage)) print 'Done.' #pl.show() else: print 'Unrecognized mode. Aborting.'