Beispiel #1
0
 def plot(self, agg):
     plt = plot.Plot()
     plt.plot(agg)
     if self.rp['plot']:
         plt.show()
     else:
         print agg
Beispiel #2
0
    def staircase(self):
        df = self._get_staircase()
        agg_thres = stats.aggregate(df,
                                    values='thres',
                                    rows='session',
                                    unstack=True)
        agg = stats.aggregate(df,
                              values='oridiff',
                              subplots='session',
                              rows='trialno',
                              cols='pos')
        if self.rp['plot'] or self.rp['saveplot']:
            plt = plot.Plot(nrows=2, ncols=2, sharex=True, sharey=True)
            ax = plt.plot(agg, kind='line', ylabel='step')
            num_trials = len(agg.columns.levels[1])

            for pno, (sno, thres) in enumerate(agg_thres.mean().iteritems()):
                #import pdb; pdb.set_trace()
                ax = plt.get_ax(pno)
                ax.set_title('session %d' % sno)
                ax.axhline(y=thres, color='.2', ls='--', lw=2, marker='None')
                print thres
                ax.text(num_trials - 15,
                        thres + .5,
                        'average threshold = %.2f' % thres,
                        fontsize=8)

            print agg_thres
            plt.hide_plots(3)
            if self.rp['plot']: plt.show()
            if self.rp['saveplot']:
                plt.savefig(PATHS['analysis'] + '%s.svg' % self.info['subjid'])

        return agg_thres
Beispiel #3
0
    def run(self):
        pattern = PATHS['data'] + '%s.csv'
        df = self.exp.get_behav_df(pattern=pattern)
        agg_acc = stats.accuracy(df,
                                 cols='context',
                                 values='accuracy',
                                 yerr='subjid',
                                 order='sorted')
        agg_rt = stats.aggregate(df[df.accuracy == 'correct'],
                                 cols='context',
                                 values='rt',
                                 yerr='subjid',
                                 order='sorted')

        plt = plot.Plot(ncols=2)
        if len(df.subjid.unique()) == 1:
            kind = 'bar'
        else:
            kind = 'bean'
        plt.plot(agg_acc, kind=kind, title='accuracy', ylabel='% correct')
        plt.plot(agg_rt, kind=kind, title='response time', ylabel='seconds')

        print agg_acc
        print agg_rt
        plt.show()
Beispiel #4
0
    def thresholds(self):
        df = self._get_staircase()
        agg_thres = stats.aggregate(df, values='thres', cols='pos',
                                    yerr='subjid')
        plt = plot.Plot()
        plt.plot(agg_thres, kind='bar', title='orientation thresholds',
                 ylabel='orientation threshold, deg')
        print agg_thres.mean()
        plt.show()

        return agg_thres
Beispiel #5
0
 def test(self):
     """Analysis of the test phase data (for 2AFC task)
     """
     pattern = self.paths['data'] + '%s_test.csv'
     df = exp.get_behav_df(self.info['subjid'], pattern=pattern)
     agg_acc = stats.accuracy(df,
                              rows='session',
                              cols='pos',
                              values='accuracy',
                              yerr='subjid')
     plt = plot.Plot()
     plt.plot(agg_acc)
     plt.show()
Beispiel #6
0
 def run(self):
     df = self._get_staircase()
     agg_thres = stats.aggregate(df, values='thres', rows='pos', unstack=True)
     agg = stats.aggregate(df, values='oridiff', rows='trialno', cols='pos')
     plt = plot.Plot()
     ax = plt.plot(agg, kind='line', ylabel='step')
     num_trials = len(agg.columns.levels[1])
     thres = agg_thres.mean(1).values[0]
     ax.axhline(y=thres, color = '.2', ls='--', lw=2, marker = 'None')
     print agg_thres
     ax.text(num_trials - num_trials/3., thres+.5,
         'average threshold = %.2f' % thres, fontsize=8)
     plt.show()
     return agg_thres
Beispiel #7
0
                        ('name', ['condition one', 'condition two']),
                        ('levels', ['small', 'medium', 'large']),
                        ('subjID', ['subj%d' % (i + 1) for i in range(n)])],
                       repeat=nsampl)
df['rt'] = 0.5
df.rt[df.cond == 1] = np.random.random(12 * k) * 1.2
df.rt[df.cond == 2] = np.random.random(12 * k)
#df['accuracy'] = ['correct','correct','incorrect','incorrect']*k*9

agg = stats.aggregate(df,
                      subplots='subplots',
                      rows='levels',
                      cols='cond',
                      yerr='subjID',
                      values='rt')
plt1 = plot.Plot(figsize=(6, 3))
plt1.plot(agg, kind='bar')
plt1.tight_layout()

plt2 = plot.Plot(figsize=(6, 3))
plt2.plot(agg, kind='line')
plt2.tight_layout()

plt3 = plot.Plot(figsize=(8, 4))
plt3.plot(agg, kind='bean')
plt3.tight_layout()

agg = stats.aggregate(df,
                      subplots='subplots',
                      rows='subjID',
                      cols='name',