def showSampleModelsPanel(): loadVerySimpleCellButton = G.addButton('Very simple cell', loadModule, extraData={ 'module': 'verysimple_cell', 'model': 'VerySimpleCell', 'action': 'loadModel' }) loadSimpleCellButton = G.addButton('Simple cell', loadModule, extraData={ 'module': 'simple_cell', 'model': 'SimpleCell', 'action': 'loadModel' }) loadSimpleNetworkButton = G.addButton('Simple network', loadModule, extraData={ 'module': 'simple_network', 'model': 'SimpleNetwork', 'action': 'loadModel' }) loadModelPanel = G.addPanel('Load Models', items=[ loadVerySimpleCellButton, loadSimpleCellButton, loadSimpleNetworkButton ], widget_id='loadModelPanel', positionX=90, positionY=10) loadModelPanel.display()
def analysis(self): #from matplotlib import pyplot #pyplot.figure(figsize=(8,4)) # Default figsize is (8,6) #pyplot.plot(self.t_vec, self.v_vec) #pyplot.xlabel('time (ms)') #pyplot.ylabel('mV') #pyplot.show() G.plotVariable('Plot', ['VerySimpleCell.v_vec'])
def showAnalysisPanel(): analysisButton = G.addButton('Plot', loadModule, extraData={'action': 'analysis'}) analysisPanel = G.addPanel('Analysis', items=[analysisButton], widget_id='analysisPanel', positionX=90, positionY=250) analysisPanel.display()
def analysis(self): #from matplotlib import pyplot # pyplot.figure(figsize=(8,4)) # Default figsize is (8,6) # pyplot.plot(self.t_vec, self.v_vec_soma, label='soma') # pyplot.plot(self.t_vec, self.v_vec_dend, 'r', label='dend') # pyplot.xlabel('time (ms)') # pyplot.ylabel('mV') # pyplot.legend() # pyplot.show() #plot voltage vs time G.plotVariable('Plot', ['SimpleCell.v_vec_dend', 'SimpleCell.v_vec_soma'])
def plot_voltage(self): """Plot the recorded traces""" #pyplot.figure(figsize=(8,4)) # Default figsize is (8,6) #pyplot.plot(self.t_vec, self.soma_v_vec, color='black', label='soma(0.5') #pyplot.plot(self.t_vec, self.dend_v_vec, color='red', label='dend(0.5)') #pyplot.legend() #pyplot.xlabel('time (ms)') #pyplot.ylabel('mV') #pyplot.ylim(-80,20) #pyplot.title('Cell voltage') #pyplot.show() G.plotVariable('Plot', ['SimpleNetwork.soma_v_vec_' + str(self.cell_index), 'SimpleNetwork.dend_v_vec_' + str(self.cell_index)])
def loadModel(self): G.createProject(name = 'Simple Cell') print('Loading Model...') self.soma = h.Section(name='soma') self.dend = h.Section(name='dend') self.dend.connect(self.soma(1)) # Surface area of cylinder is 2*pi*r*h (sealed ends are implicit). self.soma.L = self.soma.diam = 12.6157 # Makes a soma of 500 microns squared. self.dend.L = 200 # microns self.dend.diam = 1 # microns for sec in h.allsec(): sec.Ra = 100 # Axial resistance in Ohm * cm sec.cm = 1 # Membrane capacitance in micro Farads / cm^2 # Insert active Hodgkin-Huxley current in the soma self.soma.insert('hh') self.soma.gnabar_hh = 0.12 # Sodium conductance in S/cm2 self.soma.gkbar_hh = 0.036 # Potassium conductance in S/cm2 self.soma.gl_hh = 0.0003 # Leak conductance in S/cm2 self.soma.el_hh = -54.3 # Reversal potential in mV # Insert passive current in the dendrite self.dend.insert('pas') self.dend.g_pas = 0.001 # Passive conductance in S/cm2 self.dend.e_pas = -65 # Leak reversal potential mV self.dend.nseg = 10 # add synapse (custom channel) self.syn = h.AlphaSynapse(self.dend(1.0)) self.syn.e = 0 # equilibrium potential in mV self.syn.onset = 20 # turn on after this time in ms self.syn.gmax = 0.05 # set conductance in uS self.syn.tau = 0.1 # set time constant # record soma voltage and time self.t_vec = h.Vector() self.t_vec.record(h._ref_t) G.createStateVariable(id = 'time', name = 'time', units = 'ms', neuron_variable = self.t_vec) self.v_vec_soma = h.Vector() self.v_vec_soma.record(self.soma(1.0)._ref_v) # change recoding pos #TODO How do we extract the units? G.createStateVariable(id = 'v_vec_soma', name = 'v_vec_soma', units = 'mV', neuron_variable = self.v_vec_soma) self.v_vec_dend = h.Vector() self.v_vec_dend.record(self.dend(1.0)._ref_v) #TODO How do we extract the units? G.createStateVariable(id = 'v_vec_dend', name = 'v_vec_dend', units = 'mV', neuron_variable = self.v_vec_dend) # run simulation h.tstop = 60 # ms
def set_recording(self): """Set soma, dendrite, and time recording vectors on the cell. """ self.soma_v_vec = h.Vector() # Membrane potential vector at soma self.dend_v_vec = h.Vector() # Membrane potential vector at dendrite self.t_vec = h.Vector() # Time stamp vector self.soma_v_vec.record(self.soma(0.5)._ref_v) G.createStateVariable(id = 'soma_v_vec_' + str(self.cell_index), name = 'soma_v_vec for cell ' + str(self.cell_index), units = 'mV', neuron_variable = self.soma_v_vec) self.dend_v_vec.record(self.dend(0.5)._ref_v) G.createStateVariable(id = 'dend_v_vec_' + str(self.cell_index), name = 'dend_v_vec for cell ' + str(self.cell_index), units = 'mV', neuron_variable = self.dend_v_vec) self.t_vec.record(h._ref_t) G.createStateVariable(id = 'time', name = 'time', units = 'ms', neuron_variable = self.t_vec)
def loadModel(self): G.createProject(name='Very Simple Cell') print('Loading Model...') self.soma = h.Section(name='soma') self.soma.insert('pas') self.asyn = h.AlphaSynapse(self.soma(0.5)) self.asyn.onset = 20 self.asyn.gmax = 1 self.v_vec = h.Vector() # Membrane potential vector self.t_vec = h.Vector() # Time stamp vector self.v_vec.record(self.soma(0.5)._ref_v) G.createStateVariable(id='v_vec', name='v_vec', units='mV', neuron_variable=self.v_vec) self.t_vec.record(h._ref_t) G.createStateVariable(id='time', name='time', units='ms', neuron_variable=self.t_vec) h.tstop = 80.0
def showRunControlPanel(): # Init Panel initPanel = G.addTextFieldAndButton("Init", 'v_init', True, ['h.stdinit()']) # Init Run Button initRunButton = G.addButton('Init & Run', ['current_experiment.state = "RUNNING"', 'h.run()', 'current_experiment.state = "COMPLETED"']) # Stop Button stopButton = G.addButton('Stop') stopButton.on_click(['h.stoprun = 1']) # Continue til continueTilPanel = G.addTextFieldAndButton("Continue til", 'runStopAt', True, ['h.continuerun(runStopAt)', 'h.stoprun=1']) # Continue for continueForPanel = G.addTextFieldAndButton("Continue for", 'runStopIn', True, ['h.continuerun(t + runStopIn)', 'h.stoprun=1']) # Single Step singleStepButton = G.addButton('Single Step', ['h.steprun()']) # t Panel timePanel = G.addTextFieldAndButton("t", 't', False, []) # TStop Panel stopPanel = G.addTextFieldAndButton("Tstop", 'tstop', True, ['h.tstop_changed()']) # dt Panel dtPanel = G.addTextFieldAndButton("dt", 'dt', True, ['h.setdt()']) # Points plotted Panel pointsPlottedPanel = G.addTextFieldAndButton("Points plotted/ms", 'steps_per_ms', True, ['h.setdt()']) # Scrn update invl Panel scrnUpdateInvlPanel = G.addTextFieldAndButton("Scrn update invl", 'screen_update_invl', True, []) # Real Time Texfield realTimePanel = G.addTextFieldAndButton("Real Time", 'realtime', False, []) # Init main panel runControlPanel = G.addPanel('Run Control', items = [initPanel, initRunButton, stopButton, continueTilPanel, continueForPanel, singleStepButton, timePanel, stopPanel, dtPanel, pointsPlottedPanel, scrnUpdateInvlPanel, realTimePanel], widget_id = 'runControlPanel', positionX =600, positionY=10) runControlPanel.display()
def __init__(self, numcells): G.createProject(name = 'Simple Network') self.spkt = h.Vector() # Spike time of all cells self.spkid = h.Vector() # cell ids of spike times self.create_cells(numcells) # call method to create cells