Esempio n. 1
0
def create_all_reports(data_dir,
                       num_groups,
                       trial_duration,
                       p_b_e_range,
                       p_x_e_range,
                       p_e_e_range,
                       p_e_i_range,
                       p_i_i_range,
                       p_i_e_range,
                       contrast_range,
                       num_trials,
                       e_desc,
                       base_report_dir,
                       regenerate_network_plots=True,
                       regenerate_trial_plots=True,
                       smooth_missing_params=False,
                       summary_filename='wta_network_summary.h5'):

    make_report_dirs(base_report_dir)

    summary_data = SummaryData(num_groups=num_groups,
                               num_trials=num_trials,
                               trial_duration=trial_duration,
                               p_b_e_range=p_b_e_range,
                               p_x_e_range=p_x_e_range,
                               p_e_e_range=p_e_e_range,
                               p_e_i_range=p_e_i_range,
                               p_i_i_range=p_i_i_range,
                               p_i_e_range=p_i_e_range)

    bc_slope_dict = {}
    bc_intercept_dict = {}
    bc_r_sqr_dict = {}
    auc_dict = {}
    bfr_slope_dict = {}
    bfr_intercept_dict = {}
    bfr_r_sqr_dict = {}

    param_combos = get_tested_param_combos(data_dir, num_groups,
                                           trial_duration, contrast_range,
                                           num_trials, e_desc)

    report_info = Struct()
    report_info.edesc = e_desc
    report_info.roc_auc = {}
    report_info.bc_slope = {}
    report_info.bc_intercept = {}
    report_info.bc_r_sqr = {}
    report_info.bfr_slope = {}
    report_info.bfr_intercept = {}
    report_info.bfr_r_sqr = {}

    for (p_b_e, p_x_e, p_e_e, p_e_i, p_i_i, p_i_e) in param_combos:
        if p_b_e in p_b_e_range and p_x_e in p_x_e_range and p_e_e in p_e_e_range and p_e_i in p_e_i_range and p_i_i in p_i_i_range and p_i_e in p_i_e_range:
            i = p_b_e_range.index(round(p_b_e, 3))
            j = p_x_e_range.index(round(p_x_e, 3))
            k = p_e_e_range.index(round(p_e_e, 3))
            l = p_e_i_range.index(round(p_e_i, 3))
            m = p_i_i_range.index(round(p_i_i, 3))
            n = p_i_e_range.index(round(p_i_e, 3))

            file_desc='wta.groups.%d.duration.%0.3f.p_b_e.%0.3f.p_x_e.%0.3f.p_e_e.%0.3f.p_e_i.%0.3f.p_i_i.%0.3f.p_i_e.%0.3f.%s' %\
                      (num_groups, trial_duration, p_b_e, p_x_e, p_e_e, p_e_i, p_i_i, p_i_e, e_desc)
            file_prefix = os.path.join(data_dir, file_desc)
            reports_dir = os.path.join(base_report_dir, file_desc)
            if all_trials_exist(file_prefix, contrast_range, num_trials):
                print('Creating report for %s' % file_desc)
                wta_report = create_wta_network_report(
                    file_prefix,
                    contrast_range,
                    num_trials,
                    reports_dir,
                    e_desc,
                    regenerate_network_plots=regenerate_network_plots,
                    regenerate_trial_plots=regenerate_trial_plots)

                if not (i, j, k, l, m, n) in bc_slope_dict:
                    bc_slope_dict[(i, j, k, l, m, n)] = []
                bc_slope_dict[(i, j, k, l, m,
                               n)].append(wta_report.bold.bold_contrast_slope)
                if not (i, j, k, l, m, n) in bc_intercept_dict:
                    bc_intercept_dict[(i, j, k, l, m, n)] = []
                bc_intercept_dict[(i, j, k, l, m, n)].append(
                    wta_report.bold.bold_contrast_intercept)
                if not (i, j, k, l, m, n) in bc_r_sqr_dict:
                    bc_r_sqr_dict[(i, j, k, l, m, n)] = []
                bc_r_sqr_dict[(i, j, k, l, m,
                               n)].append(wta_report.bold.bold_contrast_r_sqr)

                if not (i, j, k, l, m, n) in auc_dict:
                    auc_dict[(i, j, k, l, m, n)] = []
                auc_dict[(i, j, k, l, m, n)].append(wta_report.roc.auc)

                if not (i, j, k, l, m, n) in bfr_slope_dict:
                    bfr_slope_dict[(i, j, k, l, m, n)] = []
                bfr_slope_dict[(i, j, k, l, m, n)].append(
                    wta_report.bold.bold_firing_rate_slope)
                if not (i, j, k, l, m, n) in bfr_intercept_dict:
                    bfr_intercept_dict[(i, j, k, l, m, n)] = []
                bfr_intercept_dict[(i, j, k, l, m, n)].append(
                    wta_report.bold.bold_firing_rate_intercept)
                if not (i, j, k, l, m, n) in bfr_r_sqr_dict:
                    bfr_r_sqr_dict[(i, j, k, l, m, n)] = []
                bfr_r_sqr_dict[(i, j, k, l, m, n)].append(
                    wta_report.bold.bold_firing_rate_r_sqr)

                report_info.roc_auc[(p_b_e, p_x_e, p_e_e, p_e_i, p_i_i,
                                     p_i_e)] = wta_report.roc.auc
                report_info.bc_slope[(
                    p_b_e, p_x_e, p_e_e, p_e_i, p_i_i,
                    p_i_e)] = wta_report.bold.bold_contrast_slope
                report_info.bc_intercept[(
                    p_b_e, p_x_e, p_e_e, p_e_i, p_i_i,
                    p_i_e)] = wta_report.bold.bold_contrast_intercept
                report_info.bc_r_sqr[(
                    p_b_e, p_x_e, p_e_e, p_e_i, p_i_i,
                    p_i_e)] = wta_report.bold.bold_contrast_r_sqr
                report_info.bfr_slope[(
                    p_b_e, p_x_e, p_e_e, p_e_i, p_i_i,
                    p_i_e)] = wta_report.bold.bold_firing_rate_slope
                report_info.bfr_intercept[(
                    p_b_e, p_x_e, p_e_e, p_e_i, p_i_i,
                    p_i_e)] = wta_report.bold.bold_firing_rate_intercept
                report_info.bfr_r_sqr[(
                    p_b_e, p_x_e, p_e_e, p_e_i, p_i_i,
                    p_i_e)] = wta_report.bold.bold_firing_rate_r_sqr
            else:
                report_info.roc_auc[(p_b_e, p_x_e, p_e_e, p_e_i, p_i_i,
                                     p_i_e)] = 0
                report_info.bc_slope[(p_b_e, p_x_e, p_e_e, p_e_i, p_i_i,
                                      p_i_e)] = 0
                report_info.bc_intercept[(p_b_e, p_x_e, p_e_e, p_e_i, p_i_i,
                                          p_i_e)] = 0
                report_info.bc_r_sqr[(p_b_e, p_x_e, p_e_e, p_e_i, p_i_i,
                                      p_i_e)] = 0
                report_info.bfr_slope[(p_b_e, p_x_e, p_e_e, p_e_i, p_i_i,
                                       p_i_e)] = 0
                report_info.bfr_intercept[(p_b_e, p_x_e, p_e_e, p_e_i, p_i_i,
                                           p_i_e)] = 0
                report_info.brf_r_sqr[(p_b_e, p_x_e, p_e_e, p_e_i, p_i_i,
                                       p_i_e)] = 0

    report_info.num_groups = num_groups
    report_info.trial_duration = trial_duration
    report_info.num_trials = num_trials
    report_info.p_b_e_range = p_b_e_range
    report_info.p_x_e_range = p_x_e_range
    report_info.p_e_e_range = p_e_e_range
    report_info.p_e_i_range = p_e_i_range
    report_info.p_i_i_range = p_i_i_range
    report_info.p_i_e_range = p_i_e_range

    summary_data.fill(auc_dict,
                      bc_slope_dict,
                      bc_intercept_dict,
                      bc_r_sqr_dict,
                      bfr_slope_dict,
                      bfr_intercept_dict,
                      bfr_r_sqr_dict,
                      smooth_missing_params=smooth_missing_params)

    summary_data.write_to_file(os.path.join(base_report_dir, summary_filename))

    bc_bayes_analysis = run_bayesian_analysis(
        summary_data.auc, summary_data.bc_slope, summary_data.bc_intercept,
        summary_data.bc_r_sqr, num_trials, p_b_e_range, p_e_e_range,
        p_e_i_range, p_i_e_range, p_i_i_range, p_x_e_range)

    bfr_bayes_analysis = run_bayesian_analysis(
        summary_data.auc, summary_data.bfr_slope, summary_data.bfr_intercept,
        summary_data.bfr_r_sqr, num_trials, p_b_e_range, p_e_e_range,
        p_e_i_range, p_i_e_range, p_i_i_range, p_x_e_range)

    bc_base_dir = os.path.join(base_report_dir, 'bold-contrast')
    make_report_dirs(bc_base_dir)
    render_summary_report(bc_base_dir, bc_bayes_analysis, p_b_e_range,
                          p_e_e_range, p_e_i_range, p_i_e_range, p_i_i_range,
                          p_x_e_range, report_info)

    bfr_base_dir = os.path.join(base_report_dir, 'bold-firing_rate')
    make_report_dirs(bfr_base_dir)
    render_summary_report(bfr_base_dir, bfr_bayes_analysis, p_b_e_range,
                          p_e_e_range, p_e_i_range, p_i_e_range, p_i_i_range,
                          p_x_e_range, report_info)
Esempio n. 2
0
def create_summary_report(summary_file_name, base_report_dir, e_desc):
    make_report_dirs(base_report_dir)

    summary_data=SummaryData()
    summary_data.read_from_file(summary_file_name)

    report_info=Struct()
    report_info.edesc=e_desc
    report_info.roc_auc={}
    report_info.io_slope={}
    report_info.io_intercept={}
    report_info.io_r_sqr={}
    report_info.bc_slope={}
    report_info.bc_intercept={}
    report_info.bc_r_sqr={}
    report_info.bfr_slope={}
    report_info.bfr_intercept={}
    report_info.bfr_r_sqr={}
    for i,p_b_e in enumerate(summary_data.p_b_e_range):
        for j,p_x_e in enumerate(summary_data.p_x_e_range):
            for k,p_e_e in enumerate(summary_data.p_e_e_range):
                for l,p_e_i in enumerate(summary_data.p_e_i_range):
                    for m,p_i_i in enumerate(summary_data.p_i_i_range):
                        for n,p_i_e in enumerate(summary_data.p_i_e_range):
                            if summary_data.auc[i,j,k,l,m,n]>0:
                                report_info.roc_auc[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=summary_data.auc[i,j,k,l,m,n]
                                report_info.bc_slope[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=summary_data.bc_slope[i,j,k,l,m,n]
                                report_info.bc_intercept[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=summary_data.bc_intercept[i,j,k,l,m,n]
                                report_info.bc_r_sqr[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=summary_data.bc_r_sqr[i,j,k,l,m,n]
                                report_info.bfr_slope[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=summary_data.bfr_slope[i,j,k,l,m,n]
                                report_info.bfr_intercept[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=summary_data.bfr_intercept[i,j,k,l,m,n]
                                report_info.bfr_r_sqr[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=summary_data.bfr_r_sqr[i,j,k,l,m,n]
                            else:
                                report_info.roc_auc[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=0
                                report_info.bc_slope[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=0
                                report_info.bc_intercept[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=0
                                report_info.bc_r_sqr[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=0
                                report_info.bfr_slope[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=0
                                report_info.bfr_intercept[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=0
                                report_info.bfr_r_sqr[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=0

    report_info.num_groups=summary_data.num_groups
    report_info.trial_duration=summary_data.trial_duration
    report_info.num_trials=summary_data.num_trials
    report_info.p_b_e_range=summary_data.p_b_e_range
    report_info.p_x_e_range=summary_data.p_x_e_range
    report_info.p_e_e_range=summary_data.p_e_e_range[:-1]
    report_info.p_e_i_range=summary_data.p_e_i_range
    report_info.p_i_i_range=summary_data.p_i_i_range
    report_info.p_i_e_range=summary_data.p_i_e_range

    bc_bayes_analysis=run_bayesian_analysis(summary_data.auc, summary_data.bc_slope, summary_data.bc_intercept,
        summary_data.bc_r_sqr, summary_data.num_trials, summary_data.p_b_e_range, summary_data.p_e_e_range,
        summary_data.p_e_i_range, summary_data.p_i_e_range, summary_data.p_i_i_range, summary_data.p_x_e_range)

    bfr_bayes_analysis=run_bayesian_analysis(summary_data.auc, summary_data.bfr_slope, summary_data.bfr_intercept,
        summary_data.bfr_r_sqr, summary_data.num_trials, summary_data.p_b_e_range, summary_data.p_e_e_range,
        summary_data.p_e_i_range, summary_data.p_i_e_range, summary_data.p_i_i_range, summary_data.p_x_e_range)

    bc_base_dir=os.path.join(base_report_dir, 'bold-contrast')
    make_report_dirs(bc_base_dir)
    render_summary_report(bc_base_dir, bc_bayes_analysis, summary_data.p_b_e_range, summary_data.p_e_e_range,
        summary_data.p_e_i_range, summary_data.p_i_e_range, summary_data.p_i_i_range, summary_data.p_x_e_range,
        report_info)

    bfr_base_dir=os.path.join(base_report_dir, 'bold-firing_rate')
    make_report_dirs(bfr_base_dir)
    render_summary_report(bfr_base_dir, bfr_bayes_analysis, summary_data.p_b_e_range, summary_data.p_e_e_range,
        summary_data.p_e_i_range, summary_data.p_i_e_range, summary_data.p_i_i_range, summary_data.p_x_e_range,
        report_info)
Esempio n. 3
0
def create_all_reports(data_dir, num_groups, trial_duration, p_b_e_range, p_x_e_range, p_e_e_range, p_e_i_range,
                       p_i_i_range, p_i_e_range, contrast_range, num_trials, e_desc, base_report_dir, regenerate_network_plots=True,
                       regenerate_trial_plots=True, smooth_missing_params=False,
                       summary_filename='wta_network_summary.h5'):

    make_report_dirs(base_report_dir)

    summary_data=SummaryData(num_groups=num_groups, num_trials=num_trials, trial_duration=trial_duration,
        p_b_e_range=p_b_e_range, p_x_e_range=p_x_e_range, p_e_e_range=p_e_e_range, p_e_i_range=p_e_i_range,
        p_i_i_range=p_i_i_range, p_i_e_range=p_i_e_range)

    bc_slope_dict={}
    bc_intercept_dict={}
    bc_r_sqr_dict={}
    auc_dict={}
    bfr_slope_dict={}
    bfr_intercept_dict={}
    bfr_r_sqr_dict={}

    param_combos=get_tested_param_combos(data_dir, num_groups, trial_duration, contrast_range, num_trials, e_desc)

    report_info=Struct()
    report_info.edesc=e_desc
    report_info.roc_auc={}
    report_info.bc_slope={}
    report_info.bc_intercept={}
    report_info.bc_r_sqr={}
    report_info.bfr_slope={}
    report_info.bfr_intercept={}
    report_info.bfr_r_sqr={}


    for (p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e) in param_combos:
        if p_b_e in p_b_e_range and p_x_e in p_x_e_range and p_e_e in p_e_e_range and p_e_i in p_e_i_range and p_i_i in p_i_i_range and p_i_e in p_i_e_range:
            i=p_b_e_range.index(round(p_b_e,3))
            j=p_x_e_range.index(round(p_x_e,3))
            k=p_e_e_range.index(round(p_e_e,3))
            l=p_e_i_range.index(round(p_e_i,3))
            m=p_i_i_range.index(round(p_i_i,3))
            n=p_i_e_range.index(round(p_i_e,3))

            file_desc='wta.groups.%d.duration.%0.3f.p_b_e.%0.3f.p_x_e.%0.3f.p_e_e.%0.3f.p_e_i.%0.3f.p_i_i.%0.3f.p_i_e.%0.3f.%s' %\
                      (num_groups, trial_duration, p_b_e, p_x_e, p_e_e, p_e_i, p_i_i, p_i_e, e_desc)
            file_prefix=os.path.join(data_dir,file_desc)
            reports_dir=os.path.join(base_report_dir,file_desc)
            if all_trials_exist(file_prefix, contrast_range, num_trials):
                print('Creating report for %s' % file_desc)
                wta_report=create_wta_network_report(file_prefix, contrast_range, num_trials, reports_dir,
                    e_desc, regenerate_network_plots=regenerate_network_plots, regenerate_trial_plots=regenerate_trial_plots)

                if not (i,j,k,l,m,n) in bc_slope_dict:
                    bc_slope_dict[(i,j,k,l,m,n)]=[]
                bc_slope_dict[(i,j,k,l,m,n)].append(wta_report.bold.bold_contrast_slope)
                if not (i,j,k,l,m,n) in bc_intercept_dict:
                    bc_intercept_dict[(i,j,k,l,m,n)]=[]
                bc_intercept_dict[(i,j,k,l,m,n)].append(wta_report.bold.bold_contrast_intercept)
                if not (i,j,k,l,m,n) in bc_r_sqr_dict:
                    bc_r_sqr_dict[(i,j,k,l,m,n)]=[]
                bc_r_sqr_dict[(i,j,k,l,m,n)].append(wta_report.bold.bold_contrast_r_sqr)

                if not (i,j,k,l,m,n) in auc_dict:
                    auc_dict[(i,j,k,l,m,n)]=[]
                auc_dict[(i,j,k,l,m,n)].append(wta_report.roc.auc)

                if not (i,j,k,l,m,n) in bfr_slope_dict:
                    bfr_slope_dict[(i,j,k,l,m,n)]=[]
                bfr_slope_dict[(i,j,k,l,m,n)].append(wta_report.bold.bold_firing_rate_slope)
                if not (i,j,k,l,m,n) in bfr_intercept_dict:
                    bfr_intercept_dict[(i,j,k,l,m,n)]=[]
                bfr_intercept_dict[(i,j,k,l,m,n)].append(wta_report.bold.bold_firing_rate_intercept)
                if not (i,j,k,l,m,n) in bfr_r_sqr_dict:
                    bfr_r_sqr_dict[(i,j,k,l,m,n)]=[]
                bfr_r_sqr_dict[(i,j,k,l,m,n)].append(wta_report.bold.bold_firing_rate_r_sqr)

                report_info.roc_auc[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=wta_report.roc.auc
                report_info.bc_slope[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=wta_report.bold.bold_contrast_slope
                report_info.bc_intercept[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=wta_report.bold.bold_contrast_intercept
                report_info.bc_r_sqr[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=wta_report.bold.bold_contrast_r_sqr
                report_info.bfr_slope[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=wta_report.bold.bold_firing_rate_slope
                report_info.bfr_intercept[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=wta_report.bold.bold_firing_rate_intercept
                report_info.bfr_r_sqr[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=wta_report.bold.bold_firing_rate_r_sqr
            else:
                report_info.roc_auc[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=0
                report_info.bc_slope[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=0
                report_info.bc_intercept[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=0
                report_info.bc_r_sqr[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=0
                report_info.bfr_slope[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=0
                report_info.bfr_intercept[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=0
                report_info.brf_r_sqr[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=0

    report_info.num_groups=num_groups
    report_info.trial_duration=trial_duration
    report_info.num_trials=num_trials
    report_info.p_b_e_range=p_b_e_range
    report_info.p_x_e_range=p_x_e_range
    report_info.p_e_e_range=p_e_e_range
    report_info.p_e_i_range=p_e_i_range
    report_info.p_i_i_range=p_i_i_range
    report_info.p_i_e_range=p_i_e_range

    summary_data.fill(auc_dict, bc_slope_dict, bc_intercept_dict, bc_r_sqr_dict, bfr_slope_dict, bfr_intercept_dict,
        bfr_r_sqr_dict, smooth_missing_params=smooth_missing_params)

    summary_data.write_to_file(os.path.join(base_report_dir,summary_filename))

    bc_bayes_analysis=run_bayesian_analysis(summary_data.auc, summary_data.bc_slope, summary_data.bc_intercept,
        summary_data.bc_r_sqr, num_trials, p_b_e_range, p_e_e_range, p_e_i_range, p_i_e_range, p_i_i_range, p_x_e_range)

    bfr_bayes_analysis=run_bayesian_analysis(summary_data.auc, summary_data.bfr_slope, summary_data.bfr_intercept,
            summary_data.bfr_r_sqr, num_trials, p_b_e_range, p_e_e_range, p_e_i_range, p_i_e_range, p_i_i_range, p_x_e_range)

    bc_base_dir=os.path.join(base_report_dir, 'bold-contrast')
    make_report_dirs(bc_base_dir)
    render_summary_report(bc_base_dir, bc_bayes_analysis, p_b_e_range, p_e_e_range, p_e_i_range, p_i_e_range,
        p_i_i_range, p_x_e_range, report_info)

    bfr_base_dir=os.path.join(base_report_dir, 'bold-firing_rate')
    make_report_dirs(bfr_base_dir)
    render_summary_report(bfr_base_dir, bfr_bayes_analysis, p_b_e_range, p_e_e_range, p_e_i_range, p_i_e_range,
        p_i_i_range, p_x_e_range, report_info)
Esempio n. 4
0
def create_summary_report(summary_file_name, base_report_dir, e_desc):
    make_report_dirs(base_report_dir)

    summary_data = SummaryData()
    summary_data.read_from_file(summary_file_name)

    report_info = Struct()
    report_info.edesc = e_desc
    report_info.roc_auc = {}
    report_info.io_slope = {}
    report_info.io_intercept = {}
    report_info.io_r_sqr = {}
    report_info.bc_slope = {}
    report_info.bc_intercept = {}
    report_info.bc_r_sqr = {}
    report_info.bfr_slope = {}
    report_info.bfr_intercept = {}
    report_info.bfr_r_sqr = {}
    for i, p_b_e in enumerate(summary_data.p_b_e_range):
        for j, p_x_e in enumerate(summary_data.p_x_e_range):
            for k, p_e_e in enumerate(summary_data.p_e_e_range):
                for l, p_e_i in enumerate(summary_data.p_e_i_range):
                    for m, p_i_i in enumerate(summary_data.p_i_i_range):
                        for n, p_i_e in enumerate(summary_data.p_i_e_range):
                            if summary_data.auc[i, j, k, l, m, n] > 0:
                                report_info.roc_auc[(
                                    p_b_e, p_x_e, p_e_e, p_e_i, p_i_i,
                                    p_i_e)] = summary_data.auc[i, j, k, l, m,
                                                               n]
                                report_info.bc_slope[(
                                    p_b_e, p_x_e, p_e_e, p_e_i, p_i_i,
                                    p_i_e)] = summary_data.bc_slope[i, j, k, l,
                                                                    m, n]
                                report_info.bc_intercept[(
                                    p_b_e, p_x_e, p_e_e, p_e_i, p_i_i,
                                    p_i_e)] = summary_data.bc_intercept[i, j,
                                                                        k, l,
                                                                        m, n]
                                report_info.bc_r_sqr[(
                                    p_b_e, p_x_e, p_e_e, p_e_i, p_i_i,
                                    p_i_e)] = summary_data.bc_r_sqr[i, j, k, l,
                                                                    m, n]
                                report_info.bfr_slope[(
                                    p_b_e, p_x_e, p_e_e, p_e_i, p_i_i,
                                    p_i_e)] = summary_data.bfr_slope[i, j, k,
                                                                     l, m, n]
                                report_info.bfr_intercept[(
                                    p_b_e, p_x_e, p_e_e, p_e_i, p_i_i,
                                    p_i_e)] = summary_data.bfr_intercept[i, j,
                                                                         k, l,
                                                                         m, n]
                                report_info.bfr_r_sqr[(
                                    p_b_e, p_x_e, p_e_e, p_e_i, p_i_i,
                                    p_i_e)] = summary_data.bfr_r_sqr[i, j, k,
                                                                     l, m, n]
                            else:
                                report_info.roc_auc[(p_b_e, p_x_e, p_e_e,
                                                     p_e_i, p_i_i, p_i_e)] = 0
                                report_info.bc_slope[(p_b_e, p_x_e, p_e_e,
                                                      p_e_i, p_i_i, p_i_e)] = 0
                                report_info.bc_intercept[(p_b_e, p_x_e, p_e_e,
                                                          p_e_i, p_i_i,
                                                          p_i_e)] = 0
                                report_info.bc_r_sqr[(p_b_e, p_x_e, p_e_e,
                                                      p_e_i, p_i_i, p_i_e)] = 0
                                report_info.bfr_slope[(p_b_e, p_x_e, p_e_e,
                                                       p_e_i, p_i_i,
                                                       p_i_e)] = 0
                                report_info.bfr_intercept[(p_b_e, p_x_e, p_e_e,
                                                           p_e_i, p_i_i,
                                                           p_i_e)] = 0
                                report_info.bfr_r_sqr[(p_b_e, p_x_e, p_e_e,
                                                       p_e_i, p_i_i,
                                                       p_i_e)] = 0

    report_info.num_groups = summary_data.num_groups
    report_info.trial_duration = summary_data.trial_duration
    report_info.num_trials = summary_data.num_trials
    report_info.p_b_e_range = summary_data.p_b_e_range
    report_info.p_x_e_range = summary_data.p_x_e_range
    report_info.p_e_e_range = summary_data.p_e_e_range[:-1]
    report_info.p_e_i_range = summary_data.p_e_i_range
    report_info.p_i_i_range = summary_data.p_i_i_range
    report_info.p_i_e_range = summary_data.p_i_e_range

    bc_bayes_analysis = run_bayesian_analysis(
        summary_data.auc, summary_data.bc_slope, summary_data.bc_intercept,
        summary_data.bc_r_sqr, summary_data.num_trials,
        summary_data.p_b_e_range, summary_data.p_e_e_range,
        summary_data.p_e_i_range, summary_data.p_i_e_range,
        summary_data.p_i_i_range, summary_data.p_x_e_range)

    bfr_bayes_analysis = run_bayesian_analysis(
        summary_data.auc, summary_data.bfr_slope, summary_data.bfr_intercept,
        summary_data.bfr_r_sqr, summary_data.num_trials,
        summary_data.p_b_e_range, summary_data.p_e_e_range,
        summary_data.p_e_i_range, summary_data.p_i_e_range,
        summary_data.p_i_i_range, summary_data.p_x_e_range)

    bc_base_dir = os.path.join(base_report_dir, 'bold-contrast')
    make_report_dirs(bc_base_dir)
    render_summary_report(bc_base_dir, bc_bayes_analysis,
                          summary_data.p_b_e_range, summary_data.p_e_e_range,
                          summary_data.p_e_i_range, summary_data.p_i_e_range,
                          summary_data.p_i_i_range, summary_data.p_x_e_range,
                          report_info)

    bfr_base_dir = os.path.join(base_report_dir, 'bold-firing_rate')
    make_report_dirs(bfr_base_dir)
    render_summary_report(bfr_base_dir, bfr_bayes_analysis,
                          summary_data.p_b_e_range, summary_data.p_e_e_range,
                          summary_data.p_e_i_range, summary_data.p_i_e_range,
                          summary_data.p_i_i_range, summary_data.p_x_e_range,
                          report_info)
Esempio n. 5
0
def create_bayesian_report(title, num_groups, trial_duration, roc_auc, bc_slope, bc_intercept, bc_r_sqr, evidence,
                           posterior, marginals, p_b_e_range, p_x_e_range, p_e_e_range, p_e_i_range, p_i_i_range,
                           p_i_e_range, file_prefix, reports_dir, edesc, marginal_ylim):
    report_info=Struct()
    report_info.title=title
    report_info.edesc=edesc
    report_info.evidence=evidence
    report_info.roc_auc=roc_auc
    report_info.bc_slope=bc_slope
    report_info.bc_intercept=bc_intercept
    report_info.bc_r_sqr=bc_r_sqr
    report_info.num_groups=num_groups
    report_info.trial_duration=trial_duration
    report_info.p_b_e_range=p_b_e_range
    report_info.p_x_e_range=p_x_e_range
    report_info.p_e_e_range=p_e_e_range
    report_info.p_e_i_range=p_e_i_range
    report_info.p_i_i_range=p_i_i_range
    report_info.p_i_e_range=p_i_e_range

    report_info.posterior={}
    for i,p_b_e in enumerate(p_b_e_range):
        for j,p_x_e in enumerate(p_x_e_range):
            for k,p_e_e in enumerate(p_e_e_range):
                for l,p_e_i in enumerate(p_e_i_range):
                    for m,p_i_i in enumerate(p_i_i_range):
                        for n,p_i_e in enumerate(p_i_e_range):
                            if posterior[i,j,k,l,m,n]>0:
                                report_info.posterior[(p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e)]=posterior[i,j,k,l,m,n]
    report_info.marginal_prior_p_b_e_url,\
    report_info.marginal_likelihood_p_b_e_url,\
    report_info.marginal_posterior_p_b_e_url=render_marginal_report('p_b_e', p_b_e_range,
        marginals.prior_p_b_e, marginals.likelihood_p_b_e, marginals.posterior_p_b_e, file_prefix, reports_dir, marginal_ylim)

    report_info.marginal_prior_p_x_e_url,\
    report_info.marginal_likelihood_p_x_e_url,\
    report_info.marginal_posterior_p_x_e_url=render_marginal_report('p_x_e', p_x_e_range,
        marginals.prior_p_x_e, marginals.likelihood_p_x_e, marginals.posterior_p_x_e, file_prefix, reports_dir, marginal_ylim)

    report_info.marginal_prior_p_e_e_url,\
    report_info.marginal_likelihood_p_e_e_url,\
    report_info.marginal_posterior_p_e_e_url=render_marginal_report('p_e_e', p_e_e_range,
        marginals.prior_p_e_e, marginals.likelihood_p_e_e, marginals.posterior_p_e_e, file_prefix, reports_dir, marginal_ylim)

    report_info.marginal_prior_p_e_i_url,\
    report_info.marginal_likelihood_p_e_i_url,\
    report_info.marginal_posterior_p_e_i_url=render_marginal_report('p_e_i', p_e_i_range,
        marginals.prior_p_e_i, marginals.likelihood_p_e_i, marginals.posterior_p_e_i, file_prefix, reports_dir, marginal_ylim)

    report_info.marginal_prior_p_i_i_url,\
    report_info.marginal_likelihood_p_i_i_url,\
    report_info.marginal_posterior_p_i_i_url=render_marginal_report('p_i_i', p_i_i_range,
        marginals.prior_p_i_i, marginals.likelihood_p_i_i, marginals.posterior_p_i_i, file_prefix, reports_dir, marginal_ylim)

    report_info.marginal_prior_p_i_e_url,\
    report_info.marginal_likelihood_p_i_e_url,\
    report_info.marginal_posterior_p_i_e_url=render_marginal_report('p_i_e', p_i_e_range,
        marginals.prior_p_i_e, marginals.likelihood_p_i_e, marginals.posterior_p_i_e, file_prefix, reports_dir, marginal_ylim)


    report_info.joint_marginal_p_b_e_p_x_e_url = render_joint_marginal_report('p_b_e', 'p_x_e', p_b_e_range, p_x_e_range,
        marginals.posterior_p_b_e_p_x_e, file_prefix, reports_dir)

    report_info.joint_marginal_p_e_e_p_e_i_url = render_joint_marginal_report('p_e_e', 'p_e_i', p_e_e_range, p_e_i_range,
        marginals.posterior_p_e_e_p_e_i, file_prefix, reports_dir)

    report_info.joint_marginal_p_e_e_p_i_i_url = render_joint_marginal_report('p_e_e', 'p_i_i', p_e_e_range, p_i_i_range,
        marginals.posterior_p_e_e_p_i_i, file_prefix, reports_dir)

    report_info.joint_marginal_p_e_e_p_i_e_url = render_joint_marginal_report('p_e_e', 'p_i_e', p_e_e_range, p_i_e_range,
        marginals.posterior_p_e_e_p_i_e, file_prefix, reports_dir)

    report_info.joint_marginal_p_e_i_p_i_i_url = render_joint_marginal_report('p_e_i', 'p_i_i', p_e_i_range, p_i_i_range,
        marginals.posterior_p_e_i_p_i_i, file_prefix, reports_dir)

    report_info.joint_marginal_p_e_i_p_i_e_url = render_joint_marginal_report('p_e_i', 'p_i_e', p_e_i_range, p_i_e_range,
        marginals.posterior_p_e_i_p_i_e, file_prefix, reports_dir)

    report_info.joint_marginal_p_i_i_p_i_e_url = render_joint_marginal_report('p_i_i', 'p_i_e', p_i_i_range, p_i_e_range,
        marginals.posterior_p_i_i_p_i_e, file_prefix, reports_dir)

    return report_info
Esempio n. 6
0
def create_bayesian_report(title, num_groups, trial_duration, roc_auc,
                           bc_slope, bc_intercept, bc_r_sqr, evidence,
                           posterior, marginals, p_b_e_range, p_x_e_range,
                           p_e_e_range, p_e_i_range, p_i_i_range, p_i_e_range,
                           file_prefix, reports_dir, edesc, marginal_ylim):
    report_info = Struct()
    report_info.title = title
    report_info.edesc = edesc
    report_info.evidence = evidence
    report_info.roc_auc = roc_auc
    report_info.bc_slope = bc_slope
    report_info.bc_intercept = bc_intercept
    report_info.bc_r_sqr = bc_r_sqr
    report_info.num_groups = num_groups
    report_info.trial_duration = trial_duration
    report_info.p_b_e_range = p_b_e_range
    report_info.p_x_e_range = p_x_e_range
    report_info.p_e_e_range = p_e_e_range
    report_info.p_e_i_range = p_e_i_range
    report_info.p_i_i_range = p_i_i_range
    report_info.p_i_e_range = p_i_e_range

    report_info.posterior = {}
    for i, p_b_e in enumerate(p_b_e_range):
        for j, p_x_e in enumerate(p_x_e_range):
            for k, p_e_e in enumerate(p_e_e_range):
                for l, p_e_i in enumerate(p_e_i_range):
                    for m, p_i_i in enumerate(p_i_i_range):
                        for n, p_i_e in enumerate(p_i_e_range):
                            if posterior[i, j, k, l, m, n] > 0:
                                report_info.posterior[(p_b_e, p_x_e, p_e_e,
                                                       p_e_i, p_i_i,
                                                       p_i_e)] = posterior[i,
                                                                           j,
                                                                           k,
                                                                           l,
                                                                           m,
                                                                           n]
    report_info.marginal_prior_p_b_e_url,\
    report_info.marginal_likelihood_p_b_e_url,\
    report_info.marginal_posterior_p_b_e_url=render_marginal_report('p_b_e', p_b_e_range,
        marginals.prior_p_b_e, marginals.likelihood_p_b_e, marginals.posterior_p_b_e, file_prefix, reports_dir, marginal_ylim)

    report_info.marginal_prior_p_x_e_url,\
    report_info.marginal_likelihood_p_x_e_url,\
    report_info.marginal_posterior_p_x_e_url=render_marginal_report('p_x_e', p_x_e_range,
        marginals.prior_p_x_e, marginals.likelihood_p_x_e, marginals.posterior_p_x_e, file_prefix, reports_dir, marginal_ylim)

    report_info.marginal_prior_p_e_e_url,\
    report_info.marginal_likelihood_p_e_e_url,\
    report_info.marginal_posterior_p_e_e_url=render_marginal_report('p_e_e', p_e_e_range,
        marginals.prior_p_e_e, marginals.likelihood_p_e_e, marginals.posterior_p_e_e, file_prefix, reports_dir, marginal_ylim)

    report_info.marginal_prior_p_e_i_url,\
    report_info.marginal_likelihood_p_e_i_url,\
    report_info.marginal_posterior_p_e_i_url=render_marginal_report('p_e_i', p_e_i_range,
        marginals.prior_p_e_i, marginals.likelihood_p_e_i, marginals.posterior_p_e_i, file_prefix, reports_dir, marginal_ylim)

    report_info.marginal_prior_p_i_i_url,\
    report_info.marginal_likelihood_p_i_i_url,\
    report_info.marginal_posterior_p_i_i_url=render_marginal_report('p_i_i', p_i_i_range,
        marginals.prior_p_i_i, marginals.likelihood_p_i_i, marginals.posterior_p_i_i, file_prefix, reports_dir, marginal_ylim)

    report_info.marginal_prior_p_i_e_url,\
    report_info.marginal_likelihood_p_i_e_url,\
    report_info.marginal_posterior_p_i_e_url=render_marginal_report('p_i_e', p_i_e_range,
        marginals.prior_p_i_e, marginals.likelihood_p_i_e, marginals.posterior_p_i_e, file_prefix, reports_dir, marginal_ylim)

    report_info.joint_marginal_p_b_e_p_x_e_url = render_joint_marginal_report(
        'p_b_e', 'p_x_e', p_b_e_range, p_x_e_range,
        marginals.posterior_p_b_e_p_x_e, file_prefix, reports_dir)

    report_info.joint_marginal_p_e_e_p_e_i_url = render_joint_marginal_report(
        'p_e_e', 'p_e_i', p_e_e_range, p_e_i_range,
        marginals.posterior_p_e_e_p_e_i, file_prefix, reports_dir)

    report_info.joint_marginal_p_e_e_p_i_i_url = render_joint_marginal_report(
        'p_e_e', 'p_i_i', p_e_e_range, p_i_i_range,
        marginals.posterior_p_e_e_p_i_i, file_prefix, reports_dir)

    report_info.joint_marginal_p_e_e_p_i_e_url = render_joint_marginal_report(
        'p_e_e', 'p_i_e', p_e_e_range, p_i_e_range,
        marginals.posterior_p_e_e_p_i_e, file_prefix, reports_dir)

    report_info.joint_marginal_p_e_i_p_i_i_url = render_joint_marginal_report(
        'p_e_i', 'p_i_i', p_e_i_range, p_i_i_range,
        marginals.posterior_p_e_i_p_i_i, file_prefix, reports_dir)

    report_info.joint_marginal_p_e_i_p_i_e_url = render_joint_marginal_report(
        'p_e_i', 'p_i_e', p_e_i_range, p_i_e_range,
        marginals.posterior_p_e_i_p_i_e, file_prefix, reports_dir)

    report_info.joint_marginal_p_i_i_p_i_e_url = render_joint_marginal_report(
        'p_i_i', 'p_i_e', p_i_i_range, p_i_e_range,
        marginals.posterior_p_i_i_p_i_e, file_prefix, reports_dir)

    return report_info