analyse_replay = True TFR = True save = False verbose = True f_in = "wmx_%s_%.1f_linear.pkl" % ( STDP_mode, place_cell_ratio) if linear else "wmx_%s_%.1f.pkl" % ( STDP_mode, place_cell_ratio) PF_pklf_name = os.path.join(base_path, "files", "PFstarts_%s_linear.pkl" % place_cell_ratio) if linear else None dir_name = os.path.join( base_path, "figures", "%.2f_replay_det_%s_%.1f" % (1, STDP_mode, place_cell_ratio)) if linear else None wmx_PC_E = load_wmx(os.path.join(base_path, "files", f_in)) * 1e9 # *1e9 nS conversion SM_PC, SM_BC, RM_PC, RM_BC, selection, StateM_PC, StateM_BC = run_simulation( wmx_PC_E, STDP_mode, cue=cue, save=save, seed=seed, verbose=verbose) _ = analyse_results(SM_PC, SM_BC, RM_PC, RM_BC, selection, StateM_PC, StateM_BC, seed=seed, multiplier=1, linear=linear, pklf_name=PF_pklf_name, dir_name=dir_name, analyse_replay=analyse_replay,
Ap = 0.01 Am = -Ap wmax = 4e-8 # S scale_factor = 1.27 elif STDP_mode == "sym": taup = taum = 62.5 * ms Ap = Am = 4e-3 wmax = 2e-8 # S scale_factor = 0.62 Ap *= wmax; Am *= wmax # needed to reproduce Brian1 results f_name = os.path.join(base_path, "files", f_in) spiking_neurons, spike_times = load_spike_trains(f_name) pklf_name = os.path.join(base_path, "files", f_in_wmx) intermediate_weightmx = load_wmx(pklf_name) / scale_factor # (scale only once, at the end) weightmx = learning_2nd_env(spiking_neurons, spike_times, taup, taum, Ap, Am, wmax, intermediate_weightmx) weightmx *= scale_factor # quick and dirty additional scaling! (in an ideal world the STDP parameters should be changed to include this scaling...) pklf_name = os.path.join(base_path, "files", f_out) save_wmx(weightmx, pklf_name) plot_wmx(weightmx, save_name=f_out[:-4]) plot_wmx_avg(weightmx, n_pops=100, save_name="%s_avg"%f_out[:-4]) plot_w_distr(weightmx, save_name="%s_distr"%f_out[:-4]) selection = np.array([500, 2400, 4000, 5500, 7015]) plot_weights(save_selected_w(weightmx, selection), save_name="%s_sel_weights"%f_out[:-4]) plt.show()
return np.max(EPSP) - Vrest_Pyr/mV if __name__ == "__main__": try: n = int(sys.argv[1]) except: n = 500 # number of random weights v_hold = -70. # mV i_hold = 20.967 # pA (calculated by `clamp_cell.py`) f_in = "wmx_sym_0.5_linear.pkl" pklf_name = os.path.join(base_path, "files", "paper", f_in) wmx_PC_E = load_wmx(pklf_name) * 1e9 # *1e9 nS conversion nonzero_weights = wmx_PC_E[np.nonzero(wmx_PC_E)] print "mean(nonzero weights): %s (nS)"%np.mean(nonzero_weights) np.random.seed(12345) weights = np.random.choice(nonzero_weights, n, replace=False) EPSPs = np.zeros((n, 4000)); EPSCs = np.zeros((n, 4000)) # 4000 is hard coded for sim length peak_EPSPs = np.zeros(n); peak_EPSCs = np.zeros(n) for i, weight in enumerate(tqdm(weights)): t_, EPSP, EPSC = sym_paired_recording(weight, i_hold) EPSPs[i,:] = EPSP; EPSCs[i,:] = EPSC peak_EPSPs[i] = get_peak_EPSP(t_, EPSP, i_hold, v_hold) peak_EPSCs[i] = np.max(EPSC)
if __name__ == "__main__": try: STDP_mode = sys.argv[1] except: STDP_mode = "sym" assert STDP_mode in ["sym", "asym"] place_cell_ratio = 0.5 linear = True f_in = "wmx_%s_%.1f_linear.pkl" % ( STDP_mode, place_cell_ratio) if linear else "wmx_%s_%.1f.pkl" % ( STDP_mode, place_cell_ratio) pklf_name = os.path.join(base_path, "files", f_in) wmx_orig = load_wmx(pklf_name) #wmx_modified = shuffle(wmx_orig); f_out = "%s_shuffled_linear.pkl"%f_in[:-11] if linear else "%s_shuffled.pkl"%f_in[:-4] #wmx_modified = column_shuffle(wmx_orig); f_out = "%s_cshuffled_linear.pkl"%f_in[:-11] if linear else "%s_cshuffled.pkl"%f_in[:-4] #wmx_modified = shuffle_blocks(wmx_orig); f_out = "%s_block_shuffled_linear.pkl"%f_in[:-11] if linear else "%s_block_shuffled.pkl"%f_in[:-4] wmx_modified = binarize(wmx_orig) f_out = "%s_binary_linear.pkl" % f_in[: -11] if linear else "%s_binary.pkl" % f_in[: -4] assert np.shape(wmx_modified) == ( nPCs, nPCs), "Output shape is not %i*%i" % (nPCs, nPCs) assert (wmx_modified >= 0.0).all(), "Negative weights in the modified matrix!" pklf_name = os.path.join(base_path, "files", f_out)