Beispiel #1
0
def create_roc_report(file_prefix,
                      num_groups,
                      contrast_range,
                      num_trials,
                      reports_dir,
                      regenerate_plot=True):
    num_extra_trials = 10
    roc_report = Struct()
    roc_report.auc = get_auc(file_prefix, contrast_range, num_trials,
                             num_extra_trials, num_groups)
    roc_report.auc_single_option = []
    roc_url = 'img/roc.png'
    fname = os.path.join(reports_dir, roc_url)
    roc_report.roc_url = roc_url
    if regenerate_plot or not os.path.exists(fname):
        fig = plt.figure()
        for i in range(num_groups):
            roc = get_roc_single_option(file_prefix, contrast_range,
                                        num_trials, num_extra_trials, i)
            plt.plot(roc[:, 0], roc[:, 1], 'x-', label='option %d' % i)
            roc_report.auc_single_option.append(
                get_auc_single_option(file_prefix, contrast_range, num_trials,
                                      num_extra_trials, i))
        plt.plot([0, 1], [0, 1], '--')
        plt.xlabel('False Positive Rate')
        plt.ylabel('True Positive Rate')
        save_to_png(fig, fname)
        save_to_eps(fig, os.path.join(reports_dir, 'img/roc.eps'))
        plt.close()
    return roc_report
Beispiel #2
0
def plot_roc(data_dir, num_groups, trial_duration, num_trials, p_b_e,p_x_e,p_e_e,p_e_i,p_i_i,p_i_e,num_extra_trials=10):
    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' %\
              (num_groups, trial_duration, p_b_e, p_x_e, p_e_e, p_e_i, p_i_i, p_i_e)
    file_prefix=os.path.join(data_dir,file_desc)

    fig=plt.figure()
    for i in range(num_groups):
        roc=get_roc_single_option(file_prefix, num_trials, num_extra_trials, i)
        plt.plot(roc[:,0],roc[:,1],'x-',label='option %d' % i)
    plt.plot([0,1],[0,1],'--')
    plt.xlabel('False Positive Rate')
    plt.ylabel('True Positive Rate')
    plt.show()
Beispiel #3
0
def create_roc_report(file_prefix, num_groups, contrast_range, num_trials, reports_dir, regenerate_plot=True):
    num_extra_trials=10
    roc_report=Struct()
    roc_report.auc=get_auc(file_prefix, contrast_range, num_trials, num_extra_trials, num_groups)
    roc_report.auc_single_option=[]
    roc_url = 'img/roc.png'
    fname=os.path.join(reports_dir, roc_url)
    roc_report.roc_url=roc_url
    if regenerate_plot or not os.path.exists(fname):
        fig=plt.figure()
        for i in range(num_groups):
            roc=get_roc_single_option(file_prefix, contrast_range, num_trials, num_extra_trials, i)
            plt.plot(roc[:,0],roc[:,1],'x-',label='option %d' % i)
            roc_report.auc_single_option.append(get_auc_single_option(file_prefix, contrast_range, num_trials, num_extra_trials, i))
        plt.plot([0,1],[0,1],'--')
        plt.xlabel('False Positive Rate')
        plt.ylabel('True Positive Rate')
        save_to_png(fig, fname)
        save_to_eps(fig, os.path.join(reports_dir, 'img/roc.eps'))
        plt.close()
    return roc_report
Beispiel #4
0
def plot_roc(data_dir,
             num_groups,
             trial_duration,
             num_trials,
             p_b_e,
             p_x_e,
             p_e_e,
             p_e_i,
             p_i_i,
             p_i_e,
             num_extra_trials=10):
    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' %\
              (num_groups, trial_duration, p_b_e, p_x_e, p_e_e, p_e_i, p_i_i, p_i_e)
    file_prefix = os.path.join(data_dir, file_desc)

    fig = plt.figure()
    for i in range(num_groups):
        roc = get_roc_single_option(file_prefix, num_trials, num_extra_trials,
                                    i)
        plt.plot(roc[:, 0], roc[:, 1], 'x-', label='option %d' % i)
    plt.plot([0, 1], [0, 1], '--')
    plt.xlabel('False Positive Rate')
    plt.ylabel('True Positive Rate')
    plt.show()