if addSynInputs != 1: stimobj = h.IClamp(model_cell.soma(0.5)) stimobj.delay = injectionStart # ms, time after start of sim when you want the current injection to begin stimobj.dur = injectionDuration # ms, duration of current pulse stimobj.amp = injectionLevel # nA # stimobj.i # nA, contains the level of current being injected at any given time during simulation ################################# # Run simulation and record results ################################# soma_v_vec, dend_v_vec, tuft_v_vec, t_vec, spike_times = simrun.set_recording_vectors( model_cell, nclist) simrun.simulate(tstop=mytstop) ################################# # Plot results and write results files ################################# with open("{}_spikes.dat".format(fstem), 'w') as f: f.write("{}\t{}\n".format("time", "cell")) i = 1 for spk in spike_times: f.write("{:.2f}\t{}\n".format(spk, i)) with open("{}_voltages.dat".format(fstem), 'w') as f: f.write("{}\t{}\t{}\t{}\n".format("time", "soma_v", "apical_v", "tuft_v")) for i, v in enumerate(soma_v_vec): f.write("{:.2f}\t{:.2f}\t{:.2f}\t{:.2f}\n".format(
# of the first cell in the network. (Named 'syn_' to avoid # being overwritten with the 'syn' var assigned later.) syn_ = h.ExpSyn(cells[0].dend[0](0.5)) stim.number = 1 stim.start = 9 ncstim = h.NetCon(stim, syn_) ncstim.delay = 1 ncstim.weight[0] = 0.04 # NetCon weight is a vector. #changing the tau to decay by 2 ms syn_.tau = 2 #plot soma_v_vec, dend_v_vec, t_vec = simrun.set_recording_vectors(cells[0]) simrun.simulate() simrun.show_output(soma_v_vec, dend_v_vec, t_vec) pyplot.show() # Set recording vectors syn_i_vec = h.Vector() syn_i_vec.record(syn_._ref_i) simrun.simulate() # Draw fig = pyplot.figure(figsize=(8, 4)) ax1 = fig.add_subplot(2, 1, 1) soma_plot = ax1.plot(t_vec, soma_v_vec, color='black') dend_plot = ax1.plot(t_vec, dend_v_vec, color='red') rev_plot = ax1.plot([t_vec[0], t_vec[-1]], [syn_.e, syn_.e],
stim.amp = 0.2 soma_v_vec, soma_m_vec, soma_h_vec, soma_n_vec,\ soma_inap_vec, soma_idap_vec, soma_ical_vec,\ soma_ican_vec, soma_ikca_vec, soma_ina_vec, soma_ikrect_vec,\ dend_v_vec, t_vec\ = simrun.set_recording_vectors(cells[0]) # Set recording vectors syn_i_vec = h.Vector() syn_i_vec.record(stim._ref_i) h.v_init = -65 fih = h.FInitializeHandler(2,(tweak_leak,(cells,N))) simrun.simulate() # Draw fig = pyplot.figure(figsize=(8,4)) ax1 = fig.add_subplot(2,1,1) soma_plot = ax1.plot(t_vec, soma_v_vec, color='black') dend_plot = ax1.plot(t_vec, dend_v_vec, color='red') #rev_plot = ax1.plot([t_vec[0], t_vec[-1]], [syn_.e, syn_.e], # color='blue', linestyle=':') ax1.legend(soma_plot + dend_plot, ['soma', 'dend(0.5)', 'syn reversal']) ax1.set_ylabel('mV') ax1.set_xlim([25,125]) #ax1.set_xticks([]) # Use ax2's tick labels ax2 = fig.add_subplot(2,1,2, sharex = ax1)
stim2.amp = 0 #stim.amp = stim.amp-stim2.amp #stim.amp = 0 soma_v_vec, soma_m_vec, soma_h_vec, soma_n_vec,\ soma_inap_vec, soma_idap_vec, soma_ical_vec,\ soma_ican_vec, soma_ikca_vec, soma_ina_vec, soma_ikrect_vec,\ dend_v_vec, t_vec\ = simrun.set_recording_vectors(cells[0]) # Set recording vectors syn_i_vec = h.Vector() syn_i_vec.record(cells[0].syn_I._ref_i) simrun.simulate() vs = numpy.array(soma_v_vec.to_python()) vd = numpy.array(dend_v_vec.to_python()) t = numpy.array(t_vec.to_python()) tempVrest = vs[abs(t - 9195) < 2 * h.dt] Vrest = tempVrest[0] tempVrest = vd[abs(t - 9195) < 2 * h.dt] Vrestd = tempVrest[0] #time.sleep(1) lWid = 1 soma_plot = ax1a.semilogy(t - 9198, vs - Vrest, color='black', lw=lWid) dend_plot = ax1a.semilogy(t - 9198, vd - Vrestd, color='red', lw=lWid) ax1a.set_ylim([0.1, 2]) ax1a.set_xlim([0, 20])