############################################################################### # To stimulate the network, we create a ``poisson_generator`` and set it up to # fire with a rate of 100000 spikes per second. It is connected to the # neurons of the pre-synaptic population. pg = nest.Create("poisson_generator", params={"rate": 100000.0}) nest.Connect(pg, pre, "all_to_all") ############################################################################### # To measure and record the membrane potentials of the neurons, we create a # ``voltmeter`` and connect it to all post-synaptic nodes. vm = nest.Create("voltmeter") nest.Connect(vm, post, "all_to_all") ############################################################################### # We save the whole connection graph of the network as a PNG image using the # ``plot_network`` function of the ``visualization`` submodule of PyNEST. allnodes = pg + pre + post + vm visualization.plot_network(allnodes, "csa_example_graph.png") ############################################################################### # Finally, we simulate the network for 50 ms. The voltage traces of the # post-synaptic nodes are plotted. nest.Simulate(50.0) voltage_trace.from_device(vm) voltage_trace.show()
fname.write('time' + dlm + 'weight' + dlm + 'n' + dlm + 'c' + nl) def get_neuron1_prop(property_name): return str( nest.GetStatus(nest.FindConnections( neuron1, synapse_model="sero"))[0][property_name]) # Run simualtion weight = None for t in np.arange(0, T + dt, dt): if nest.GetStatus(neuron2)[0]['local']: data = str(t) + dlm + get_neuron1_prop( 'weight') + dlm + get_neuron1_prop('n') + dlm + get_neuron1_prop( 'c') + nl fname.write(data) nest.Simulate(dt) print '///////////////////////////////// ' + str( t / T * 100) + ' % completed' if nest.GetStatus(neuron2)[0]['local']: print("weight = " + str(weight) + " pA") fname.close() print("Eligibility trace = " + get_neuron1_prop('c')) print("Serotonin conc-on = " + get_neuron1_prop('n')) plot.from_device(voltmeter, timeunit="s") plot.show()
# Tab delimiter in a string dlm = '\t' # Next line symbol nl = '\n' # Set-up file header: time[ms], connection weight, serotonin concentration, eligibility trace fname.write('time'+ dlm + 'weight' + dlm + 'n' + dlm + 'c' + nl) def get_neuron1_prop(property_name): return str(nest.GetStatus(nest.FindConnections(neuron1, synapse_model="sero"))[0][property_name]) # Run simualtion weight = None for t in np.arange(0, T + dt, dt): if nest.GetStatus(neuron2)[0]['local']: data = str(t) + dlm + get_neuron1_prop('weight') + dlm + get_neuron1_prop('n') + dlm + get_neuron1_prop('c') + nl fname.write(data) nest.Simulate(dt) print '///////////////////////////////// ' + str(t/T * 100) + ' % completed' if nest.GetStatus(neuron2)[0]['local']: print("weight = " + str(weight) + " pA") fname.close() print("Eligibility trace = " + get_neuron1_prop('c')) print("Serotonin conc-on = " + get_neuron1_prop('n')) plot.from_device(voltmeter, timeunit="s") plot.show()
Vm = events["V_m"] Vm_exp = Vm[np.where(senders == n_exp)] Vm_cond = Vm[np.where(senders == n_cond)] Vm_exp_b4 = Vm[np.logical_and(times < 199, senders == n_exp)] Vm_cond_b4 = Vm[np.logical_and(times < 199, senders == n_cond)] print "Amplitudes of psc_exp and cond_exp before spike" print np.mean(Vm_exp_b4), np.mean(Vm_cond_b4) print "Amplitudes of psc_exp and cond_exp after spike" print max(Vm_exp), max(Vm_cond) print "PSP sizes for psc_exp and cond_exp after spike" print np.mean(Vm_exp_b4) - max(Vm_exp), np.mean(Vm_cond_b4) - max(Vm_cond) print np.argmax(Vm_exp), np.argmax(Vm_cond) vt.from_device(mm) vt.show() # V_m baseline for I_e = 300 / 200: -58. # V_m baseline for I_e = -300 / -200: -82. # SOLUTION # With +ve background #Amplitudes of psc_exp and cond_exp before spike #-62.4800000189 -62.5000288791 #Amplitudes of psc_exp and cond_exp after spike #-62.4746501618 -62.4529781256 #PSP sizes for psc_exp and cond_exp after spike #-0.00534985715843 -0.0470507534623 # Without +ve background #Amplitudes of psc_exp and cond_exp before spike