stimdur = expdata['stim_duration']
        clusterids = plf.clusters_to_ids(clusters)
        index = [i for i, cl in enumerate(clusterids)
                 if cl == clustertoplot][0]

        fr = expdata['all_frs'][index]
        t = expdata['t']
        baselines = expdata['baselines'][index]

        plotind = [1, 3, 5, 7][i + 2 * j]
        ax = plt.subplot(4, 2, plotind)
        ax.plot(t, fr, 'k', linewidth=.5)
        plf.spineless(ax)
        if cond == 'M':
            plf.drawonoff(ax, preframedur, stimdur, h=.1)
            plf.subplottext(['A', 'B'][j], ax, x=-0.1)
        elif cond != 'M' and j == 0:
            scalebars.add_scalebar(
                ax,
                matchx=False,
                sizex=.5,
                labelx='500 ms',
                matchy=False,
                sizey=30,
                labely='30 Hz',
                #                       labely=fr'{dist_set} $\upmu$m',
                hidey=False,
                barwidth=1.2,
                loc='upper right',
                sep=2,
                pad=0)
Example #2
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}')
Example #3
0
    with warnings.catch_warnings():
        warnings.filterwarnings('ignore', '.*divide by zero*.', RuntimeWarning)
        pars = gfit.gaussfit(fit_frame * onoroff)
        f = gfit.twodgaussian(pars)
        Z = f(X, Y)

    # Correcting for Mahalonobis dist.
    with warnings.catch_warnings():
        warnings.filterwarnings('ignore', '.*divide by zero*.', RuntimeWarning)
        Zm = np.log((Z - pars[0]) / pars[1])
    Zm[np.isinf(Zm)] = np.nan
    Zm = np.sqrt(Zm * -2)

    ax = plt.subplot(1, 2, 1)
    plf.subplottext('A', ax, x=0, y=1.3)

    vmax = np.abs(fit_frame).max()
    vmin = -vmax
    im = plf.stashow(fit_frame, ax)
    ax.set_aspect('equal')
    plf.spineless(ax)
    ax.set_axis_off()

    with warnings.catch_warnings():
        warnings.filterwarnings('ignore', category=UserWarning)
        warnings.filterwarnings('ignore', '.*invalid value encountered*.')
        ax.contour(Y,
                   X,
                   Zm, [inner_b, outer_b],
                   cmap=plf.RFcolormap(('C0', 'C1')))
Example #4
0
        warnings.filterwarnings('ignore',
                                '.*divide by zero*.', RuntimeWarning)
        pars = gfit.gaussfit(fit_frame*onoroff)
        f = gfit.twodgaussian(pars)
        Z = f(X, Y)

    # Correcting for Mahalonobis dist.
    with warnings.catch_warnings():
        warnings.filterwarnings('ignore',
                                '.*divide by zero*.', RuntimeWarning)
        Zm = np.log((Z-pars[0])/pars[1])
    Zm[np.isinf(Zm)] = np.nan
    Zm = np.sqrt(Zm*-2)

    ax1 = plt.subplot(rows, columns, 1)
    plf.subplottext('A', ax1)

    vmax = np.abs(fit_frame).max()
    vmin = -vmax
    im = plf.stashow(fit_frame, ax1)
    ax1.set_aspect('equal')
    plf.spineless(ax1)
    ax1.set_xticks([])
    ax1.set_yticks([])

    checkercolors = ['black', 'orange']

    with warnings.catch_warnings():
        warnings.filterwarnings('ignore', category=UserWarning)
        warnings.filterwarnings('ignore', '.*invalid value encountered*.')
        ax1.contour(Y, X, Zm, [inner_b, outer_b], linewidths=.5,
Example #5
0
fig = texplot.texfig(.85, aspect=1.85)

ax = plt.subplot2grid((4, 3), (0, 0), colspan=3, rowspan=2)

# Create an array for all the colors to use with plt.legend()
patches = []
for color, label in zip(colorcategories, colorlabels):
    patches.append(mpatches.Patch(color=color, label=label))
ax.legend(handles=patches, fontsize='xx-small')

for group, color in zip(groups, colorcategories):

    ax.scatter(csichange[group], biaschange[group], c=color, **scatterkwargs)
    ax.axhline(0, **linekwargs)
    ax.axvline(0, **linekwargs)
    plf.subplottext('A', ax, x=-0.05)
ax.set_xlabel(r'CSI$_{photopic}$ - CSI$_{mesopic}$')
ax.set_ylabel(r'PI$_{photopic}$ - PI$_{mesopic}$')

for i, (group, color) in enumerate(zip(groups, colorcategories)):
    ax = plt.subplot2grid((4, 3), (2 + int((np.round((i - 1) / 3))), i % 3))
    ax.scatter(csichange, biaschange, c='grey')
    ax.scatter(csichange[group], biaschange[group], c=color, **scatterkwargs)
    ax.axhline(0, **linekwargs)
    ax.axvline(0, **linekwargs)
    plf.spineless(ax, 'tr')
    plf.subplottext(['B', 'C', 'D', 'E', 'F'][i], ax, x=-.25)

#axes[-1].set_axis_off()
plt.subplots_adjust(hspace=.45, wspace=.45)
#texplot.savefig('csichangevsbiaschange')
        popt = all_parameters[index]

        cut_time = int(100/(frame_duration*1000)/2)
        # Changed width from 700 micrometer to 400 to zoom in on the
        # region of interest. This shifts where the fit is drawn,
        # it's fixed when plotting.
        fsize_original = int(700/(stx_w*px_size))
        fsize = int(400/(stx_w*px_size))
        fsize_diff = fsize_original - fsize
        t = np.arange(filter_length)*frame_duration*1000
        vscale = fsize * stx_w*px_size

        sta, max_i = msc.cutstripe(sta, max_i, fsize*2)

        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])
        ax1.set_xlabel('Time [ms]')
#        ax1.set_ylabel(r'Distance [$\upmu$m]')
        ax1.set_ylabel(r'Distance [μ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}',