Exemplo n.º 1
0
def AR1(constrained=False):
    g = .95
    sn = .3
    y, c, s = [a[0] for a in gen_data([g], sn, N=1)]
    result = constrained_oasisAR1(y, g, sn) if constrained else oasisAR1(y, g, lam=2.4)
    result_foopsi = constrained_foopsi(y, [g], sn) if constrained else foopsi(y, [g], lam=2.4)
    npt.assert_allclose(np.corrcoef(result[0], result_foopsi[0])[0, 1], 1)
    npt.assert_allclose(np.corrcoef(result[1], result_foopsi[1])[0, 1], 1)
    npt.assert_allclose(np.corrcoef(result[0], c)[0, 1], 1, .03)
    npt.assert_allclose(np.corrcoef(result[1], s)[0, 1], 1, .2)
Exemplo n.º 2
0
def AR2(constrained=False):
    g = [1.7, -.712]
    sn = .3
    y, c, s = [a[0] for a in gen_data(g, sn, N=1, seed=3)]
    result = constrained_onnlsAR2(y, g, sn) if constrained else onnls(y, g, lam=25)
    result_foopsi = constrained_foopsi(y, g, sn) if constrained else foopsi(y, g, lam=25)
    npt.assert_allclose(np.corrcoef(result[0], result_foopsi[0])[0, 1], 1, 1e-3)
    npt.assert_allclose(np.corrcoef(result[1], result_foopsi[1])[0, 1], 1, 1e-2)
    npt.assert_allclose(np.corrcoef(result[0], c)[0, 1], 1, .03)
    npt.assert_allclose(np.corrcoef(result[1], s)[0, 1], 1, .2)
    result2 = constrained_oasisAR2(y, g[0], g[1], sn) if constrained \
        else oasisAR2(y, g[0], g[1], lam=25)
    npt.assert_allclose(np.corrcoef(result2[0], c)[0, 1], 1, .03)
    npt.assert_allclose(np.corrcoef(result2[1], s)[0, 1], 1, .2)
Exemplo n.º 3
0
# real data from Chen et al 2013, available at following URL
# https://portal.nersc.gov/project/crcns/download/cai-1/GCaMP6s_9cells_Chen2013/processed_data.tar.gz
filename = "/Users/joe/Downloads/data_20120627_cell2_002.mat"

################
#### Traces ####
################

# AR(1)

g = .95
sn = .3
Y, trueC, trueSpikes = gen_data()
N, T = Y.shape
result_oasis = oasisAR1(Y[0], g=g, lam=2.4)
result_foopsi = foopsi(Y[0], g=[g], lam=2.4)

fig = plt.figure(figsize=(20, 5.5))
fig.add_axes([.038, .57, .96, .42])
plt.plot(result_oasis[0], c=col[0], label='OASIS')
plt.plot(result_foopsi[0], '--', c=col[6], label='CVXPY')
plt.plot(trueC[0], c=col[2], label='Truth', zorder=-5)
plt.plot(Y[0], c=col[7], alpha=.7, zorder=-10, lw=1, label='Data')
plt.legend(frameon=False, ncol=4, loc=(.275, .82))
plt.gca().set_xticklabels([])
simpleaxis(plt.gca())
plt.ylim(Y[0].min(), Y[0].max())
plt.yticks([0, int(Y[0].max())], [0, int(Y[0].max())])
plt.xticks(range(750, 3000, 750), [''] * 3)
plt.ylabel('Fluor.')
plt.xlim(0, 2000)
Exemplo n.º 4
0
# https://portal.nersc.gov/project/crcns/download/cai-1/GCaMP6s_9cells_Chen2013/processed_data.tar.gz
filename = "/Users/joe/Downloads/data_20120627_cell2_002.mat"


################
#### Traces ####
################

# AR(1)

g = .95
sn = .3
Y, trueC, trueSpikes = gen_data()
N, T = Y.shape
result_oasis = oasisAR1(Y[0], g=g, lam=2.4)
result_foopsi = foopsi(Y[0], g=[g], lam=2.4)

fig = plt.figure(figsize=(20, 5.5))
fig.add_axes([.038, .57, .96, .42])
plt.plot(result_oasis[0], c=col[0], label='OASIS')
plt.plot(result_foopsi[0], '--', c=col[6], label='CVXPY')
plt.plot(trueC[0], c=col[2], label='Truth', zorder=-5)
plt.plot(Y[0], c=col[7], alpha=.7, zorder=-10, lw=1, label='Data')
plt.legend(frameon=False, ncol=4, loc=(.275, .82))
plt.gca().set_xticklabels([])
simpleaxis(plt.gca())
plt.ylim(Y[0].min(), Y[0].max())
plt.yticks([0, int(Y[0].max())], [0, int(Y[0].max())])
plt.xticks(range(750, 3000, 750), [''] * 3)
plt.ylabel('Fluor.')
plt.xlim(0, 2000)