""" This is the lab2. It's playing with Izhikevich neurons. """ #import the cod for the pyNN nest interface. import pyNN.nest as sim from pyNN.utility import normalized_filename #set up some constants in all caps for my style. #RUN_DURATION = 200 RUN_DURATION = 100 TIME_STEP = 0.1 numberNeurons = 3 def init(): sim.setup(timestep=TIME_STEP,min_delay=TIME_STEP, max_delay=TIME_STEP) def makeNeurons(): #These are the default values cellparams cells=sim.Population(numberNeurons,sim.HH_cond_exp,cellparams={}) #step 3 cells[1].e_rev_leak=-60.0 #change the leak param cells[2].e_rev_leak=-70.0 #change the leak param #step 5 #cells[1].v_offset=-59.0 #change v_offset #step 6 cells[1].e_rev_Na= 60.0 #step 7 cells[1].e_rev_E= 20.0 cells[1].e_rev_K= -100.0 cells[0].e_rev_leak=-60.0 #change the leak param cells[0].e_rev_Na= 60.0 cells[0].e_rev_K= -100.0 #step 2 #print(sim.HH_cond_exp.recordable) #print("default v_offset", cells[0].v_offset) #print("default e_rev_leak", cells[0].e_rev_leak) #print("default e_rev_K", cells[0].e_rev_K) #print("default e_rev_Na", cells[0].e_rev_Na) #print("default e_rev_E", cells[0].e_rev_E) #print("default e_rev_I", cells[0].e_rev_I) cells.record({'spikes','v'}) return (cells) def makeDCSource(): clamp = sim.DCSource(amplitude=0.1, start=20.0, stop=80.0) return (clamp) def useDCSource(neuronsToClamp): dCSource = makeDCSource() neuronsToClamp[0].inject(dCSource) neuronsToClamp[1].inject(dCSource) neuronsToClamp[2].inject(dCSource) def plotIt(population): from pyNN.utility.plotting import Figure, Panel figure_filename = normalized_filename(".", "lab1a voltage", "png", "nest") panels = [] for variable in ('v'): panels.append( Panel(population.get_data().segments[0].filter(name=variable)[0], data_labels=[population.label], yticks=True), ) # add ylabel to top panel in each group panels[0].options.update(ylabel='Membrane potential (mV)') # add xticks and xlabel to final panel panels[-1].options.update(xticks=True, xlabel="Time (ms)") Figure(*panels, title="Hodgkin Huxley Neurons", annotations="Simulated with NEST" ).save(figure_filename) print(figure_filename) #----main--- init() cells = makeNeurons() #step 4 #useDCSource(cells) sim.run(RUN_DURATION) cells.write_data("lab3Spikes.pkl",'spikes') cells.write_data("lab3Voltage.pkl",'v') plotIt(cells)