def __init__(self): logging.debug('Loading PTcell') neuron_utils.createProject(name='PTcell Neuron') resource_package = "neuron_ui" resource_path = '/'.join(('models', 'PTcell.hoc')) filepath = pkg_resources.resource_filename(resource_package, resource_path) h.load_file(filepath) self.PTCell = h.PTcell() self.t_vec = h.Vector() self.t_vec.record(h._ref_t) neuron_utils.createStateVariable(id='time', name='time', units='ms', python_variable={ "record_variable": self.t_vec, "segment": None }) neuron_geometries_utils.extractGeometries() logging.debug('PTcell loaded')
def __init__(self): print("loading very simple cell") neuron_utils.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) neuron_utils.createStateVariable(id='v_vec', name='v_vec', units='ms', python_variable={ "record_variable": self.v_vec, "segment": self.soma(0.5) }) self.t_vec.record(h._ref_t) neuron_utils.createStateVariable(id='time', name='time', units='ms', python_variable={ "record_variable": self.t_vec, "segment": None }) h.tstop = 80.0 neuron_geometries_utils.extractGeometries()
def __init__(self): logging.debug('Loading HNN') neuron_utils.createProject(name='HNN') import run self.t_vec = h.Vector() self.t_vec.record(h._ref_t) neuron_utils.createStateVariable(id='time', name='time', units='ms', python_variable={ "record_variable": self.t_vec, "segment": None }) neuron_geometries_utils.extractGeometries() logging.debug('HNN loaded') self.RunSimButton = neuron_utils.add_button('Run', extraData={'commands': []}) self.StopSimButton = neuron_utils.add_button( 'Stop', extraData={'commands': []}) self.SetParams = neuron_utils.add_button('Set Parameters') self.BasePanel = neuron_utils.add_panel( 'HNN Control', items=[self.RunSimButton, self.StopSimButton, self.SetParams], widget_id='hnnBasePanel') self.BasePanel.on_close(self.close) self.BasePanel.display()
def __init__(self, N=5, stim_w=0.004, stim_number=1, syn_w=0.01, syn_delay=5): """ :param N: Number of cells. :param stim_w: Weight of the stimulus :param stim_number: Number of spikes in the stimulus :param syn_w: Synaptic weight :param syn_delay: Delay of the synapse """ neuron_utils.createProject(name='Ring') self._N = N # Total number of cells in the net self.cells = [] # Cells in the net self.nclist = [] # NetCon list self.stim = None # Stimulator self.stim_w = stim_w # Weight of stim self.stim_number = stim_number # Number of stim spikes self.syn_w = syn_w # Synaptic weight self.syn_delay = syn_delay # Synaptic delay self.t_vec = h.Vector() # Spike time of all cells self.id_vec = h.Vector() # Ids of spike times self.set_numcells(N) # Actually build the net. self.time_vec = h.Vector() # Time stamp vector self.time_vec.record(h._ref_t) neuron_utils.createStateVariable(id='time', name='time', units='ms', python_variable={ "record_variable": self.time_vec, "segment": None }) for i in range(N): self.set_recording_vectors(i) h.tstop = 50 neuron_geometries_utils.extractGeometries()
def refresh_data(self, data, geometry_identifier, point): logging.debug('Refreshing space plot with selected geometry: ' + data + "." + geometry_identifier) self.vectors = [] for geometry in GeppettoJupyterModelSync.current_model.geometries_raw: if geometry.id == geometry_identifier: logging.debug('Loading values for geometry ' + str(geometry_identifier)) GeppettoJupyterModelSync.current_model.highlight_visual_group_element( geometry.python_variable["section"].name()) self.geometry = geometry self.state_variables = [] self.section = geometry.python_variable["section"] for index, segment in enumerate(self.section): vector = h.Vector() vector.record(segment._ref_v) state_variable = neuron_utils.createStateVariable(id=self.section.name() + "_" + str(index), name=self.section.name() + "_" + str(index), units='mV', python_variable={"record_variable": vector, "segment": segment}) self.state_variables.append(state_variable) if hasattr(self, 'derived_state_variables'): self.derived_state_variables[0].set_inputs(self.state_variables) self.derived_state_variables[1].timeSeries = list(range(len(self.state_variables))) else: self.derived_state_variables = [] self.derived_state_variables.append(G.createDerivedStateVariable(id="space_plot", name="Space Plot", units='mV', inputs=self.state_variables, normalizationFunction='SPACEPLOT')) self.derived_state_variables.append(G.createDerivedStateVariable(id="space_plot_2", name="Space Plot 2", units='nm', timeSeries=list(range(len(self.state_variables))), normalizationFunction='CONSTANT')) GeppettoJupyterModelSync.current_model.addDerivedStateVariables(self.derived_state_variables) # FIXME: We can not be sured the new variables are created by # this time probably is better if we register an event for # model loaded and we listen to it GeppettoJupyterModelSync.events_controller.register_to_event( [GeppettoJupyterModelSync.events_controller._events['Instances_created']], self.updatePlots) # GeppettoJupyterModelSync.current_model.sync() break
def set_recording_vectors(self, i): """Set soma, dendrite, and time recording vectors on the cell. :param cell: Cell to record from. :return: the soma, dendrite, and time vectors as a tuple. """ #soma_v_vec = h.Vector() # Membrane potential vector at soma setattr(self, 'soma_v_vec_' + str(i), h.Vector()) #dend_v_vec = h.Vector() # Membrane potential vector at dendrite setattr(self, 'dend_v_vec_' + str(i), h.Vector()) getattr(self, 'soma_v_vec_' + str(i)).record(self.cells[i].soma(0.5)._ref_v) neuron_utils.createStateVariable(id='v_vec_soma_' + str(i), name='v_vec_soma_' + str(i), units='mV', python_variable={ "record_variable": getattr(self, 'soma_v_vec_' + str(i)), "segment": self.cells[i].soma(0.5) }) getattr(self, 'dend_v_vec_' + str(i)).record(self.cells[i].dend(0.5)._ref_v) neuron_utils.createStateVariable(id='v_vec_dend_' + str(i), name='v_vec_dend_' + str(i), units='mV', python_variable={ "record_variable": getattr(self, 'dend_v_vec_' + str(i)), "segment": self.cells[i].dend(0.5) })
def __init__(self): neuron_utils.createProject(name='Simple Cell') 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). # Makes a soma of 500 microns squared. self.soma.L = self.soma.diam = 12.6157 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 # self.stim = h.IClamp(self.dend(1.0)) # self.stim.amp = 0.3 # input current in nA # self.stim.delay = 1 # turn on after this time in ms # self.stim.dur = 1 # duration of 1 ms # record soma voltage and time self.t_vec = h.Vector() self.t_vec.record(h._ref_t) neuron_utils.createStateVariable(id='time', name='time', units='ms', python_variable={ "record_variable": self.t_vec, "segment": None }) 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? neuron_utils.createStateVariable(id='v_vec_soma', name='v_vec_soma', units='mV', python_variable={ "record_variable": self.v_vec_soma, "segment": self.soma(1.0) }) self.v_vec_dend = h.Vector() self.v_vec_dend.record(self.dend(1.0)._ref_v) # TODO How do we extract the units? neuron_utils.createStateVariable(id='v_vec_dend', name='v_vec_dend', units='mV', python_variable={ "record_variable": self.v_vec_dend, "segment": self.dend(1.0) }) # run simulation h.tstop = 60 # ms # h.run() neuron_geometries_utils.extractGeometries()