def plot_summary(cmb_corrs, fig_path, extras=''):
    """ plot a summary showing the mean and std for all attempted
    combinations"""
    fig = plt.figure(figsize=(14, 12))
    ax = plt.subplot(111)
    adjust_spines(ax, ['bottom', 'left'])
    colors = ['r', 'b', 'g', 'y', 'c', 'm']
    _ = plt.subplot(111)
    xaxis = []
    xvals = []
    boxes = []
    lbls = []

    #targets.append('Overall')
    offset = -1
    for i, k in enumerate(sorted(cmb_corrs.keys())):
        offset += 2
        min_x = offset
        for j, cmb in enumerate(sorted(cmb_corrs[k].keys())):
            xaxis.append(cmb)
            xvals.append(offset)
            dat = cmb_corrs[k][cmb]
            if len(dat) == 0:
                continue
            col = colors[i]
            #            do_box_plot(np.array(dat), np.array([i + offset]),
            #                        col, widths=[0.2])
            do_spot_scatter_plot(np.array(dat), offset, col)
            offset += 1


#            if j == 0:
#                boxes.append(plt.Rectangle((0, 0), 1, 1, fc=col))
#                lbls.append(k)
        max_x = offset
        plt.text(min_x + (max_x - min_x) / 2., 1., k, ha='center')
    plt.title('N=%d' % len(dat))

    plt.xticks(xvals, xaxis, rotation='vertical')
    plt.plot([-1, len(xaxis) + 1], [0, 0], '--')
    plt.xlim(0, offset)
    plt.ylim(-0.05, 1)
    plt.subplots_adjust(left=0.05,
                        bottom=0.5,
                        right=0.97,
                        top=0.95,
                        wspace=0.3,
                        hspace=0.34)
    plt.legend(boxes, lbls, frameon=False, loc=4)
    plt.ylabel('Correlation between prediction and Experimental Mean')
    fname = '%s%s_pred_%s' % (fig_path, 'summary', extras)
    fig.savefig(fname + '.eps')
    fig.savefig(fname + '.png')
    #plt.show()
    plt.close(fig)
def plot_summary(cmb_corrs, fig_path, extras=''):
    """ plot a summary showing the mean and std for all attempted
    combinations"""
    fig = plt.figure(figsize=(14, 12))
    ax = plt.subplot(111)
    adjust_spines(ax, ['bottom', 'left'])
    colors = ['r', 'b', 'g', 'y', 'c', 'm']
    _ = plt.subplot(111)
    xaxis = []
    xvals = []
    boxes = []
    lbls = []

    #targets.append('Overall')
    offset = -1
    for i, k in enumerate(sorted(cmb_corrs.keys())):
        offset += 2
        min_x = offset
        for j, cmb in enumerate(sorted(cmb_corrs[k].keys())):
            xaxis.append(cmb)
            xvals.append(offset)
            dat = cmb_corrs[k][cmb]
            if len(dat) == 0:
                continue
            col = colors[i]
#            do_box_plot(np.array(dat), np.array([i + offset]),
#                        col, widths=[0.2])
            do_spot_scatter_plot(np.array(dat), offset, col)
            offset += 1
#            if j == 0:
#                boxes.append(plt.Rectangle((0, 0), 1, 1, fc=col))
#                lbls.append(k)
        max_x = offset
        plt.text(min_x + (max_x - min_x) / 2., 1., k, ha='center')
    plt.title('N=%d' % len(dat))

    plt.xticks(xvals, xaxis, rotation='vertical')
    plt.plot([-1, len(xaxis) + 1], [0, 0], '--')
    plt.xlim(0, offset)
    plt.ylim(-0.05, 1)
    plt.subplots_adjust(left=0.05, bottom=0.5, right=0.97, top=0.95,
                       wspace=0.3, hspace=0.34)
    plt.legend(boxes, lbls, frameon=False, loc=4)
    plt.ylabel('Correlation between prediction and Experimental Mean')
    fname = '%s%s_pred_%s' % (fig_path, 'summary', extras)
    fig.savefig(fname + '.eps')
    fig.savefig(fname + '.png')
    #plt.show()
    plt.close(fig)
        cnt_lims = [
            np.minimum(cnt_lims[0], cnts.min()),
            np.maximum(cnt_lims[1], cnts.max())
        ]
        #        crr_lims = [np.minimum(crr_lims[0], crrs[:, 0].min()),
        #                    np.maximum(crr_lims[1], crrs[:, 0].max() + crrs[:, 1].max())]

        cnt_axs.append(plt.subplot(2, 2, cnt))
        cnt += 2
        plt.title(k)
        plt.plot(shifts, cnts, '-o')
        if i == 0:
            plt.ylabel('# correlated responses')
        crr_axs.append(plt.subplot(2, 2, cnt))
        for cr, shift in zip(crrs, shifts):
            do_spot_scatter_plot(cr, shift, 'k', 0.4, False, mean_adjust=True)
        #do_box_plot(crrs, shifts, 'k', np.ones_like(shifts) * 0.5)
        cnt -= 1
        if i == 0:
            plt.ylabel('mean corr of responders')
        plt.xlabel('Shift in Frames')
    adjuster = np.array([-0.5, 0.5])
    for ax in cnt_axs:
        ax.set_ylim(cnt_lims + adjuster)
        ax.set_xlim(np.array([shifts.min(), shifts.max()]) + adjuster)
#    for ax in crr_axs:
#        ax.set_ylim(crr_lims + adjuster * 0.05)
#        ax.set_xlim(np.array([shifts.min(), shifts.max()]) + adjuster)
    fig3.savefig(fig_path + '%s_%s_shift_avg_count.eps' %
                 (str(filt), exp_type))
    fig3.savefig(fig_path + '%s_%s_shift_avg_count.png' %
#                    adjust_spines(ax, ['left', 'bottom'])
#                elif ax.is_last_row():
#                    plt.setp(ax.get_xticklabels(), rotation='vertical')
#                    adjust_spines(ax, ['bottom'])
#                elif ax.is_first_col():
#                    adjust_spines(ax, ['left'])
#                    ax.text(-0.5, 0.5, label, transform=ax.transAxes,
#                            rotation='vertical', va='center', ha='center')
#                else:
#                    adjust_spines(ax, [])
                ttl = '%s %s' % (exp_type, stim_type)
                plt.title(ttl)
                plt.hold(True)
                for s, shift in enumerate(shifts):
                    vals = np.array(new_res[rbm_type][act_type][exp_type][stim_type][shift])
                    vals = np.array([vals[vals > 0.].mean()])
                    if vals.max() > mx:
                        mx = vals.max()
                    do_spot_scatter_plot(vals, shift, 'k', 0.4, False, True)
                cnt += 1
            for ax in axes:
                ax.set_ylim(-0.01, mx + (mx * 0.1))
                ax.set_xlim(shifts.min() - 0.5, shifts.max() + 0.5)
        plt.subplots_adjust(left=0.05, bottom=0.05, right=0.99, top=0.93, wspace=0.25, hspace=0.25)
        fig.savefig(fig_path + 'scatter_%s_%s.eps' % (rbm_type, act_type))
        fig.savefig(fig_path + 'scatter_%s_%s.png' % (rbm_type, act_type))
        
        plt.close(fig)

print 'CHECK WHAT TYPE OF STIMULUS::: WHOLE FIELD OR CENTRE: DO THE PEAKS OF SHIFT DIFFER BETWEEN THE TWO, WHAT DO THE RECEPTIVE FIELDS LOOK LIKE?'
print 'DO THE SAME PLOT AS THE PRED WITH SCATTER'
        xvals = []
        fig = plt.figure(figsize=(14, 12))
        ax = plt.subplot(111)
        adjust_spines(ax, ['bottom', 'left'])
        offset = -1
        for k in cell_results[cell].keys():
            offset += 2
            min_x = offset
            for cmb in cell_results[cell][k].keys():
                xaxis.append(cmb)
                xvals.append(offset)
                dat = []
                for s in cell_results[cell][k][cmb].keys():
                    #dat.append([s, cell_results[cell][k][cmb][s]['crr_pred']])
                    dat.append(cell_results[cell][k][cmb][s]['crr_pred'])
                do_spot_scatter_plot(np.array(dat, dtype=np.float), offset,
                                     width=0.4)
                offset += 1
            max_x = offset
            plt.text(min_x + (max_x - min_x) / 2., 1., k, ha='center')

        plt.xticks(xvals, xaxis, rotation='vertical')
        plt.plot([-1, len(xaxis) + 1], [0, 0], '--')
        plt.xlim(0, offset)
        plt.ylim(-0.05, 1)
        plt.subplots_adjust(left=0.05, bottom=0.2, right=0.97, top=0.95,
                           wspace=0.3, hspace=0.34)
        plt.ylabel('Correlation between prediction and Experimental Mean')
        fname = '%s%s_pred' % (fig_path, cell)
        fig.savefig(fname + '.eps')
        fig.savefig(fname + '.png')
        #plt.show()
        crrs = np.array(crrs)
        cnts = np.array(cnts)
        cnt_lims = [np.minimum(cnt_lims[0], cnts.min()),
                    np.maximum(cnt_lims[1], cnts.max())]
#        crr_lims = [np.minimum(crr_lims[0], crrs[:, 0].min()),
#                    np.maximum(crr_lims[1], crrs[:, 0].max() + crrs[:, 1].max())]

        cnt_axs.append(plt.subplot(2, 2, cnt))
        cnt += 2
        plt.title(k)
        plt.plot(shifts, cnts, '-o')
        if i == 0:
            plt.ylabel('# correlated responses')
        crr_axs.append(plt.subplot(2, 2, cnt))
        for cr, shift in zip(crrs, shifts):
            do_spot_scatter_plot(cr, shift, 'k', 0.4, False, mean_adjust=True)
        #do_box_plot(crrs, shifts, 'k', np.ones_like(shifts) * 0.5)
        cnt -= 1
        if i == 0:
            plt.ylabel('mean corr of responders')
        plt.xlabel('Shift in Frames')
    adjuster = np.array([-0.5, 0.5])
    for ax in cnt_axs:
        ax.set_ylim(cnt_lims + adjuster)
        ax.set_xlim(np.array([shifts.min(), shifts.max()]) + adjuster)
#    for ax in crr_axs:
#        ax.set_ylim(crr_lims + adjuster * 0.05)
#        ax.set_xlim(np.array([shifts.min(), shifts.max()]) + adjuster)
    fig3.savefig(fig_path + '%s_%s_shift_avg_count.eps' % (str(filt), exp_type))
    fig3.savefig(fig_path + '%s_%s_shift_avg_count.png' % (str(filt), exp_type))
    plt.close(fig3)
Example #7
0
        fig = plt.figure(figsize=(14, 12))
        ax = plt.subplot(111)
        adjust_spines(ax, ['bottom', 'left'])
        offset = -1
        for k in cell_results[cell].keys():
            offset += 2
            min_x = offset
            for cmb in cell_results[cell][k].keys():
                xaxis.append(cmb)
                xvals.append(offset)
                dat = []
                for s in cell_results[cell][k][cmb].keys():
                    #dat.append([s, cell_results[cell][k][cmb][s]['crr_pred']])
                    dat.append(cell_results[cell][k][cmb][s]['crr_pred'])
                do_spot_scatter_plot(np.array(dat, dtype=np.float),
                                     offset,
                                     width=0.4)
                offset += 1
            max_x = offset
            plt.text(min_x + (max_x - min_x) / 2., 1., k, ha='center')

        plt.xticks(xvals, xaxis, rotation='vertical')
        plt.plot([-1, len(xaxis) + 1], [0, 0], '--')
        plt.xlim(0, offset)
        plt.ylim(-0.05, 1)
        plt.subplots_adjust(left=0.05,
                            bottom=0.2,
                            right=0.97,
                            top=0.95,
                            wspace=0.3,
                            hspace=0.34)
Example #8
0
                #                elif ax.is_first_col():
                #                    adjust_spines(ax, ['left'])
                #                    ax.text(-0.5, 0.5, label, transform=ax.transAxes,
                #                            rotation='vertical', va='center', ha='center')
                #                else:
                #                    adjust_spines(ax, [])
                ttl = '%s %s' % (exp_type, stim_type)
                plt.title(ttl)
                plt.hold(True)
                for s, shift in enumerate(shifts):
                    vals = np.array(new_res[rbm_type][act_type][exp_type]
                                    [stim_type][shift])
                    vals = np.array([vals[vals > 0.].mean()])
                    if vals.max() > mx:
                        mx = vals.max()
                    do_spot_scatter_plot(vals, shift, 'k', 0.4, False, True)
                cnt += 1
            for ax in axes:
                ax.set_ylim(-0.01, mx + (mx * 0.1))
                ax.set_xlim(shifts.min() - 0.5, shifts.max() + 0.5)
        plt.subplots_adjust(left=0.05,
                            bottom=0.05,
                            right=0.99,
                            top=0.93,
                            wspace=0.25,
                            hspace=0.25)
        fig.savefig(fig_path + 'scatter_%s_%s.eps' % (rbm_type, act_type))
        fig.savefig(fig_path + 'scatter_%s_%s.png' % (rbm_type, act_type))

        plt.close(fig)