states = [ 'hand_px', 'hand_py', 'hand_pz', 'hand_vx', 'hand_vy', 'hand_vz', 'offset' ] decoding_states = ['hand_vx', 'hand_vz', 'offset'] # TODO transpose beta matrix truedata = loadmat( '/Users/sgowda/bmi/workspace/adaptive_ppf/ppf_test_case_matlab_output.mat') a_ppf = truedata['A'][0, 0] w_ppf = truedata['W'][0, 0] A = np.mat(np.diag([a_ppf, a_ppf, 1])) W = np.mat(np.diag([w_ppf, w_ppf, 0])) # Instantiate PPF ppf = ppfdecoder.PointProcessFilter(A, W, beta.T, T_loop) ppf._init_state() decoded_output = np.zeros([3, n_iter]) for idx in range(1, n_iter): ppf(spike_counts[idx, :]) decoded_output[:, idx] = ppf.get_mean() x_est = truedata['x_est'] plt.figure() plt.hold(True) plt.plot(x_est[0, :n_iter], label='matlab') plt.plot(hand_vel[0, :n_iter], label='handvel') plt.plot(decoded_output[0, :], label='pyth') plt.legend() plt.show()
updater_cont = clda.PPFContinuousBayesianUpdater(decoder_rml) updater_cont.rho = -1 ## RUN n_iter = X.shape[0] spike_counts = data['spike_counts'] beta_hist = [] beta_cont_hist = np.zeros([n_iter, n_neurons, 3]) beta_cont_hist[0, :, -1] = beta[:, -1] I = np.mat(np.eye(3 * n_neurons)) R_diag_neuron = 1e-4 * np.array([0.13, 0.13, 0.06 / 50]) R = np.diag(np.tile(R_diag_neuron, (n_neurons, ))) meta_ppf = ppfdecoder.PointProcessFilter(I, R, np.zeros(3 * n_neurons), dt=dt) meta_ppf._init_state(init_state=beta_cont_hist[0, :, :].ravel(), init_cov=R) n_iter = 60000 for n in range(1, n_iter): if n % batch_size == 0: print(n) int_kin = np.hstack([np.zeros(3), X[n, 0], 0, X[n, 1], 1]) beta_C = np.array([X[n, 0], X[n, 1], 1]) learner(spike_counts[n - 1, :].reshape(-1, 1), int_kin) if learner.is_ready(): # calc beta est from batch int_kin_batch, spike_counts_batch = learner.get_batch() beta_hist.append(decoder_sb.filt.C) new_params = updater_sb.calc(int_kin_batch, spike_counts_batch, rho,