コード例 #1
0
        res[prefix][thres] = quality_mx

pickle.dump(res, open(os.path.join(save_path, 'thres_res.pckl'), 'w'))

# plotting
for prefix in res.keys():

    fig = plt.figure()
    fig.suptitle(prefix)
    gs = gridspec.GridSpec(len(range(2, 7)), 1)
    gs.update(hspace=0.7)

    thresholds = sorted(res[prefix].keys())
    for n in range(2, 7):
        p = fig.add_subplot(gs[n - 2, 0])
        channels = np.zeros(len(thresholds))

        for i, thres in enumerate(thresholds):
            quality_mx = res[prefix][thres]
            best = utils.select_n_channels(quality_mx, n)
            channels[i] = sum((np.sum(quality_mx[best, :], 0) == n).astype('int'))
        p.grid()
        p.plot(thresholds, channels.T)
        p.set_title('# of animals: %d' % int(n))
        p.set_xticklabels([])
        p.set_yticks(range(0, np.size(quality_mx, 1), 5))
    p.set_xlabel('threshold')
    p.set_xticklabels(thresholds)
    fig.savefig(os.path.join(save_path, 'groupsize_' + prefix + '.png'))

コード例 #2
0
ファイル: runDros.py プロジェクト: dedan/DrosCalciumAnalyse
    answer = raw_input('output folder already exists, overwrite results? (y/n): ')
    if not answer == 'y':
        print 'abort run, output folder contains files'
        sys.exit()
print 'results are written to : %s' % save_base_path

total_resp = []
for prefix in config['prefixes']:

    filelist = glob.glob(os.path.join(config['data_path'], prefix) + '*.json')
    colorlist = {}

    # use only the n_best animals --> most stable odors in common
    if config['n_best']:
        res = pickle.load(open(os.path.join(config['data_path'], config['load_path'], 'thres_res.pckl')))
        best = utils.select_n_channels(res[prefix][config['choose_threshold']], config['n_best'])
        filelist = [filelist[i] for i in best]

    #create lists to collect results
    all_sel_modes, all_sel_modes_condensed, all_raw = [], [], []
    baselines, all_stimulifilter = [], []

    filelist = filelist[0:2]
    for file_ind, filename in enumerate(filelist):

        print prefix, filename
        meas_path = os.path.splitext(filename)[0]
        fname = os.path.basename(meas_path)
        plot_name_base = os.path.join(plots_folder, fname)

        #assign each file a color:
コード例 #3
0
    tmp_filelist = []
    for filename in filelist:
        info = json.load(open(filename))
        print "checking file: ", filename
        if 'bad_data' in info:
            print 'skip this file: bad_data flag found'
            continue
        else:
            tmp_filelist.append(filename)
    filelist = tmp_filelist

    colorlist, allodors = {}, []

    # use only the n_best animals --> most stable odors in common
    res = pickle.load(open(os.path.join(data_path, loadfolder, 'thres_res.pckl')))
    best = utils.select_n_channels(res[prefix][selection_thres], n_best)
    filelist = [filelist[i] for i in best]

    for i in range(-1, len(filelist)):

        if i == -1:
            filelist_fold = filelist
            save_name = prefix + '_all'
        else:
            filelist_fold = [filelist[j] for j in range(len(filelist)) if j != i]
            name_list = [os.path.splitext(os.path.basename(f))[0] for f in filelist_fold]
            name_list = [f.split('_')[1] for f in name_list]
            save_name = prefix + "_" + "_".join(sorted(name_list))
            save_name = save_name + "-" + os.path.splitext(os.path.basename(filelist[i]))[0]
        print save_name