def makeDF(camdir): # creates data frame for CAM experiments, and returns paths to all experiments list_of_dirs = os.walk(camdir).next()[1] list_of_paths = [] for i in list_of_dirs: nwb_path = camdir + i + '/' + i + '.nwb' list_of_paths.append(nwb_path) CAM_df = pd.DataFrame(index=range(len(list_of_paths),),columns=cn.getMetaData(list_of_paths[0])) row_counter = 0 for path in list_of_paths: CAM_df.loc[row_counter] = pd.Series(cn.getMetaData(path)) row_counter += 1 # add a metric of running speed to that data frame mean_speed = [] for path in list_of_paths: run_data = cn.getRunningSpeed(path) mean_speed.append(np.nanmean(run_data[0])) CAM_df['mean speed'] = mean_speed CAM_df['path_to_exp'] = list_of_paths return list_of_paths, CAM_df
NTRIALS = 15 # number of trials per sweep PTHRESH = 0.05 # p-value cutoff above which results are not significant DTHRESH = 0.01 # D-statistic for K-S test below which results are not significant NBINS = 20 # number of bins for histogram plot DF_THRESH = 15 # percent threshold (dF/F) for cutting off non-responsive cells # get experiment data and path to experiments list_of_dirs = os.walk(CAMDIR).next()[1] list_of_paths = [] for i in list_of_dirs: nwb_path = CAMDIR + i + '/' + i + '.nwb' list_of_paths.append(nwb_path) CAM_df = pd.DataFrame(index=range(len(list_of_paths),), columns=cn.getMetaData(list_of_paths[0])) row_counter = 0 for path in list_of_paths: CAM_df.loc[row_counter] = pd.Series(cn.getMetaData(path)) row_counter += 1 # add a metric of running speed to that data frame mean_speed = [] for path in list_of_paths: run_data = cn.getRunningSpeed(path) mean_speed.append(np.nanmean(run_data[0])) CAM_df['mean speed'] = mean_speed CAM_df['path_to_exp'] = list_of_paths # LOOP OVER ALL EXPERIMENTS AND CALCULATE HISTOGRAM OF LIFETIME SPARSENESSES FOR EACH lift_spar_list = []
NPERMS = 100 # number of permutations to use for permutation test of significance for LVs NBOOTS = 100 # number of iterations to perform for bootsrapping procedure for salience stabilities # get experiment data and path to experiments path_list, CAM_df = pr.makeDF(CAMDIR) # LOOP OVER ALL EXPERIMENTS AND CALCULATE HISTOGRAM OF LIFETIME SPARSENESSES FOR EACH life_spar_list = [] pop_spar_list = [] meta_list = [] pval_list = [] sal_list = [] for path in path_list: # extract interesting information meta = cn.getMetaData(path) # get meta data for experiment of interest proj = cn.getMaxProjection( path ) # getMaxProjection returns a 512x512 array of the maximum projection of the 2P movie print meta meta_list.append(meta) # returns an array of raw fluorescence traces for each ROI and the timestamps for each time point. timestamps, celltraces = cn.getFluorescenceTraces(path) number_cells = np.size(celltraces, 0) acquisition_rate = 1 / (timestamps[1] - timestamps[0]) print "Number of cells: ", number_cells print "Acquisition rate: %f Hz" % acquisition_rate # returns data frame of stimulus conditions
NBOOTS = 100 # number of iterations to perform for bootsrapping procedure for salience stabilities # get experiment data and path to experiments path_list, CAM_df = pr.makeDF(CAMDIR) # LOOP OVER ALL EXPERIMENTS AND CALCULATE HISTOGRAM OF LIFETIME SPARSENESSES FOR EACH life_spar_list = [] pop_spar_list = [] meta_list = [] pval_list = [] sal_list = [] for path in path_list: # extract interesting information meta = cn.getMetaData(path) # get meta data for experiment of interest proj = cn.getMaxProjection(path) # getMaxProjection returns a 512x512 array of the maximum projection of the 2P movie print meta meta_list.append(meta) # returns an array of raw fluorescence traces for each ROI and the timestamps for each time point. timestamps, celltraces = cn.getFluorescenceTraces(path) number_cells = np.size(celltraces,0) acquisition_rate = 1/(timestamps[1]-timestamps[0]) print "Number of cells: ", number_cells print "Acquisition rate: %f Hz" % acquisition_rate # returns data frame of stimulus conditions stimulus_table = cn.getStimulusTable(path) number_sweeps = len(stimulus_table)