def addSynapses(self): ##### Excitatory + Inhibitory Synpase combo taken from the paper Djurisic etal 2008 JNeurosci. ##### Actually it's only an excitatory synapse, but they have used the inhibitory one to model the later time course. ##### Though this might be needed to account for PG cell inhibition? ##### Gbar-s have been set to ensure 16mV EPSP at the glom tuft as done in the paper. ##### Paper's defaults give only 8mV EPSP peak at glom tuft. So here multiplied by two. Cannot use supplemental table values as no cytoplasmic resistivity Ri in this model. Only axial resistance from glom to prim which doesn't matter much [maybe it does - loading rather than input resistance?]. Makes sense only if dendritic tree with many compartments. ##### Also no idea of how much to change the inhibitory part without Ri, so multiplied that also by 2 self._ExcORNSyn = moose.SynChan(self.path + "/ExcSyn") self._ExcORNSyn.Ek = EREST + 0.07 # Volts, 70mV above EREST self._ExcORNSyn.Gbar = 0.3 * SYN_EXC_G # Siemens ### The delay and weight can be set only after connecting a spike event generator. ### delay and weight are arrays: multiple event messages can be connected to a single synapse self._ExcORNSyn.tau1 = 1.6094e-3 # seconds self._ExcORNSyn.tau2 = 1.6094e-3 # seconds self._InhORNSyn = moose.SynChan(self.path + "/InhSyn") self._InhORNSyn.Ek = EREST - 0.01 # Volts, 10mV below EREST self._InhORNSyn.Gbar = 0.3 * SYN_INH_G # Siemens ### The delay and weight can be set only after connecting a spike event generator. ### delay and weight are arrays: multiple event messages can be connected to a single synapse self._InhORNSyn.tau1 = 5.6631e-3 # seconds self._InhORNSyn.tau2 = 5.6631e-3 # seconds self._mitralGlom.connect("channel", self._ExcORNSyn, "channel") self._mitralGlom.connect("channel", self._InhORNSyn, "channel")
def make_synapse(path): """Create a synapse with two time constants.""" syn = moose.SynChan(path) syn.tau1 = 5.0 # ms syn.tau2 = 1.0 # ms syn.Gbar = 1.0 # mS syn.Ek = 0.0 synsh = moose.SimpleSynHandler(path + '/sh') synsh.synapse.num = 1 # syn.bufferTime = 1.0 # ms synsh.synapse.delay = 1.0 synsh.synapse.weight = 1.0 print(('Synapses:', len(synsh.synapse), 'w=', synsh.synapse[0].weight)) spikegen = moose.SpikeGen('%s/spike' % (syn.parent.path)) spikegen.edgeTriggered = False # Make it fire continuously when input is high spikegen.refractT = 10.0 # With this setting it will fire at 1 s / 10 ms = 100 Hz spikegen.threshold = 0.5 # This will send alternatind -1 and +1 to SpikeGen to make it fire spike_stim = moose.PulseGen('%s/spike_stim' % (syn.parent.path)) spike_stim.delay[0] = 50.0 spike_stim.level[0] = 1.0 spike_stim.width[0] = 100.0 moose.connect(spike_stim, 'output', spikegen, 'Vm') m = moose.connect(spikegen, 'spikeOut', synsh.synapse[0], 'addSpike') return syn, spikegen
def make_NMDA(comp): """This function is modified from proto18.py by Upi, which is again based on Dave Beeman's implementation. This implementation of NMDA uses the formulation by Zador, Koch and Brown (1990) where Gk = Gbar * (exp(- t / tau1) - exp(-t / tau2)) / (1 + eta * [Mg2+] * exp(- gmma * Vm)) The MgBlock object sits between the SynChan and teh Compartment and scales the Gk of regular SynChan Gk by [Mg2+] such that the resulting conductance is as above formula, where the fields are : CMg = [Mg2+] KMg_A = 1 / eta KMg_B = 1 / gamma """ nmda = moose.SynChan('%s/nmda' % (comp.path)) nmda.synapse.num = 1 nmda.Ek = 0.0 nmda.tau1 = 20e-3 nmda.tau2 = 20e-3 nmda.Gbar = 0.2 * 8e-9 # channel open probability is 0.2 nmda.bufferTime = 0.0001 mgblock = moose.MgBlock('%s/mgblock' % (nmda.path)) mgblock.CMg = 1.2 # [Mg] in mM mgblock.Zk = 2 mgblock.KMg_A = 1.0/0.28 mgblock.KMg_B = 1.0/62 moose.connect( nmda, 'channelOut', mgblock, 'origChannel', 'OneToOne' ) moose.connect(mgblock, 'channel', comp, 'channel') return nmda, mgblock
def make_NMDA(): if moose.exists('NMDA'): return NMDA = moose.SynChan('NMDA') NMDA.Ek = 0.0 NMDA.tau1 = 20.0e-3 NMDA.tau2 = 20.0e-3 NMDA.Gbar = 5 * SOMA_A block = moose.MgBlock('/library/NMDA/block') block.CMg = 1.2 # [Mg] in mM block.Zk = 2 block.KMg_A = 1.0 / 0.28 block.KMg_B = 1.0 / 62 moose.connect(NMDA, 'channelOut', block, 'origChannel', 'OneToOne') addmsg1 = moose.Mstring('/library/NMDA/addmsg1') addmsg1.value = '.. channel ./block channel' #Here we want to also tell the cell reader to _remove_ the original #Gk, Ek term going from the channel to the compartment, as this is # now handled by the MgBlock. #addmsg2 = moose.Mstring( 'NMDA/addmsg2' #addmsg2.value = 'DropMsg .. channel' addmsg3 = moose.Mstring('/library/NMDA/addmsg3') addmsg3.value = '.. VmOut . Vm'
def create_compartment(path): comp = moose.Compartment(path) comp.diameter = soma_dia comp.Em = EREST_ACT + 10.613e-3 comp.initVm = EREST_ACT sarea = np.pi * soma_dia * soma_dia comp.Rm = 1/(0.3e-3 * 1e4 * sarea) comp.Cm = 1e-6 * 1e4 * sarea if moose.exists('/library/na'): nachan = moose.element(moose.copy('/library/na', comp, 'na')) else: nachan = create_na_chan(comp.path) nachan.Gbar = 120e-3 * sarea * 1e4 moose.showfield(nachan) moose.connect(nachan, 'channel', comp, 'channel') if moose.exists('/library/k'): kchan = moose.element(moose.copy('/library/k', comp, 'k')) else: kchan = create_k_chan(comp.path) kchan.Gbar = 36e-3 * sarea * 1e4 moose.connect(kchan, 'channel', comp, 'channel') synchan = moose.SynChan(comp.path + '/synchan') synchan.Gbar = 1e-8 synchan.tau1 = 2e-3 synchan.tau2 = 2e-3 synchan.Ek = 0.0 m = moose.connect(comp, 'channel', synchan, 'channel') spikegen = moose.SpikeGen(comp.path + '/spikegen') spikegen.threshold = 0.0 m = moose.connect(comp, 'VmOut', spikegen, 'Vm') return comp
def make_synapse(path): """Create a synapse with two time constants. Connect a spikegen to the synapse. Create a pulsegen to drive the spikegen.""" syn = moose.SynChan(path) syn.tau1 = 5.0 # ms syn.tau2 = 1.0 # ms syn.Gk = 1.0 # mS syn.Ek = 0.0 syn.synapse.num = 1 # syn.bufferTime = 1.0 # ms syn.synapse.delay = 1.0 syn.synapse.weight = 1.0 print 'Synapses:', len(syn.synapse), 'w=', syn.synapse[0].weight spikegen = moose.SpikeGen('%s/spike' % (syn.parent.path)) spikegen.edgeTriggered = False # Make it fire continuously when input is high spikegen.refractT = 10.0 # With this setting it will fire at 1 s / 10 ms = 100 Hz spikegen.threshold = 0.5 # This will send alternatind -1 and +1 to SpikeGen to make it fire spike_stim = moose.PulseGen('%s/spike_stim' % (syn.parent.path)) spike_stim.delay[0] = 1.0 spike_stim.level[0] = 1.0 spike_stim.width[0] = 100.0 moose.connect(spike_stim, 'output', spikegen, 'Vm') # m = moose.connect(spikegen, 'spikeOut', syn.synapse.vec, 'addSpike', 'Sparse') # m.setRandomConnectivity(1.0, 1) m = moose.connect(spikegen, 'spikeOut', syn.synapse[0], 'addSpike') # this causes segfault return syn, spikegen
def make_new_synapse(syn_name, postcomp, syn_name_full, nml_params): ## if channel does not exist in library load it from xml file if not moose.exists('/library/' + syn_name): cmlR = ChannelML(nml_params) model_filename = syn_name + '.xml' model_path = utils.find_first_file(model_filename, nml_params['model_dir']) if model_path is not None: cmlR.readChannelMLFromFile(model_path) else: raise IOError( 'For mechanism {0}: files {1} not found under {2}.'.format( syn_name, model_filename, nml_params['model_dir'])) ## deep copies the library SynChan and SynHandler ## to instances under postcomp named as <arg3> synid = moose.copy(moose.element('/library/' + syn_name), postcomp, syn_name_full) #synhandlerid = moose.copy(moose.element('/library/'+syn_name+'/handler'), postcomp,syn_name_full+'/handler') This line was a bug: double handler synhandler = moose.element(synid.path + '/handler') syn = moose.SynChan(synid) synhandler = moose.element( synid.path + '/handler') # returns SimpleSynHandler or STDPSynHandler ## connect the SimpleSynHandler or the STDPSynHandler to the SynChan (double exp) moose.connect(synhandler, 'activationOut', syn, 'activation') # mgblock connections if required childmgblock = mu.get_child_Mstring(syn, 'mgblockStr') #### connect the post compartment to the synapse if childmgblock.value == 'True': # If NMDA synapse based on mgblock, connect to mgblock mgblock = moose.Mg_block(syn.path + '/mgblock') moose.connect(postcomp, "channel", mgblock, "channel") else: # if SynChan or even NMDAChan, connect normally moose.connect(postcomp, "channel", syn, "channel")
def make_NMDA(): if moose.exists('NMDA'): return NMDA = moose.SynChan('NMDA') NMDA.Ek = 0.0 NMDA.tau1 = 20.0e-3 NMDA.tau2 = 20.0e-3 NMDA.Gbar = 5 * SOMA_A block = moose.MgBlock('/library/NMDA/block') block.CMg = 1.2 # [Mg] in mM block.Zk = 2 block.KMg_A = 1.0 / 0.28 block.KMg_B = 1.0 / 62 moose.connect(NMDA, 'channelOut', block, 'origChannel', 'OneToOne') addmsg1 = moose.Mstring('/library/NMDA/addmsg1') addmsg1.value = '.. channel ./block channel' #Here we want to also tell the cell reader to _remove_ the original #Gk, Ek term going from the channel to the compartment, as this is # now handled by the MgBlock. #addmsg2 = moose.Mstring( 'NMDA/addmsg2' #addmsg2.value = 'DropMsg .. channel' addmsg1 = moose.Mstring('/library/NMDA/addmsg1') addmsg1.value = '.. VmOut ./block Vm' addmsg2 = moose.Mstring('/library/NMDA/addmsg2') addmsg2.value = './block IkOut ../Ca_conc current' addmsg3 = moose.Mstring('/library/NMDA/addmsg3') addmsg3.value = '.. VmOut . Vm' sh = moose.SimpleSynHandler('NMDA/sh') moose.connect(sh, 'activationOut', NMDA, 'activation') sh.numSynapses = 1 sh.synapse[0].weight = 1
def many_ematrix_to_one_element(): """This is an example of event messages from multiple SpikeGen objects into a synchan. Create a SynChan element with 2 elements in synapse field. Create 5 SpikeGen elements. Connect alternet SpikeGen elements to synapse[0] and synapse[1] ... This is a minimal example. In real simulations the SpikeGens will be embedded in compartments representing axon terminals and the SynChans will be embedded in somatic/dendritic compartments. """ model = moose.Neutral('/model') # data = moose.Neutral('/data') synchan = moose.SynChan('/model/synchan') synh = moose.SimpleSynHandler('/model/synchan/synh') moose.connect(synh, 'activationOut', synchan, 'activation') synh.synapse.num = 2 num_spikegen = 5 spikegens = [ moose.SpikeGen('/model/spikegen_%d' % (ii)) for ii in range(num_spikegen) ] for ii in range(num_spikegen): msg = moose.connect(spikegens[ii], 'spikeOut', synh.synapse[ii % 2], 'addSpike') # synchan.synapse[ii].delay = ii * 1e-3 # synchan.synapse[ii].weight = (ii+1) * 0.1 for sg in spikegens: print(sg.path, '-->', end=' ') for m in sg.msgOut: print(moose.element(m).adjacent[sg].path)
def create_spine_with_receptor(compt, cell, index, frac): FaradayConst = 96485.3415 # s A / mol spineLength = 5.0e-6 spineDia = 4.0e-6 head = create_spine(compt, cell, index, frac, spineLength, spineDia, 0.0) gluR = moose.SynChan(head.path + '/gluR') gluR.tau1 = 4e-3 gluR.tau2 = 4e-3 gluR.Gbar = 1e-6 gluR.Ek = 10.0e-3 moose.connect(head, 'channel', gluR, 'channel', 'Single') caPool = moose.CaConc(head.path + '/ca') caPool.CaBasal = 1e-4 # 0.1 micromolar caPool.tau = 0.01 B = 1.0 / (FaradayConst * spineLength * spineDia * spineDia * math.pi / 4) B = B / 20.0 # scaling factor for Ca buffering caPool.B = B moose.connect(gluR, 'IkOut', caPool, 'current', 'Single') synHandler = moose.SimpleSynHandler(head.path + '/gluR/handler') synHandler.synapse.num = 1 moose.connect(synHandler, 'activationOut', gluR, 'activation', 'Single') return gluR
def create_cell(): """Create a single-compartment Hodgking-Huxley neuron with a synaptic channel. This uses the :func:`ionchannel.create_1comp_neuron` function for model creation. Returns a dict containing the neuron, the synchan and the synhandler for accessing the synapse, """ neuron = create_1comp_neuron('/neuron') #: SynChan for post synaptic neuron synchan = moose.SynChan('/neuron/synchan') synchan.Gbar = 1e-8 synchan.tau1 = 2e-3 synchan.tau2 = 2e-3 msg = moose.connect(neuron, 'channel', synchan, 'channel') #: Create SynHandler to handle spike event input and set the #: activation input of synchan synhandler = moose.SimpleSynHandler('/neuron/synhandler') synhandler.synapse.num = 1 synhandler.synapse[0].delay = 5e-3 moose.connect(synhandler, 'activationOut', synchan, 'activation') return {'neuron': neuron, 'synchan': synchan, 'synhandler': synhandler}
def createSynapseOnCompartment(compt): FaradayConst = 96485.3415 # s A / mol length = compt.length dia = compt.diameter gluR = moose.SynChan(compt.path + '/gluR') gluR.tau1 = 4e-3 gluR.tau2 = 4e-3 gluR.Gbar = 1e-6 gluR.Ek = 10.0e-3 moose.connect(compt, 'channel', gluR, 'channel', 'Single') gluSyn = moose.SimpleSynHandler(compt.path + '/gluR/sh') moose.connect(gluSyn, 'activationOut', gluR, 'activation') gluSyn.synapse.num = 1 # Ca comes in through this channel, at least for this example. caPool = moose.CaConc(compt.path + '/ca') caPool.CaBasal = 1e-4 # 0.1 micromolar caPool.tau = 0.01 B = 1.0 / (FaradayConst * length * dia * dia * math.pi / 4) B = B / 20.0 # scaling factor for Ca buffering caPool.B = B moose.connect(gluR, 'IkOut', caPool, 'current', 'Single') # Provide a regular synaptic input. synInput = moose.SpikeGen('/n/elec/compt/synInput') synInput.refractT = 47e-3 synInput.threshold = -1.0 synInput.edgeTriggered = 0 synInput.Vm(0) syn = moose.element(gluSyn.path + '/synapse') moose.connect(synInput, 'spikeOut', syn, 'addSpike', 'Single') syn.weight = 0.2 syn.delay = 1.0e-3 return gluR
def create_synaptic_channel(name, Gbar, tau1, tau2, ek, synapse_count, delay, params=None): lib = moose.Neutral('/library') if not moose.exists( '/library') else moose.element('/library') if name == 'nmda': synchan = moose.NMDAChan(lib.path + '/' + name) try: synchan = set_nmda_magnesium_parameters(synchan, params) synchan = set_ghk_equation_factors(synchan, params) except: raise ValueError("No NMDA params provided") else: synchan = moose.SynChan(lib.path + '/' + name) synchan.Gbar = Gbar synchan.tau1 = tau1 synchan.tau2 = tau2 synchan.Ek = ek sh = create_synaptic_handle(synchan, synapse_count, delay) moose.connect(sh, 'activationOut', synchan, 'activation') return (synchan, sh)
def make_synapses(spikegen, synchan, delay=5e-3): """ Create synapses from spikegens to synchans in a manner similar to OneToAll connection. spikegen: list of spikegen objects These are sources of synaptic event messages. synchan: list of synchan objects These are the targets of the synaptic event messages. delay: mean delay of synaptic transmission. Individual delays are normally distributed with sd=0.1*mean. """ scount = len(spikegen) for ii, sid in enumerate(synchan): s = moose.SynChan(sid) sh = moose.SimpleSynHandler( sid.path + "/synh" ) moose.connect( sh, "activationOut", s, "activation" ) sh.synapse.num = scount delay_list = np.random.normal(delay, delay*0.1, scount) # print delay_list for jj in range(scount): sh.synapse[jj].delay = delay_list[jj] # Connect all spikegens to this synchan except that from # same compartment - we assume if parents are same the two belong to the same compartment if s.parent.path != spikegen[jj].parent.path: m = moose.connect(spikegen[jj], 'spikeOut', moose.element(sh.path + '/synapse'), 'addSpike')
def make_AMPA(comp): ampa = moose.SynChan('%s/ampa' % (comp.path)) ampa.synapse.num = 1 ampa.tau1 = 2e-3 ampa.Gbar = 0.5e-9 ampa.bufferTime = 0.0001 moose.connect(ampa, 'channel', comp, 'channel') return ampa
def connectSynapse(compartment, synname, gbar_factor): """ Creates a synname synapse under compartment, sets Gbar*gbar_factor, and attaches to compartment. synname must be a synapse in /library of MOOSE. """ synapseid = moose.copy(moose.SynChan("/library/" + synname), compartment, synname) synapse = moose.SynChan(synapseid) synapse.Gbar = synapse.Gbar * gbar_factor synapse_mgblock = moose.Mstring(synapse.path + "/mgblockStr") if (synapse_mgblock.value == "True" ): # If NMDA synapse based on mgblock, connect to mgblock mgblock = moose.Mg_block(synapse.path + "/mgblock") compartment.connect("channel", mgblock, "channel") else: compartment.connect("channel", synapse, "channel") return synapse
def make_glu(): if moose.exists('glu'): return glu = moose.SynChan('glu') glu.Ek = 0.0 glu.tau1 = 2.0e-3 glu.tau2 = 9.0e-3 glu.Gbar = 40 * SOMA_A
def timetable_demo(): tt_array, sp_array = timetable_nparray() tt_file, sp_file = timetable_file() # Create a synchan inside a compartment to demonstrate how to use # TimeTable to send artificial spike events to a synapse. comp = moose.Compartment('/model/comp') comp.Em = -60e-3 comp.Rm = 1e9 comp.Cm = 1e-12 synchan = moose.SynChan('/model/comp/synchan') synchan.Gbar = 1e-6 synchan.Ek = 0.0 moose.connect(synchan, 'channel', comp, 'channel') synh = moose.SimpleSynHandler('/model/comp/synchan/synh') moose.connect(synh, 'activationOut', synchan, 'activation') synh.synapse.num = 1 moose.connect(tt_file, 'eventOut', moose.element(synh.path + '/synapse'), 'addSpike') # Data recording: record the `state` of the time table filled # using array. data = moose.Neutral('/data') tab_array = moose.Table('/data/tab_array') moose.connect(tab_array, 'requestOut', tt_array, 'getState') # Record the synaptic conductance for the other time table, which # is filled from a text file and sends spike events to a synchan. tab_file = moose.Table('/data/tab_file') moose.connect(tab_file, 'requestOut', synchan, 'getGk') # Scheduling moose.setClock(0, simdt) moose.setClock(1, simdt) moose.useClock(1, '/model/##[ISA=Compartment]', 'init') moose.useClock(1, '/model/##,/data/##', 'process') moose.reinit() moose.start(simtime) # Plotting pylab.subplot(2, 1, 1) pylab.plot(sp_array, np.ones(len(sp_array)), 'rx', label='spike times from numpy array') pylab.plot(np.linspace(0, simtime, len(tab_array.vector)), tab_array.vector, 'b-', label='TimeTable state') pylab.legend() pylab.subplot(2, 1, 2) pylab.plot(sp_file, np.ones(len(sp_file)), 'rx', label='spike times from file') pylab.plot(np.linspace(0, simtime, len(tab_file.vector)), tab_file.vector * 1e6, 'b-', label='Syn Gk (uS)') pylab.legend() pylab.show()
def test_synintegration(filename, target_cell, source_type): sim = Simulation('synintegration') cell = SpinyStellate(SpinyStellate.prototype, sim.model.path + '/SpinyStellate') vm_table = cell.comp[cell.presyn].insertRecorder('Vm', 'Vm', sim.data) # Create a common spike gen object sp = moose.SpikeGen('spike', sim.model) sp.threshold = 0.0 sp.edgeTriggered = 1 sptab = moose.Table('spike', sim.data) sptab.stepMode = 3 sptab.connect('inputRequest', sp, 'state') (comp_indices, syntype, gbar, tau1, tau2, Ek, ) = \ get_syninfo(filename, target_cell, source_type) # Set up the synapses for ii in range(len(comp_indices)): print '%d\t%s\t%g\t%g\t%g\t%g' % (comp_indices[ii], syntype[ii], gbar[ii], tau1[ii], tau2[ii], Ek[ii]) comp = cell.comp[comp_indices[ii]] weight = 1.0 if syntype[ii] == 'nmda': chan = moose.NMDAChan('nmda_from_%s' % (source_type), comp) chan.MgConc = 1.5 weight = gbar[ii] else: chan = moose.SynChan('%s_from_%s' % (syntype[ii], source_type), comp) chan.Gbar = gbar[ii] chan.tau1 = tau1[ii] chan.tau2 = tau2[ii] chan.Ek = Ek[ii] comp.connect('channel', chan, 'channel') sp.connect('event', chan, 'synapse') count = chan.numSynapses if source_type == 'TCR': chan.delay[count-1] = 1e-3 # thalamocortical delay else: chan.delay[count-1] = 0.05e-3 # default delay chan.weight[count-1] = weight gktable = moose.Table('%s_%s_%s' % (cell.name, comp.name, chan.name), sim.data) gktable.stepMode = 3 gktable.connect('inputRequest', chan, 'Gk') pulsegen = moose.PulseGen('pulse', sim.model) pulsegen.firstDelay = 3.0 pulsegen.firstLevel = 1.0 pulsegen.firstWidth = 1e-3 pulsegen.trigMode = moose.FREE_RUN pulsegen.connect('outputSrc', sp, 'Vm') ptable = moose.Table('pulse', sim.data) ptable.stepMode = 3 ptable.connect('inputRequest', pulsegen, 'output') sim.schedule(simdt=1e-6, plotdt=1e-6) sim.run(10.0) sim.save_data_h5(filename.replace('network_', 'synintegration_'))
def create_synaptic_channel(name, Gbar, tau1, tau2, ek, synapse_count, delay): synchan = moose.SynChan(name) synchan.Gbar = Gbar synchan.tau1 = tau1 synchan.tau2 = tau2 synchan.Ek = ek sh = create_synaptic_handle(synchan, synapse_count, delay) moose.connect(sh, 'activationOut', synchan, 'activation') return (synchan, sh)
def setup_two_cells(): """ Create two cells with leaky integrate and fire compartments. Each cell is a single compartment a1 and b2. a1 is stimulated by a step current injection. The compartment a1 is connected to the compartment b2 through a synaptic channel. """ model = moose.Neutral('/model') data = moose.Neutral('/data') a1 = LIFComp('/model/a1') b2 = LIFComp(moose.copy(a1, '/model', 'b2')) a1.Vthreshold = 10e-3 a1.Vreset = 0 b2.Vthreshold = 10e-3 b2.Vreset = 0 syn = moose.SynChan('%s/syn' % (b2.path)) syn.tau1 = 1e-3 syn.tau2 = 5e-3 syn.Ek = 90e-3 synh = moose.SimpleSynHandler(syn.path + '/synh') moose.connect(synh, 'activationOut', syn, 'activation') synh.synapse.num += 1 # syn.numSynapses = 1 synh.synapse.delay = delayMax moose.connect(b2, 'channel', syn, 'channel') ## Single message works most of the time but occassionally gives a ## core dump # m = moose.connect(a1.spikegen, 'spikeOut', # syn.synapse.vec, 'addSpike') ## With Sparse message and random connectivity I did not get core ## dump. m = moose.connect(a1.spikegen, 'spikeOut', synh.synapse.vec, 'addSpike', 'Sparse') m.setRandomConnectivity(1.0, 1) stim = moose.PulseGen('/model/stim') stim.delay[0] = 100e-3 stim.width[0] = 1e3 stim.level[0] = 11e-9 moose.connect(stim, 'output', a1, 'injectMsg') tables = [] data = moose.Neutral('/data') for c in moose.wildcardFind('/##[ISA=Compartment]'): tab = moose.Table('%s/%s_Vm' % (data.path, c.name)) moose.connect(tab, 'requestOut', c, 'getVm') tables.append(tab) syntab = moose.Table('%s/%s' % (data.path, 'Gk')) moose.connect(syntab, 'requestOut', syn, 'getGk') tables.append(syntab) synh.synapse[0].delay = 1e-3 syn.Gbar = 1e-6 return tables
def addSynChan(compname, synparams): synchan = moose.SynChan(compname.path + '/' + synparams['name']) synchan.Gbar = synparams['Gbar'] synchan.tau1 = synparams['tau1'] synchan.tau2 = synparams['tau2'] synchan.Ek = synparams['erev'] msg = moose.connect(compname, 'channel', synchan, 'channel') sh = moose.SimpleSynHandler(synchan.path + '/' + synparams['name']) moose.connect(sh, 'activationOut', synchan, 'activation') return sh
def __init__(self, path, syn_shape, Cm=1.0, Em=0.0, Rm=1.0, Vr=0.0, Vt=1.0, refractT=0.0, inject=0.0, tau_e=0.001, tau_i=0.001, e_e=0.0, e_i=-0.07): moose.IntFire.__init__(self, path) self.Cm = Cm self.Em = Em self.Rm = Rm self.Vr = Vr self.Vt = Vt self.refractT = refractT self.inject = inject self.syn_shape = syn_shape self.esyn = moose.SynChan("%s/excitatory" % path) self.isyn = moose.SynChan("%s/inhibitory" % path) for syn in self.esyn, self.isyn: syn.tau2 = 1e-6 # instantaneous rise, for shape=='exp' syn.Gbar = 1 * uS self.connect("channel", syn, "channel") syn.n_incoming_connections = 0 self.tau_e = tau_e self.tau_i = tau_i self.e_e = e_e self.e_i = e_i self.source = moose.SpikeGen("source", self) self.source.thresh = 0.0 self.source.abs_refract = 2.0 self.connect("VmSrc", self.source, "Vm") self.comp = self # for recorder mixin
def make_GABA( name ): if moose.exists( '/library/' + name ): return GABA = moose.SynChan( '/library/' + name ) GABA.Ek = -0.065 # V GABA.tau1 = 4.0e-3 # s GABA.tau2 = 9.0e-3 # s sh = moose.SimpleSynHandler( GABA.path + '/sh' ) moose.connect( sh, 'activationOut', GABA, 'activation' ) sh.numSynapses = 1 sh.synapse[0].weight = 1
def readSynapseML(self, synapseElement, units="SI units"): if 'Physiological Units' in units: # see pg 219 (sec 13.2) of Book of Genesis Vfactor = 1e-3 # V from mV Tfactor = 1e-3 # s from ms Gfactor = 1e-3 # S from mS elif 'SI Units' in units: Vfactor = 1.0 Tfactor = 1.0 Gfactor = 1.0 else: pu.fatal("Wrong units %s exiting ..." % units) sys.exit(1) if not moose.exists('/library'): moose.Neutral('/library') synname = synapseElement.attrib['name'] if utils.neuroml_debug: pu.info("Loading synapse : %s into /library" % synname) moosesynapse = moose.SynChan('/library/' + synname) doub_exp_syn = synapseElement.find('./{' + self.cml + '}doub_exp_syn') moosesynapse.Ek = float( doub_exp_syn.attrib['reversal_potential']) * Vfactor moosesynapse.Gbar = float( doub_exp_syn.attrib['max_conductance']) * Gfactor moosesynapse.tau1 = float( doub_exp_syn.attrib['rise_time']) * Tfactor # seconds moosesynapse.tau2 = float( doub_exp_syn.attrib['decay_time']) * Tfactor # seconds ## The delay and weight can be set only after connecting a spike event generator. ## delay and weight are arrays: multiple event messages can be connected to a single synapse ## graded synapses are not supported by neuroml, so set to False here, ## see my Demo/neuroml/lobster_pyloric/STG_net.py for how to still have graded synapses moosesynapse_graded = moose.Mstring(moosesynapse.path + '/graded') moosesynapse_graded.value = 'False' moosesynapse_mgblock = moose.Mstring(moosesynapse.path + '/mgblockStr') moosesynapse_mgblock.value = 'False' ## check if STDP synapse is present or not stdp_syn = synapseElement.find('./{' + self.cml + '}stdp_syn') if stdp_syn is None: moosesynhandler = moose.SimpleSynHandler('/library/' + synname + '/handler') else: moosesynhandler = moose.STDPSynHandler('/library/' + synname + '/handler') moosesynhandler.aPlus0 = float(stdp_syn.attrib['del_weight_ltp']) moosesynhandler.aMinus0 = float(stdp_syn.attrib['del_weight_ltd']) moosesynhandler.tauPlus = float(stdp_syn.attrib['tau_ltp']) moosesynhandler.tauMinus = float(stdp_syn.attrib['tau_ltd']) moosesynhandler.weightMax = float( stdp_syn.attrib['max_syn_weight']) moosesynhandler.weightMin = 0.0 ## connect the SimpleSynHandler or the STDPSynHandler to the SynChan (double exp) moose.connect(moosesynhandler, 'activationOut', moosesynapse, 'activation')
def buildSyn( name, compt, Ek, tau1, tau2, Gbar, CM ): syn = moose.SynChan( compt.path + '/' + name ) syn.Ek = Ek syn.tau1 = tau1 syn.tau2 = tau2 syn.Gbar = Gbar * compt.Cm / CM moose.connect( compt, 'channel', syn, 'channel' ) sh = moose.SimpleSynHandler( syn.path + '/sh' ) moose.connect( sh, 'activationOut', syn, 'activation' ) sh.numSynapses = 1 sh.synapse[0].weight = 1 return syn
def make_glu( name ): if moose.exists( '/library/' + name ): return glu = moose.SynChan( '/library/' + name ) glu.Ek = 0.0 glu.tau1 = 2.0e-3 glu.tau2 = 9.0e-3 sh = moose.SimpleSynHandler( glu.path + '/sh' ) moose.connect( sh, 'activationOut', glu, 'activation' ) sh.numSynapses = 1 sh.synapse[0].weight = 1 return glu
def make_glu(): if moose.exists('glu'): return glu = moose.SynChan('glu') glu.Ek = 0.0 glu.tau1 = 2.0e-3 glu.tau2 = 9.0e-3 glu.Gbar = 40 * SOMA_A sh = moose.SimpleSynHandler('glu/sh') moose.connect(sh, 'activationOut', glu, 'activation') sh.numSynapses = 1 sh.synapse[0].weight = 1
def createSynapse(comp, numInputs): synchan = moose.SynChan(comp.path + "/synchan") synchan.Gbar = 1e-8 synchan.tau1 = 2e-3 synchan.tau2 = 2e-3 synchan.Ek = -0.01 moose.connect(comp, "channel", synchan, "channel") sh = moose.SimpleSynHandler(comp.path + "/synhandler") moose.connect(sh, "activationOut", synchan, "activation") sh.synapse.num = numInputs for i in range(numInputs): sh.synapse[i].delay = 5e-3 return sh
def synintegration2(filename, target_cell): raise NotImplementedError syntab = None netfile = h5.File(filename, 'r') syntab = netfile['network/synapse'][:] idx = np.char.startswith(syntab['dest'], target_cell) syntab = syntab[idx] sim = Simulation('synintegration') cell = SpinyStellate(SpinyStellate.prototype, sim.model.path + '/SpinyStellate') vm_table = cell.comp[cell.presyn].insertRecorder('Vm', 'Vm', sim.data) # Create a common spike gen object sp = moose.SpikeGen('spike', sim.model) sp.threshold = 0.0 sp.edgeTriggered = 1 sptab = moose.Table('spike', sim.data) sptab.stepMode = 3 sptab.connect('inputRequest', sp, 'state') for ii in range(len(syntab)): source = syntab['source'][ii].partition('/')[0] dest, compname = syntab['dest'][ii].split('/') if source == dest: print 'source = dest', source, filename continue comp_no = compname.split('_')[-1] comp = cell[int(comp_no)] weight = 1.0 if syntab['type'][ii] == 'nmda': chan = moose.NMDAChan('nmda_from_%s' % (source.split('_')[0]), comp) chan.MgConc = 1.5 weight = syntab['Gbar'][ii] else: chan = moose.SynChan('%s_from_%s' % (syntab['type'][ii], source.split('_')[0]), comp) chan.Gbar = syntab['Gbar'][ii] chan.tau1 = syntab['tau1'][ii] chan.tau2 = syntab['tau2'][ii] chan.Ek = syntab['Ek'][ii] comp.connect('channel', chan, 'channel') sp.connect('event', chan, 'synapse') count = chan.numSynapses if source_type == 'TCR': chan.delay[count-1] = 1e-3 # thalamocortical delay else: chan.delay[count-1] = 0.05e-3 # default delay chan.weight[count-1] = weight gktable = moose.Table('%s_%s_%s' % (cell.name, comp.name, chan.name), sim.data) gktable.stepMode = 3 gktable.connect('inputRequest', chan, 'Gk')