Beispiel #1
0
             c=[orange, cyan][i],
             label=['Poisson', 'Gaussian'][i])
    IQRfill(cor.T, dsls, [orange, cyan][i])
plt.xlabel('Spatial decimation')
ax = plt.gca()
simpleaxis(ax)
ax.patch.set_visible(False)
plt.xticks(dsls, ['1', '', '', '4x4', '6x6', '8x8', '12x12'])
plt.yticks([.95, 1.00], [.95, '1'])
plt.xlim(dsls[0], dsls[-1])
plt.ylim(.949, 1)
plt.ylabel('Correlation w/ ground truth', y=.54, labelpad=-25)
plt.legend(loc=(.01, .25), ncol=1)
plt.subplots_adjust(.105, .15, .94, .97)
plt.savefig(figpath +
            '/Poisson-Gauss_zebrafish.pdf') if figpath else showpause()

#

# ########################################################
# #####################  two-photon  #####################
# ########################################################

# Load results

cluster = False  # whether code is run on cluster
dsls = [1, 2, 3, 4, 6, 8, 12, 16, 24, 32]

f, A2, b2, C2 = itemgetter('f', 'A2', 'b2',
                           'C2')(np.load('results/CNMF-HRshapes.npz'))
A2 = A2.item()
Beispiel #2
0
    simpleaxis(plt.gca())
    plt.xticks(dsls, ['1', '', '', '', '', '8x8', '', '16x16', '24x24', '32x32'])
    plt.ylim(.3, 1)
    plt.yticks(
        *[np.round(np.arange(np.round(plt.ylim()[1], 1), plt.ylim()[0], -.2), 1)] * 2)
    plt.xlim(dsls[0], dsls[-1])
    plt.ylabel('Correlation w/ undecimated $C_1$/$S_1$', y=.42, labelpad=1)
    plt.legend(handles=[l3, l4, l1, l2], loc=loc, ncol=1)
    plt.subplots_adjust(.13, .15, .94, .96)
    return l1, l2, l3, l4


plt.figure()
plotCorr(ssub, ssub0)
plt.ylim(.25, 1)
plt.savefig(figpath + '/Corr.pdf', transparent=True) if figpath else showpause()

plt.figure()
plotCorr(ssubX, ssubX0)
plt.ylim(.4, 1)
plt.xticks(dsls, ['1', '', '', '', '', '8x1', '', '16x1', '24x1', '32x1'])
plt.savefig(figpath + '/xCorr.pdf', transparent=True) if figpath else showpause()

#

# # artificial data, from 'true' generative model by shuffling residuals in time

res = np.load('results/decimate-stratshuffled.npz')
ssub, ssubX = res['ssub'].item(), res['ssubX'].item()
res = np.load('results/decimate-stratshuffled-LR.npz')
ssub0, ssubX0 = res['ssub'].item(), res['ssubX'].item()
Beispiel #3
0
               vmax=4000)
ax.set_xticks([])
ax.set_yticks([])
plt.axis('off')
# create an axes on the right side of ax. The width of cax will be 5%
# of ax and the padding between cax and ax will be fixed at 0.05 inch.
divider = make_axes_locatable(ax)
cax = divider.append_axes("right", size="5%", pad=0.05)
cb = plt.colorbar(im, cax=cax, label='Maximum Projection')
cb.set_ticks(range(1000, 4000, 1000))
plt.yticks(range(1000, 4000, 1000), range(1000, 4000, 1000), fontsize=16)
cb.ax.yaxis.label.set_font_properties(
    matplotlib.font_manager.FontProperties(size=16))
plt.subplots_adjust(.005, 0, .89, 1)
plt.savefig(figpath + '/data-1stHalf.pdf', bbox_inches='tight',
            pad_inches=.01) if figpath else showpause()

#

# # correlations

init_fig()

# find for each neuron obtianed on the full data the idx of the corresponding neuron
# obtained on small batch of the data, if it exists otherwise set idx to None
A2 = np.load('results/CNMF-HRshapes.npz')['A2'].item()
centers = np.asarray(
    [center_of_mass(a.reshape(d1, d2)) for a in A2.toarray().T])

A2h = np.load('results/CNMF-HRshapes-Aon1stHalf.npz')['A2'].item()
centersH = np.asarray(
Beispiel #4
0
plt.vlines(range(16, d1, 16), 0, d1, cyan)
plt.hlines(range(8, d2, 16), 0, d2, orange)
plt.vlines(range(8, d1, 16), 0, d1, orange)
plt.xlim(112, 288)
plt.ylim(128, 304)
# create an axes on the right side of ax. The width of cax will be 5%
# of ax and the padding between cax and ax will be fixed at 0.05 inch.
divider = make_axes_locatable(ax)
cax = divider.append_axes("right", size="5%", pad=0.05)
cb = plt.colorbar(im, cax=cax, label='Maximum Projection')
cb.set_ticks(range(1000, 4000, 1000))
plt.yticks(range(1000, 4000, 1000), range(1000, 4000, 1000), fontsize=16)
cb.ax.yaxis.label.set_font_properties(
    matplotlib.font_manager.FontProperties(size=16))
plt.subplots_adjust(.005, 0, .89, 1)
plt.savefig(figpath + '/data-interleave.pdf') if figpath else showpause()
#

#

# plot correlations

init_fig()


def plotCorr(ssubs,
             compare,
             dsls,
             labels=None,
             colors=[cyan, orange, green],
             ca_or_spikes='ca',
Beispiel #5
0
# update order
plt.figure()
plt.plot(*np.min(MSE_order, 0).T / np.array([[1], [z]]),
         label='one neuron at a time\n (HALS)', c='k')
plt.plot(*np.min(MSE_nodec, 0).T / np.array([[1], [z]]),
         label='one factor at a time\n (fast HALS)', c=col[0])
lg = plt.legend(bbox_to_anchor=(1, 1))
adjust()
plt.ylabel('normalized MSE', labelpad=-25)
plt.xticks(*[[0, 10, 20]] * 2)
plt.yticks(*[[1, 1.05], ['1.00', 1.05]])
plt.xlim(0, 30)
plt.ylim(l, 1.052)
plt.plot((0, 8.5, 8.5), (u, u, l), 'k--')
plt.savefig(figpath + '/MSE_order.pdf') if figpath else showpause()


# temporal decimation
plt.figure()
plt.plot(*np.min(MSE_nodec, 0).T / np.array([[1], [z]]), label='1', c=col[0])
for k, i in enumerate(mbls[1:]):
    plt.plot(*np.min([m[k + 1]
                      for m in MSE_decT], 0).T / np.array([[1], [z]]), label=i, c=col[k + 1])
lg = plt.legend(title='decimation factor', ncol=2, columnspacing=1, bbox_to_anchor=(1, 1))
for i, t in enumerate(lg.get_texts()):  # right align
    t.set_ha('right')
    t.set_position((25 + i / 3 * 10, 0))
adjust()
plt.ylabel('normalized MSE', labelpad=-25, y=.58)
plt.savefig(figpath + '/MSE_decT.pdf') if figpath else showpause()
Beispiel #6
0
                      ec=np.array([.2, .2, .2]) +
                      np.array([.8, .5, .8]) * np.random.rand(3)))
for i, k in enumerate(idx):
    plt.gca().add_patch(
        plt.Rectangle(boxes[k][:, 0] + .2,
                      boxes[k][0, 1] - boxes[k][0, 0] - 1,
                      boxes[k][1, 1] - boxes[k][1, 0] - 1,
                      lw=2,
                      fill=False,
                      ec=col[2 * i]))
    plt.scatter(*centers[k], s=60, marker='x', lw=3, c=col[2 * i], zorder=10)
plt.axis('off')
plt.xlim(0, 96)
plt.ylim(96, 0)
plt.subplots_adjust(0, 0, 1, 1)
plt.savefig(figpath + '/patch.pdf') if figpath else showpause()


# plot series for short and long processing time
def df(a, s, id):
    return a[id] * s[id].ravel().dot(
        s[id].ravel()) / (a[-1] * s[id].ravel().dot(s[-1].ravel()))


for j, a in enumerate([activityQ, activity]):
    fig = plt.figure(figsize=(18, 6. / 8 * 7))
    for i, k in enumerate(idx):
        fig.add_axes([.053, .705 - .29 * i, .945, .27])
        tmp = df(activity0, shapes0, k)[:1000]
        tmp -= tmp.min()
        plt.plot(tmp, lw=3, c='k')