Beispiel #1
0
alpha1 = np.arange(0, 0.5, 0.05)
results = dict.fromkeys(alpha1)
for i, a2 in tqdm(enumerate(alpha1)):
    model_output = opt.minimize(glm.gain_only_objective, x0, (rec, big_mask, small_mask, a2, nLV), options={'gtol':1e-6, 'disp': True})
    weights = model_output.x

    # get model output
    w1 = weights.reshape((2+nLV), nCells)[0, :]
    w2 = weights.reshape((2+nLV), nCells)[1:-1, :]
    b = weights.reshape((2+nLV), nCells)[-1, :]

    # compute model prediction
    mse, pred, lv = glm.gain_only_objective(weights, rec, big_mask, small_mask, b1=a2, nLV=nLV, verbose=True)

    # compute prediction correlation, save model prediction, weights, and latent variable
    cc = glm.corrcoef_by_neuron(rec['resp']._data, pred)
    mse = glm.mean_square_error(rec['resp']._data, pred)
    results[a2] = {}
    results[a2]['cc'] = cc
    results[a2]['mse'] = mse
    results[a2]['pred'] = pred
    results[a2]['lv'] = lv
    results[a2]['beta1'] = w1
    results[a2]['beta2'] = w2
    results[a2]['baseline'] = b

    x0 = model_output.x

f2, ax2 = plt.subplots(1, 2)
best = 0
for k in results.keys():
Beispiel #2
0
                            x0, (rec),
                            options={
                                'gtol': 1e-6,
                                'disp': True
                            })
weights = model_output.x
g1 = weights.reshape(3, nCells)[0, :]
#w1 = w1 / np.linalg.norm(w1)
d1 = weights.reshape(3, nCells)[1, :]
b = weights.reshape(3, nCells)[-1, :]

# compute model prediction
mse, pred = glm.pupil_only_objective(weights, rec, verbose=True)

# compute prediction correlation, save model prediction, weights, and latent variable
cc = glm.corrcoef_by_neuron(rec['resp']._data, pred)
mse = glm.mean_square_error(rec['resp']._data, pred)
results = {}
results['cc'] = cc
results['mse'] = mse
results['pred'] = pred
results['gain'] = g1
results['dc'] = d1
results['baseline'] = b

# create plots to evaluate outcome of fits

plt.figure(figsize=(6, 4))
ax2 = plt.subplot2grid((1, 2), (0, 0), rowspan=1, colspan=1)
ax3 = plt.subplot2grid((1, 2), (0, 1), rowspan=1, colspan=1)