Esempio n. 1
0
x = np.linspace(-r, r, num=200)


def f(x, a, mu, sig):
    y = a * np.exp((-(x - mu)**2) / (2 * sig**2))
    #    y = a*np.exp(-np.power((x-mu), 2)/(2 * sig**2))
    return y


y1 = f(x, .3, 0, 3)
y2 = f(x, -.1, 0, 9)

fig = texplot.figsize(.9)
plf.addarrowaxis(plt.gca(),
                 x=0.1,
                 y=0.4,
                 dx=0.1,
                 dy=0.2,
                 xtext='Distance',
                 ytext='Sensitivity',
                 xtextoffset=.02,
                 ytextoffset=.032,
                 fontsize='x-small')
plt.plot(x, y1 + y2)
plt.plot(x, y1, '--')
plt.plot(x, y2, '--')
plt.xticks([])
plt.yticks([])
texplot.savefig('rfstructure')
plt.show()
#plt.axis('equal')
plf.subplottext('C', ax3, x=-0.2, y=1.025)
ax3.set_xticks([0, 1])
ax3.set_xticklabels(['Mesopic', 'Photopic'])
ax3.set_ylabel('Polarity Index')
plf.spineless(ax3)

distrib = [len(group) * 100 / cells.shape[0] for group in groups]
ax4 = plt.subplot(2, 2, 4)
# Hack for fixing the whitespace on both sides for this subplot
# On (2,2) grid, there is too much space on the left of the fourth
# plot for some reason.
# Also , extra space is needed for the cell category names, setting the
# colspan to 4 instead of 5 gives enough space for them.
ax4 = plt.subplot2grid((2, 10), (1, 5), colspan=4)
ax4.barh(np.arange(5), distrib, tick_label=colorlabels, color=colorcategories)
# Labels look unaligned on ipython output but the saved pdf and pgf are fine
for txt in ax4.get_yticklabels():
    txt.set_x(1.2)
    txt.set_ha('right')
plf.spineless(ax4)
ax4.tick_params(axis='y', length=0)
ax4.invert_yaxis()
ax4.set_xlabel('Percentage of cells')

plf.subplottext('D', ax4, x=-0, y=1.15)

plt.subplots_adjust(hspace=.4, wspace=.4)
texplot.savefig('polarityindexchange')
plt.show()
Esempio n. 3
0
groups = []

bins = np.arange(-.2, .35+0.05, 0.05)
for i, color in enumerate(colorcategories):
    group = [index for index, c in enumerate(colors) if c == color]
    ax = axes[i]
    change = csichange[group]
    groups.append(group)
    changes.append(change)
    if i == 0:
        csichange_on = np.copy(change)
    elif i == 1:
        csichange_off = np.copy(change)
    ax.hist(change, color=color , bins=bins)
    ax.set_ylim([0, 10])
    ax.set_yticks(np.linspace(0, 8, 3))
    ax.plot([0, 0], [0, 12], 'r--', alpha=.3)
    plf.subplottext(['A', 'B', 'C', 'D', 'E'][i], ax, x=-.08)
    plf.spineless(ax)
    print(i, stats.wilcoxon(group)[1])


plt.subplots_adjust(hspace=.3)
ax.set_xlabel(r'CSI$_{photopic}$ - CSI$_{mesopic}$')
texplot.savefig('csihistogram_mp')
plt.show()

manwhitu = stats.mannwhitneyu(csichange_on, csichange_off)
print('Mann-Whitney U test for ON and OFF populations '
      f'being different: {manwhitu[1]:5.4f}')
Esempio n. 4
0
    # Function to quickly adjust the spine color and width
    def setspines(ax):
        locs = ['top', 'left', 'bottom', 'right']
        for loc in locs:
            ax.spines[loc].set_color('maroon')
            ax.spines[loc].set_linewidth(1)
    # Define functions to generate the representative stimuli
    def checkerstim():
        return np.random.randint(0, 2, bwndim*bwndim).reshape(bwndim,bwndim)
    def barstim():
        return (np.repeat(np.random.randint(0, 2, bwndim),
                          bwndim)).reshape(bwndim, bwndim)
    # We first draw checker representation, then bar representation
    # Since the bar should be further down, we offset it
    for stim, baroffset in zip([checkerstim, barstim], [0, .45]):
        np.random.seed(0)
        for i in range(nr_frames):
            d = i*offset # How much to offset each individual frame
            # This is the trick to place the frames where you want
            ax = fig.add_axes([.13-d, .7-d-baroffset, .06, .06])
            ax.imshow(stim(), cmap='Greys')
            plt.xticks([])
            plt.yticks([])
            setspines(ax)

    plt.subplots_adjust(wspace=.3, hspace=.35)
    texplot.savefig('comparesurroundcalc')
    plt.show()
    plt.close()
Esempio n. 5
0
    ax.set_xlim(ax_lims)
    ax.set_ylim(ax_lims)
    tick_locs = [0, 0.2, 0.4]
    ax.set_xticks(tick_locs)
    ax.set_yticks(tick_locs)

    ax.scatter(csi[0, :], csi[1, :], s=6, c='grey')
    ax.scatter(csi[0, group], csi[1, group], s=6, c=color, linewidths=.5)
    ax.plot(x, x, 'k--', alpha=.5, linewidth=.5)

    plf.subplottext(['B', 'C', 'D', 'E', 'F'][i], ax, x=-.25)
    ax.set_aspect('equal')
    plf.spineless(ax, 'tr')
plt.subplots_adjust(hspace=.4, wspace=.4)
texplot.savefig('csichange')

plt.show()

# Perform non-parametric paired test to test significance
stat_test = stats.wilcoxon(csi[0, :], csi[1, :])
print(f'Wilcoxon signed-rank test p-val: {stat_test[1]:7.2e}')
for label, group in zip(colorlabels, groups):
    stat_test_grp = stats.wilcoxon(csi[0, group], csi[1, group])
    print(f'Wilcoxon p-val for {label:25s}: {stat_test_grp[1]:7.2e}')

#np.savez('/home/ycan/Documents/thesis/analysis_auxillary_files/thesis_csiplotting.npz',
#         cells=cells,
#         bias=bias,
#         include=include,
#         colors=colors,
Esempio n. 6
0
        ax1 = axes[2*j]
        plf.subplottext(['A', 'C'][j], ax1, x=-.4)
        plf.subplottext(['Mesopic', 'Photopic'][j],
                        ax1, x=-.5, y=.5, rotation=90, va='center')
        plf.stashow(sta, ax1, extent=[0, t[-1], -vscale, vscale],
                    cmap=texplot.cmap)
        ax1.set_xlabel('Time [ms]')
        ax1.set_ylabel(r'Distance [$\upmu$m]')

        fitv = np.mean(sta[:, max_i[1]-cut_time:max_i[1]+cut_time+1],
                       axis=1)

        s = np.arange(fitv.shape[0])

        ax2 = axes[2*j+1]
        plf.subplottext(['B', 'D'][j], ax2, x=-.1)
        plf.subplottext(f'Center-Surround Index: {csi:4.2f}',
                        ax2, x=.95, y=.15, fontsize=8, fontweight='normal')
        plf.spineless(ax2)
        ax2.set_yticks([])
        ax2.set_xticks([])
        ax2.plot(onoroff*fitv, -s, label='Data')
        # Displace the center of both distributions according to the difference
        popt = popt - np.array([0, 1, 0, 0, 1, 0])*fsize_diff*2
        ax2.plot(onedgauss(s, *popt[:3]), -s,  '--', label='Center')
        ax2.plot(-onedgauss(s, *popt[3:]), -s,  '--', label='Surround')

    plt.subplots_adjust(hspace = .3, wspace=.2)
    texplot.savefig(label)
    plt.show()
Esempio n. 7
0
axes = fig.subplots(len(colorcategories) + 1, 1, sharex=True)
bins = np.arange(-200, 25 + 25,
                 25)  # Arange does not include endpoint so 25+25
changes = []
for i, color in enumerate(colorcategories):
    group = [index for index, c in enumerate(colors) if c == color]
    ax = axes[i]
    change = maxts_f[1, group] - maxts_f[0, group]
    changes.append(change)
    ax.hist(change, color=color, bins=bins)
    ax.set_ylim([0, 10])
    plf.subplottext(['A', 'B', 'C', 'D', 'E'][i], ax, x=-.08)
    plf.spineless(ax)
    stat_test = stats.wilcoxon(change)
    print(f'Wilcoxon p-val for {color:25s}:  {stat_test[1]:7.2e}')
ax = axes[-1]
ax.hist(maxts_f[1, :] - maxts_f[0, :], color='k', bins=bins)
plf.subplottext('F', ax, x=-.08)
plf.spineless(ax)
ax.set_xlabel(r'TTP\textsubscript{photopic} - TTP\textsubscript{mesopic} [ms]')
plt.subplots_adjust(hspace=.4)
texplot.savefig('temporalpeakchangehistogram')
plt.show()

mannwu = stats.mannwhitneyu(changes[0], changes[1])
print(f'Mann-Whitney-U test p-val for ON vs OFF categories:  {mannwu[1]:7.2e}')

stats = stats.wilcoxon(maxts_f[1, :] - maxts_f[0, :])
print(f'Wilcoxon p-val for the whole population: {stats[1]:7.2e}')