import pyNN.nest as sim from pyNN.nest import native_synapse_type import nest #---Below here are functions to test the system--- RUN_DURATION = 200 TIME_STEP = 1.0 CELL_PARAMS = {'v_thresh':-48.0, 'v_reset' : -70.0, 'tau_refrac': 2.0 , 'tau_syn_E': 5.0, 'tau_syn_I' : 5.0, 'v_rest' : -65.0,'i_offset':0.0} def testCreateTwoInputs(): inputSpikeTimes0 = [10.0] inputSpikeTimes1 = [50.0] spikeArray0 = {'spike_times': [inputSpikeTimes0]} spikeGen0=sim.Population(1,sim.SpikeSourceArray,spikeArray0, label='inputSpikes_0') spikeArray1 = {'spike_times': [inputSpikeTimes1]} spikeGen1=sim.Population(1, sim.SpikeSourceArray, spikeArray1, label='inputSpikes_1') return [spikeGen0,spikeGen1] def connectInput(spikeSources,cells): weight = 0.12 firstConnector = [(0,0,weight,TIME_STEP)] firstListConnector = sim.FromListConnector(firstConnector) sim.Projection(spikeSources[0], cells, firstListConnector) secondConnector = [(0,1,weight,TIME_STEP)] secondListConnector = sim.FromListConnector(secondConnector) sim.Projection(spikeSources[1], cells, secondListConnector) def connectPop1Pop2(pop1,pop2): noisy_synapse_type = native_synapse_type('noisy_synapse') weight = 0.12 firstConnector = [(0,0,weight,TIME_STEP)] firstListConnector = sim.FromListConnector(firstConnector) #the next three work #sim.Projection(pop1, pop2, firstListConnector) #sim.Projection(pop1, pop2, firstListConnector,sim.StaticSynapse()) #sim.Projection(pop1, pop2, firstListConnector,sim.StaticSynapse(weight=1.0)) #sim.Projection(pop1, pop2, firstListConnector,noisy_synapse_type()) #sim.Projection(pop1, pop2, firstListConnector,noisy_synapse_type(weight=1.0)) #sim.Projection(pop1, pop2, firstListConnector,noisy_synapse_type(weight=1.0)) #sim.Projection(pop1, pop2, firstListConnector,noisy_synapse_type()) #sim.Projection(pop1, pop2, sim.AllToAllConnector(),synapse_type=noisy_synapse_type(w=1.0)) #sim.Projection(pop1, pop2, sim.AllToAllConnector(),synapse_type=noisy_synapse_type()) sim.Projection(pop1, pop2, sim.AllToAllConnector(),synapse_type=noisy_synapse_type(weight=1.0)) ##--main--- sim.setup(timestep= TIME_STEP, min_delay=TIME_STEP, max_delay=TIME_STEP, debug=0) nest.Install("nestmlmodule") #make neurons and make them recordable pop1=sim.Population(1,sim.IF_cond_exp,{}) pop1.record({'spikes'}) pop2=sim.Population(1,sim.IF_cond_exp,{}) pop2.record({'spikes'}) #setup input spikeGenerators = testCreateTwoInputs() connectInput(spikeGenerators,pop1) connectPop1Pop2(pop1,pop2) sim.run(RUN_DURATION) #print results pop1.write_data('pop1.pkl',['spikes']) pop2.write_data('pop2.pkl',['spikes'])