def gentoplot(time): """Generates a dictionary where the keys are movie names and the values are the raw trace for plotting. Time specifies the length of time in seconds of the plots shown.""" toplot = {} # Generates a list of movie paths in the data folder. files = dftf.batch_s('.') # Generates dft traces and plots for each roi in each movie. for file in files: os.chdir(file) print(os.path.basename(file)) for col in COLS: if os.path.exists('params') == True: rawtracedata = dftf.TraceData(fname=RESULTS_FILE, paramsfile=PARAMS_FILE, corrparamsfile=CORRPARAMS_FILE, colname=col) td = rawtracedata.Processrawtrace(DFTSIZE, HZ_BOUND1, HZ_BOUND2) moviename = os.path.basename(os.path.abspath('.')) # Selects the area of the raw trace to plot. frames = time * td['fps'] #print(frames) plottime = td['seltrace'][:frames]/6 #print(len(plottime)) ms = plottime-np.mean(plottime) xsec = np.linspace(0, len(plottime)/td['fps'], len(plottime)) #print(xsec) condition = td['condition'] toplot[moviename] = [xsec, ms, condition] print(np.max(ms), np.min(ms)) return(toplot)
def gentoplot_dft(xlimhz): toplot = {} # Generates a list of movie paths in the data folder. files = dftf.batch_s('.') # Generates dft traces and plots for each roi in each movie. for file in files: os.chdir(file) print(os.path.basename(file)) for col in COLS: if os.path.exists('params') == True: rawtracedata = dftf.TraceData(fname=RESULTS_FILE, paramsfile=PARAMS_FILE, corrparamsfile=CORRPARAMS_FILE, colname=col) td = rawtracedata.Processrawtrace(DFTSIZE, HZ_BOUND1, HZ_BOUND2) condition = td['condition'] m = td['peakf'] xpoints = np.linspace(0, td['fps']/2, td['dftsize']/2) prop = xlimhz/(td['fps']/2) tracelen = np.rint(prop*len(td['dftnormtrunctrace'])) toplot[td['moviename']] = [xpoints[:tracelen], td['dftnormtrunctrace'][:tracelen], condition] return(toplot)
def gentoplot_dft(xlimhz): toplot = {} # Generates a list of movie paths in the data folder. files = dftf.batch_s('.') # Generates dft traces and plots for each roi in each movie. for file in files: os.chdir(file) print(os.path.basename(file)) for col in COLS: if os.path.exists('params') == True: rawtracedata = dftf.TraceData(fname=RESULTS_FILE, paramsfile=PARAMS_FILE, corrparamsfile=CORRPARAMS_FILE, colname=col) td = rawtracedata.Processrawtrace(DFTSIZE, HZ_BOUND1, HZ_BOUND2) condition = td['condition'] m = td['peakf'] xpoints = np.linspace(0, td['fps'] / 2, td['dftsize'] / 2) prop = xlimhz / (td['fps'] / 2) tracelen = np.rint(prop * len(td['dftnormtrunctrace'])) toplot[td['moviename']] = [ xpoints[:tracelen], td['dftnormtrunctrace'][:tracelen], condition ] return (toplot)
def gentoplot(time): """Generates a dictionary where the keys are movie names and the values are the raw trace for plotting. Time specifies the length of time in seconds of the plots shown.""" toplot = {} # Generates a list of movie paths in the data folder. files = dftf.batch_s('.') # Generates dft traces and plots for each roi in each movie. for file in files: os.chdir(file) print(os.path.basename(file)) for col in COLS: if os.path.exists('params') == True: rawtracedata = dftf.TraceData(fname=RESULTS_FILE, paramsfile=PARAMS_FILE, corrparamsfile=CORRPARAMS_FILE, colname=col) td = rawtracedata.Processrawtrace(DFTSIZE, HZ_BOUND1, HZ_BOUND2) moviename = os.path.basename(os.path.abspath('.')) # Selects the area of the raw trace to plot. frames = time * td['fps'] #print(frames) plottime = td['seltrace'][:frames]/10 #print(len(plottime)) ms = plottime-np.mean(plottime) xsec = np.linspace(0, len(plottime)/td['fps'], len(plottime)) #print(xsec) condition = td['condition'] toplot[moviename] = [xsec, ms, condition] print(np.max(ms), np.min(ms)) return(toplot)
def batch_plotspecmovie(nfft, padmultiple): # Generates a list of movie paths in the data folder. files = dftf.batch_s('.') # Generates dft traces and plots for each roi in each movie. for file in files: os.chdir(file) print(os.path.basename(file)) if os.path.exists('params') == True and os.path.exists( 'results1.txt') == True: plotspecmovie(nfft, padmultiple) dftf.savetracesumm(str(nfft), moviefold='summary/spec_pad_' + str(nfft)) plt.close()
def gentoplot(time): """Generates a dictionary where the keys are movie names and the values are the raw trace for plotting. Time specifies the length of time in seconds of the plots shown.""" toplot = {} # Generates a list of movie paths in the data folder. files = dftf.batch_s('.') # Generates dft traces and plots for each roi in each movie. for file in files: os.chdir(file) print(os.path.basename(file)) for col in COLS: if os.path.exists('params') == True: rawtracedata = dftf.TraceData(fname=RESULTS_FILE, paramsfile=PARAMS_FILE, corrparamsfile=CORRPARAMS_FILE, colname=col) td = rawtracedata.Processrawtrace(DFTSIZE, HZ_BOUND1, HZ_BOUND2) # Selects the area of the raw trace to plot. frames = time * td['fps'] frameoffset = TIMEOFFSET * td['fps'] #print(frames) if os.path.basename(file) == 'mov_20101130_200533' \ or os.path.basename(file) == 'mov_20110517_181356' \ or os.path.basename(file) == 'mov_20110517_174209': plottime = td['seltrace'][frameoffset:frames]/8 elif os.path.basename(file) == 'mov_20110518_192012': plottime = td['seltrace'][frameoffset:frames]/1.5 elif os.path.basename(file) == 'mov_20110518_184849': plottime = td['seltrace'][frameoffset:frames]/3 #elif os.path.basename(file) == 'mov_20110527_163607_part2': #plottime = td['seltrace'][50:frames+50] else: plottime = td['seltrace'][frameoffset:frames] #print(len(plottime)) ms = plottime-np.mean(plottime) xsec = np.linspace(0, len(plottime)/td['fps'], len(plottime)) #print(xsec) condition = td['condition'] toplot[td['moviename']] = [xsec, ms, condition] print(np.max(ms), np.min(ms)) return(toplot)
def pool_probendarea_results(datafol, expts): files = [] for expt in expts: exptpath = '../{0}/{1}/'.format(expt, datafol) os.chdir(exptpath) fs = dftf.batch_s('.') files.extend(fs) os.chdir('../') ad = dal.areadict(files) #ad = dal.areadict_multpts(files) pd = dal.areapoints(ad) pdd = dal.areapoints_dict(ad) md = dal.meanpoints(pd) sd = dal.statdict(pd) asd = dal.areastats(sd) #print(ad) #print(pd) #print(md) return [ad, pd, pdd, md, sd, asd]
def pool_probendarea_results(datafol, expts): files = [] for expt in expts: exptpath = '../{0}/{1}/'.format(expt, datafol) os.chdir(exptpath) fs = dftf.batch_s('.') files.extend(fs) os.chdir('../') ad = dal.areadict(files) #ad = dal.areadict_multpts(files) pd = dal.areapoints(ad) pdd = dal.areapoints_dict(ad) md = dal.meanpoints(pd) sd = dal.statdict(pd) asd = dal.areastats(sd) #print(ad) #print(pd) #print(md) return[ad, pd, pdd, md, sd, asd]
plotfolder = os.path.join( os.path.dirname(os.path.dirname(os.path.abspath('.'))), 'plots') makenewdir(plotfolder) figname = os.path.join(plotfolder, movie + '_trace_nolab') plt.savefig(figname + '.svg', dpi=FIGDPI, format='svg') plt.savefig(figname + '.png', dpi=FIGDPI, format='png') os.chdir('../') if labels == 'yes': plotfolder = os.path.join( os.path.dirname(os.path.dirname(os.path.abspath('.'))), 'plots') makenewdir(plotfolder) figname = os.path.join(plotfolder, movie + '_trace') plt.savefig(figname + '.svg', dpi=FIGDPI, format='svg') plt.savefig(figname + '.png', dpi=FIGDPI, format='png') os.chdir('../') matplotlib.rc('axes', linewidth=LINEWIDTH) # Generates a list of movie paths in the data folder. files = dftf.batch_s('.') # Generates dft traces and plots for each roi in each movie. plottrace_paper(MOVIES, FIGW, FIGH, FIGDPI, FONTSIZE, BORDER, XLABEL, YLABEL, YAXISTICKS, XAXISTICKS, LABELS, LINEWIDTH, FS) os.chdir('../')
makenewdir(summfol) return(summfol) def savemeanplot(summfold, plotname, format, figdpi=600): plt.savefig(os.path.join(summfold, plotname+'.'+str(format)), format=format, dpi=figdpi) if __name__ == '__main__': homefol = os.path.abspath(os.getcwd()) genbubparams('movies_dye_prob_end_notes.txt', 'data_area_liquid') os.chdir('data_area_liquid') #os.chdir('data_area_wholelab') files = dftf.batch_s('.') ad = areadict(files) pd = areapoints(ad) md = meanpoints(pd) print('Area dictionary') print(ad) print('Area points') print(pd) #ad = areadict_norm(files, os.path.join(homefol, 'data_hwidth')) sf = gensummfol_data('summary_area_liquid') #b_plotpoints(files, sf) savemeans(md, sf, 'means_area_liquid')