コード例 #1
0
    def criteria(self, hit=False, fa=False):
        data = self.data
        amnesic_fa = data.iloc[0][::-1]
        control_fa = data.iloc[3][::-1]
        amnesic_fa = amnesic_fa[:-1]
        control_fa = control_fa[:-1]

        amnesic_hit = data.iloc[1][::-1]
        control_hit = data.iloc[4][::-1]
        amnesic_hit = amnesic_hit[:-1]
        control_hit = control_hit[:-1]

        if fa:
            fig, ax = plt.subplots(1, 1)
            ax.plot(np.arange(1, 7, 1), np.cumsum(amnesic_fa), 'ro-')
            ax.plot(np.arange(1, 7, 1), np.cumsum(control_fa), 'go-')
            ax.plot()
            ax.set_title(self.name, fontsize=16)
            ax.set_ylabel('False alarms', fontsize=16)
            ax.set_xlabel('Threshold', fontsize=16)
            set_aspect(ax)

        if hit:
            fig, ax = plt.subplots(1, 1)
            ax.plot(np.arange(1, 7, 1), np.cumsum(amnesic_hit), 'ro-')
            ax.plot(np.arange(1, 7, 1), np.cumsum(control_hit), 'go-')
            ax.set_title(self.name, fontsize=16)
            ax.set_ylabel('Hits', fontsize=16)
            ax.set_xlabel('Threshold', fontsize=16)
            set_aspect(ax)
コード例 #2
0
 def F_and_R(self):
     data = self.data
     F_time = normalize_F(data.iloc[:5][:]['F'])
     R_time = data.iloc[:5][:]['R']
     cond = data.iloc[:5][:]['Condition']
     fig, ax = plt.subplots(1, 1)
     ax.plot(F_time, 'go-', label='F')
     ax.plot(R_time, 'bo-', label='R')
     plt.xticks(range(len(cond)), cond, fontsize=14)
     ax.legend(prop={'size': 15})
     ax.set_title(self.name, fontsize=15)
     set_aspect(ax)
コード例 #3
0
    def plot_results(self, experiment):
        fig, axes = plt.subplots(1, 3, figsize=(10, 10))
        hits = self.data[experiment]['hits']
        fa = self.data[experiment]['fa']
        markers = ['go--', 'ro--', 'go-', 'ro-']
        for ind, item in enumerate(self.keys):
            axes[0].plot(hits[item], markers[ind], label=item)
            axes[1].plot(fa[item], markers[ind], label=item)
            axes[2].plot(fa[item], hits[item], markers[ind], label=item)


#        axis_default(axes[0],'Criterion','Hit rate',legend=True,limit=[[0,len(hits[item])],[0,1]])
#        axis_default(axes[1],'Criterion','False alarm rate',limit=[[0,len(fa[item])],[0,1]],legend=False)
#        axis_default(axes[2],'False alarm rate','Hit rate',limit=[[0,1],[0,1]],legend=False)
        [set_aspect(ax) for ax in axes]
        fig.tight_layout()
        fig.suptitle('Ratcliff et al. 1992 ' + experiment, fontsize=15, y=.75)
コード例 #4
0
 def plot_experiment(self, experiment):
     experiment -= 1
     exp = self.experiments[experiment]
     fig, axes = plt.subplots(1, 2, figsize=(8, 8))
     hit = self.data.loc[experiment, self.hit_keys]
     fa = self.data.loc[experiment, self.fa_keys]
     hit.plot.bar(ax=axes[0],
                  x='lab',
                  y='val',
                  rot=0,
                  colors=['g', 'g', 'crimson', 'crimson'])
     fa.plot.bar(ax=axes[1],
                 x='lab',
                 y='val',
                 rot=0,
                 colors=['g', 'g', 'crimson', 'crimson'])
     #        axis_default(axes[0],' ','Hit rate',legend=False,limit=[[None,None],[0,1]],ticks=False)
     #        axis_default(axes[1],' ','False alarm rate',legend=False,limit=[[None,None],[0,1]],ticks=False)
     [set_aspect(ax) for ax in axes]
     fig.tight_layout()
     fig.suptitle(self.name + ': experiment ' + str(exp) + '*',
                  fontsize=15,
                  y=.75)
     plt.gcf().text(0.1, .2, '*' + self.notes[experiment], fontsize=14)
コード例 #5
0
#fits=['Rn:0','Rn:0','Rn:0','Rn:0']
fits = ['Full', 'Rn:0', 'Full', 'Full']
fig, ax = plt.subplots(1, 1)
m = -1
o = 0
nn = 0
for index, simID in enumerate(IDs):
    params = pickle.load(open(path1 + '/Log/metadata_' + simID + '.pkl', "rb"))
    params.data_dir = update_path(path1, params.data_dir)
    params.data_dir = "/".join(params.data_dir.split(os.sep)[:9]) + '/'
    params.path = update_path(path1, params.path)
    mat = matlab(params)
    data, conds = mat.load_dpsd(fit=fits[index])
    ax.plot(data[o][m]['fa'][0][nn],
            data[o][m]['hits'][0][nn],
            'o',
            color=colors[index],
            alpha=0.6)
    #    ax.plot(data[o][0]['fa'][nn][0],data[o][0]['hits'][nn][0],'ro')
    ax.plot(data[o][m]['roc_fa'][m][:, nn],
            data[o][m]['roc_hit'][0][:, nn],
            'b',
            color=colors[index],
            linestyle=markers[index],
            label='Set ' + labels[index])
    #    ax.plot(data[o][0]['roc_fa'][0][:,nn],data[o][0]['roc_hit'][0][:,nn],'r',linestyle=markers[index])
    ax.plot([0, 1], [0, 1], 'k--')
    set_aspect(ax)
    axis_default(ax, 'False alarm rate', 'Hit rate', legend=True)
fig.savefig('related_unrelated.eps')
コード例 #6
0
    lures=[]
    for ind, folder in enumerate(folders):
        directory=input_dir+folder+'/'
        filenames=sorted([item for item in os.listdir(directory) if item[-3:]=='pkl'])
        data=[pd.read_pickle(directory+file) for file in filenames]
        targ=get_data(data[m],'target',o,nn)
        lure=get_data(data[m],'lure',o,nn)
        targs.append(targ)
        lures.append(lure)
        hit=calc_rates(targ,params.N_t)
        fa=calc_rates(lure,params.N_t)
        ax.plot(fa,hit,'o-',label=folder)
    ax.set_xlim(0,1)
    ax.set_ylim(0,1)
    ax.legend()
    set_aspect(ax)
    
    targs_average=np.mean(targs[:10],axis=0)
    lure_average=np.mean(lures[:10],axis=0)
    hit_average=calc_rates(targs_average,params.N_t)
    fa_average=calc_rates(lure_average,params.N_t)
    axis.plot(fa_average,hit_average,'o-')
    axis.plot([0,1],[0,1],'k--')
    axis.set_xlim(0,1)
    axis.set_ylim(0,1)
    set_aspect(axis)
sys.exit()
   
    
#figure,axis=plt.subplots(1,1)
#for noise_ind in range(len(params.noise)):
コード例 #7
0
strong_hits = [.38, .60, .64, .70, .82]
strong_sp = [.14, .30, .36, .43, .64]
strong_ur = [.02, .06, .09, .19, .41]

fig, axes = plt.subplots(1, 3)
axes[0].plot(weak_hits, 'ro-')
axes[0].plot(strong_hits, 'go-')
axes[1].plot(weak_sp, 'ro-')
axes[1].plot(strong_sp, 'go-')
axes[2].plot(weak_ur, 'ro-')
axes[2].plot(strong_ur, 'go-')
axes[0].set_title('Hit rates')
axes[1].set_title('SP false alarms')
axes[2].set_title('UL false alarms')

[set_aspect(ax) for ax in axes]
fig.tight_layout()

fig1, axes1 = plt.subplots(1, 3)
axes1[0].plot(weak_ur, weak_hits, 'ro-')
axes1[0].plot(strong_ur, strong_hits, 'go-')
axes1[1].plot(weak_sp, weak_hits, 'ro-')
axes1[1].plot(strong_sp, strong_hits, 'go-')
axes1[2].plot(weak_ur, weak_sp, 'ro-')
axes1[2].plot(strong_ur, strong_sp, 'go-')
axes1[0].set_title('ROC for UL')
axes1[1].set_title('ROC for SP**')
axes1[2].set_title('ROC UL vs SP**')

[set_aspect(ax) for ax in axes1]
fig1.tight_layout()
コード例 #8
0
    calc_rates(data_strong_hip['lure'], params.N_t)
]

labels = ['weak', 'mixed', 'strong']
titles = ['cort_hit_rate', 'cort_false_rate', 'hip_hit_rate', 'hip_false_rate']

data_all = [cort_hit_rate, cort_false_rate, hip_hit_rate, hip_false_rate]
fig1, axes = plt.subplots(2, 2)
axes = axes.flatten()
for i, data in enumerate(data_all):
    ax = axes[i]
    [
        ax.plot(threshold[:-1], item[:-1], 'o-', label=labels[ind])
        and ax.legend() and ax.set_ylabel(titles[i])
        and ax.set_xlabel('threshold') and ax.set_ybound(0, 1.1)
        and set_aspect(ax) for ind, item in enumerate(data)
    ]
#    ax.set_aspect('equal')
fig1.tight_layout()

#fig2,axes=plt.subplots(2,2)
#axes=axes.flatten()
#for i, data in enumerate(data_all):
#    ax=axes[i]
#    ax.plot([1,2,3],[data[0][0],data[1][0],data[2][0]], 'o-', label='threshold 1')
#    ax.plot([1,2,3],[data[0][1],data[1][1],data[2][1]], 'o-', label='threshold 2')
#    ax.set_ylabel(titles[i])
#    ax.set_ybound(0,0.9)
#    ax.legend()
#    ax.set_xticks([1,2,3])
#    ax.set_xticklabels(labels)