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 setupModel(): ''' Set up two LIF neurons and connect them by an STDPSynHandler. Set up some tables, and reinit MOOSE before simulation. ''' # ########################################### # Initialize neuron group # ########################################### ## two neurons: index 0 will be presynaptic, 1 will be postsynaptic network = moose.LIF('network', 2) moose.le('/network') network.vec.Em = Vrest network.vec.thresh = Vt_base network.vec.refractoryPeriod = refrT network.vec.Rm = R network.vec.vReset = Vreset network.vec.Cm = tau / R network.vec.inject = 0. network.vec.initVm = Vrest # ########################################### # Synaptic model: STDP at each pre and post spike # ########################################### # Values approx from figure in Scholarpedia article (following Bi and Poo 1998): # Jesper Sjoestroem and Wulfram Gerstner (2010) Spike-timing dependent plasticity. # Scholarpedia, 5(2):1362., revision #137369 tauPlus = 10e-3 # s # Apre time constant tauMinus = 10e-3 # s # Apost time constant aPlus0 = 1.0 # at pre, Apre += Apre0 aMinus0 = 0.25 # at post, Apost += Apost0 weight = 5e-3 # V # delta function synapse, adds to Vm syn = moose.STDPSynHandler('/network/syn') syn.numSynapses = 1 # 1 synapse # many pre-synaptic inputs can connect to a synapse # synapse onto postsynaptic neuron moose.connect(syn, 'activationOut', network.vec[1], 'activation') # synapse from presynaptic neuron moose.connect(network.vec[0], 'spikeOut', syn.synapse[0], 'addSpike') # post-synaptic spikes also needed for STDP moose.connect(network.vec[1], 'spikeOut', syn, 'addPostSpike') syn.synapse[0].delay = 0.0 syn.synapse[0].weight = weight # V syn.aPlus0 = aPlus0 * weight # on every pre-spike, aPlus gets this jump # aMinus0 includes learning rate # on every pre-spike, aMinus is added to weight syn.tauPlus = tauPlus syn.aMinus0 = -aMinus0 * weight # on every post-spike, aMinus gets this jump # aMinus0 includes learning rate # on every post-spike, aPlus is added to weight syn.tauMinus = tauMinus syn.weightMax = 2 * weight # bounds on the weight syn.weightMin = 0. # ########################################### # Setting up tables # ########################################### Vms = moose.Table('/plotVms', 2) moose.connect(network, 'VmOut', Vms, 'input', 'OneToOne') spikes = moose.Table('/plotSpikes', 2) moose.connect(network, 'spikeOut', spikes, 'input', 'OneToOne') # ########################################### # Simulate the STDP curve with spaced pre-post spike pairs # ########################################### dt = 0.5e-5 # s # moose simulation moose.useClock(0, '/network/syn', 'process') moose.useClock(1, '/network', 'process') moose.useClock(2, '/plotSpikes', 'process') moose.useClock(3, '/plotVms', 'process') moose.setClock(0, dt) moose.setClock(1, dt) moose.setClock(2, dt) moose.setClock(3, dt) moose.setClock(9, dt) moose.reinit()