""" This is the code for lab1. It's python. If code is inside these triple quotes, it's a comment. You can also have a comment from a #, but it's just until the end of the line. """ #import the cod for the pyNN nest interface. import pyNN.nest as sim #set up some constants in all caps for my style. RUN_DURATION = 100 TIME_STEP = 1.0 numberNeurons = 2 #Anything that starts with a def is a function. #Remember python uses indenting for blocks. So this one ends at the #next def. def makeDCSource(): clamp = sim.DCSource(amplitude=0.8, start=20.0, stop=80.0) return (clamp) #Python functions don't need to return anything. def makeSynapses(cells): #Make a spike source inputSpikeTimes = [10.0,20.0,40.0,70] spikeArray = {'spike_times': [inputSpikeTimes]} spikeGen=sim.Population(1,sim.SpikeSourceArray,spikeArray, label='inputSpikes_0') #make a synapse firingWt = 0.2 connector = [] connector = connector + [(0,0,firingWt,TIME_STEP)] fromListConnector = sim.FromListConnector(connector) sim.Projection(spikeGen, cells, fromListConnector, receptor_type='excitatory') #----main--- sim.setup(timestep=TIME_STEP,min_delay=TIME_STEP, max_delay=TIME_STEP, debug=0) cells=sim.Population(numberNeurons,sim.IF_cond_exp, cellparams={}) cells.record({'spikes'}) #Step 2 #dCSource = makeDCSource() #cells.inject(dCSource) #step 3 #cells[0].inject(dCSource) #step4 makeSynapses(cells) sim.run(RUN_DURATION) cells.write_data("lab1Spikes.pkl",'spikes')