def two_stn_cell(): current_unit = b2.pA par_sim['simulation_time'] = 2000 * b2.ms start_time = time() fig, ax = plt.subplots(3, figsize=(10, 5), sharex=True) i_stim = [0.] for ii in range(len(i_stim)): st_mon = simulate_2_STN_cell_biexp(par, par_sim) plot_data(st_mon, ax[ii], index=1) ax[0].plot(st_mon.t / b2.ms, st_mon.vs[0] / b2.mV, lw=2, c='b', label="0") ax[0].plot(st_mon.t / b2.ms, st_mon.vs[1] / b2.mV, lw=2, c='r', label="1") ax[1].plot(st_mon.t/b2.ms, st_mon.s_ss[0], lw=2, c='b', label="0") ax[1].plot(st_mon.t/b2.ms, st_mon.s_ss[1], lw=2, c='r', label="1") ax[0].legend() ax[1].legend() ax[0].set_xlim(0, np.max(st_mon.t / b2.ms)) ax[0].set_ylabel("v [mV]", fontsize=14) ax[1].set_ylabel("s_syn", fontsize=14) ax[-1].plot(st_mon.t / b2.ms, st_mon.i_syn_ss[1] / current_unit, lw=1, c='k', alpha=0.5) ax[-1].set_xlabel("t [ms]", fontsize=14) ax[-1].set_ylabel("I_syn [{}]".format(str(current_unit)), fontsize=14) # ax[-1].set_xlim(300, 330) print("Done in {}".format(time() - start_time)) plt.tight_layout() plt.savefig('figure_2_stn.png') plt.show()
def plot_details(filename='figure_1.png'): par['record_from'] = [ "vg", "Iapp", "iNap", "iNaf", 'iKv2', 'iKv3', 'iKv4f', 'iKv4s', 'iCah', 'iSk', 'iKcnq' ] par_sim['simulation_time'] = 100 * b2.ms current_unit = b2.uA start_time = time() i_stim = [2.0] _, ax = plt.subplots(len(i_stim) + 1, figsize=(6, 8), sharex=True) # make_grid(nrows, ncols, left, right, hspace, wspace, bottom, top) ax = make_grid(3, 1, 0.2, 0.95, 0.18, 0, 0.1, 0.95) for ii in range(len(i_stim)): input_current = get_step_current(50, 100, b2.ms, i_stim[ii] * current_unit) par['iapp'] = input_current st_mon = simulate_GPe_cell(par, par_sim) plot_data(st_mon, ax[ii], lw=1, c='k') # plot_current(st_mon, ax[-2], current_unit) plot_channel_currents(st_mon, ax[1:], current_unit) ax[0].set_xlim(75, 90) ax[1].set_xlim(75, 90) ax[2].set_xlim(75, 90) print("Done in {:.3f}".format(time() - start_time)) plt.savefig(filename) plt.close()
def figure2(): fig = plt.figure(figsize=(10, 6)) gs = GridSpec(6, 1) gs.update(left=0.1, right=0.95) ax1 = plt.subplot(gs[:2]) ax2 = plt.subplot(gs[2]) ax3 = plt.subplot(gs[3:5]) ax4 = plt.subplot(gs[5]) ax = [ax1, ax2, ax3, ax4] start_time = time() I_sm1 = b2.TimedArray([0, 2, 0, 5, 0, 10, 0]*b2.pA, dt=100*b2.ms) par_sim['I_sm'] = I_sm1 state_monitor = simulate_Thl_cell_fig2(par, par_sim) plot_data(state_monitor, ax[0]) plot_current(state_monitor, ax[1]) I_sm2 = b2.TimedArray([0, 0, -0.5, 0, 0, -1, 0, 0]*b2.pA, dt=100*b2.ms) par_sim['I_sm'] = I_sm2 par['i_ext'] = 0.0 state_monitor = simulate_Thl_cell_fig2(par, par_sim) print("Done in {}".format(time() - start_time)) plot_data(state_monitor, ax[2]) plot_current(state_monitor, ax[3], xlabel="Time [ms]") [ax[i].set_xticks([]) for i in range(3)] [ax[i].set_xlim([0, 1000]) for i in range(4)] plt.savefig(join("data", "figure2.png")) plt.show()
def figure3(): fig, ax = plt.subplots(nrows=2, ncols=1, figsize=(10, 4), sharex=True) start_time = time() par_sim['I_sm'] = 0*b2.pA par_sim['i_ext'] = 0.*b2.pA par_ = {**par, **par_SM} state_monitor = simulate_Thl_cell_fig3(par_, par_sim) plot_data(state_monitor, ax[0]) plot_current(state_monitor, ax[1]) plt.savefig(join("data", "figure3.png")) plt.show() print("Done in {}".format(time() - start_time))
def plot_fig_1e(): start_time = time() fig, ax = plt.subplots(4, figsize=(10, 6), sharex=True) t_stim = [300, 450, 600] for ii in range(len(t_stim)): input_current = get_step_current(500, 500 + t_stim[ii], b2.ms, -25 * b2.pA) par['i_ext'] = input_current st_mon = simulate_STN_cell(par, par_sim) plot_data(st_mon, ax[ii]) plot_current(st_mon, ax[3]) print("Done in {}".format(time() - start_time)) plt.tight_layout() plt.savefig('figure_1e.png') plt.close()
def plot_fig_1f(): current_unit = b2.pA start_time = time() fig, ax = plt.subplots(4, figsize=(10, 6), sharex=True) i_stim = [-20, -30, -40] for ii in range(len(i_stim)): input_current = get_step_current(500, 800, b2.ms, i_stim[ii] * current_unit) par['i_ext'] = input_current st_mon = simulate_STN_cell(par, par_sim) plot_data(st_mon, ax[ii]) plot_current(st_mon, ax[3], current_unit) print("Done in {}".format(time() - start_time)) plt.tight_layout() plt.savefig('figure_1f.png') plt.close()
def plot(): current_unit = b2.uA start_time = time() i_stim = [2, 4, 6] _, ax = plt.subplots(len(i_stim)+1, figsize=(10, 6), sharex=True) for ii in range(len(i_stim)): input_current = get_step_current(200, 700, b2.ms, i_stim[ii] * current_unit) par['i_ext'] = input_current st_mon = simulate_FSI_cell(par, par_sim) plot_data(st_mon, ax[ii]) plot_current(st_mon, ax[3], current_unit) print("Done in {:.3f}".format(time() - start_time)) plt.tight_layout() plt.savefig('data/figure_1.png') plt.close()
def plot(filename="figure_0.png"): par['record_from'] = ["vg", "Iapp"] par_sim['simulation_time'] = 500.0 * b2.ms current_unit = b2.uA start_time = time() i_stim = [2.0] _, ax = plt.subplots(len(i_stim) + 1, figsize=(10, 5), sharex=True) for ii in range(len(i_stim)): input_current = get_step_current(100, 300, b2.ms, i_stim[ii] * current_unit) par['iapp'] = input_current st_mon = simulate_GPe_cell(par, par_sim) plot_data(st_mon, ax[ii], lw=1, c='k') plot_current(st_mon, ax[-1], current_unit) # plot_channel_currents(st_mon, ax[-1], current_unit) ax[0].set_xlim(0, 500) print("Done in {:.3f}".format(time() - start_time)) plt.tight_layout() plt.savefig(filename) plt.close()
def simulate_2_gpe_cell(): start_time = time() current_unit = b2.pA par_sim['simulation_time'] = 300 * b2.ms fig, ax = plt.subplots(3, figsize=(10, 6), sharex=True) par_g['iapp'] = -0.5 * b2.pA st_mon = simulate_two_GPe_cell(par_g, par_sim) plot_data(st_mon, ax[0]) ax[0].plot(st_mon.t / b2.ms, st_mon.vg[0] / b2.mV, lw=2, c='b', label="0") ax[0].plot(st_mon.t / b2.ms, st_mon.vg[1] / b2.mV, lw=2, c='r', label="1") ax[1].plot(st_mon.t / b2.ms, st_mon.s_gg[0], lw=2, c='b', label="0") ax[1].plot(st_mon.t / b2.ms, st_mon.s_gg[1], lw=2, c='r', label="1") ax[0].legend() ax[1].legend() ax[0].set_xlim(0, np.max(st_mon.t / b2.ms)) ax[0].set_ylabel("v [mV]", fontsize=14) ax[1].set_ylabel("s_syn", fontsize=14) ax[-1].plot(st_mon.t / b2.ms, st_mon.i_syn_gg[1] / current_unit, lw=1, c='k', alpha=0.5) ax[-1].set_xlabel("t [ms]", fontsize=14) ax[-1].set_ylabel("I_syn [{}]".format(str(current_unit)), fontsize=14) # ax[-1].set_xlim(290, 310) print("Done in {} seconds".format(time() - start_time)) plt.tight_layout() plt.savefig('figure_2_gpe.png') plt.close()
def simulate_1_gpe_cell(): start_time = time() current_unit = b2.pA # Figure 2 ------------------------------------------------------ fig, ax = plt.subplots(5, figsize=(10, 8)) i_stim = [20, 0, -0.5, 170.] for ii in range(len(i_stim)): input_current = get_step_current(0, 1000, b2.ms, i_stim[ii] * current_unit) if ii == 3: input_current = get_step_current(100, 250, b2.ms, i_stim[ii] * current_unit) par_sim['simulation_time'] = 350 * b2.ms par_g['i_ext'] = input_current st_mon = simulate_GPe_cell(par_g, par_sim) plot_data(st_mon, ax[ii], title=str(i_stim[ii])) plot_current(st_mon, current_unit, ax[-1], [-1, 22]) print("Done in {} seconds".format(time() - start_time)) plt.tight_layout() plt.savefig('figure_2.png') plt.close()
def plot(): current_unit = b2.uA start_time = time() i_stim = [1.67] _, ax = plt.subplots(len(i_stim) + 3, figsize=(10, 7), sharex=True) for ii in range(len(i_stim)): input_current = b2.TimedArray([0, i_stim[ii], 0, i_stim[ii], 0] * b2.uA, dt=200 * b2.ms) # input_current = get_step_current(50, # 200, # b2.ms, # i_stim[ii] * current_unit) par['iapp'] = input_current st_mon = simulate_MSN_cell(par, par_sim) plot_data(st_mon, ax[ii], lw=1, c='k') plot_h(st_mon, ax[-2]) plot_m(st_mon, ax[-3]) plot_current(st_mon, ax[-1], current_unit) print("Done in {:.3f}".format(time() - start_time)) plt.tight_layout() plt.savefig('data/figure_1.png') plt.close()
'tau_peak_i': tau_peak_i * b2.ms, } par_syn = { 'v_rev_e': 0 * b2.mV, 'v_rev_i': -75 * b2.mV, 'w_ei': 1, 'w_ie': 1, 'w_ee': 1, 'w_ii': 1, 'p_ie': p_ie, 'p_ei': p_ei, 'p_ee': p_ee, 'p_ii': p_ii, } par_e['tau_dq_e'] = tau_d_q_function(tau_d_e, tau_r_e, tau_peak_e) * b2.ms par_i['tau_dq_i'] = tau_d_q_function(tau_d_i, tau_r_i, tau_peak_i) * b2.ms par_syn['g_ei'] = g_hat_ei / (num_e * p_ei) * b2.msiemens par_syn['g_ee'] = g_hat_ee / (num_e * p_ee) * b2.msiemens par_syn['g_ie'] = g_hat_ie / (num_i * p_ei) * b2.msiemens par_syn['g_ii'] = g_hat_ii / (num_i * p_ii) * b2.msiemens par_e['I_e'] = 1.4 * np.ones(num_e) * (1 + sigma_e * randn(num_e)) * b2.uA par_i['I_i'] = 0.0 * np.ones(num_i) * (1 + sigma_i * randn(num_i)) * b2.uA par_sim = {'simulation_time': 200 * b2.ms, 'integration_method': 'rk4'} monitors = simulate_PING(par_e, par_i, par_syn, par_sim) print("done in {}".format(time.time() - start_time)) plot_data(monitors, num_e, num_i)