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 __init__(self, *args): #### The Mg_block way moose.KinSynChan.__init__(self, *args) self.mgblock = moose.Mg_block(self.path + "/mgblock") self.mgblock.CMg = mitral_granule_NMDA_MgConc self.mgblock.KMg_A = mitral_granule_NMDA_KMg_A #### KMg_B has not been wrapped properly in pymoose, needed to set it via setField available in every pymoose object #mgblock.KMg_B = mitral_granule_NMDA_KMg_B self.mgblock.setField('KMg_B', str(mitral_granule_NMDA_KMg_B)) #### connect source to destination. excsyn2 sends Gk and Ek to mgblock. other way around gives error. self.connect("origChannel", self.mgblock, "origChannel") self.addField('mgblock') self.setField('mgblock', 'True') #### The Mg_block way ends ##### The NMDAChan way #moose.NMDAChan.__init__(self,*args) #self.MgConc = mitral_granule_NMDA_MgConc #connect this in the calling script in the usual way as below: #granulecomp.connect("channel", excsyn2, "channel") ##### The NMDAChan way - ends self.Ek = mitral_granule_NMDA_Ek self.Gbar = mitral_granule_saturatingNMDA_Gbar # KinSynChan is implemented from Destexhe, Mainen and Sejnowski, 1994 # pulseWidth is the time for which the neurotransmitter is on self.pulseWidth = mitral_granule_saturatingNMDA_pulseWidth # decay time after neurotransmitter is switched off 1/beta in Destexhe, Mainen and Sejnowski, 1994 self.tau1 = mitral_granule_saturatingNMDA_tau1 # the fraction of bound/open receptors in infinite time with one synaptic event. # rise time tau2 or tau_r in the paper is calculated as tau_1*(1-rInf) and cannot be set. self.rInf = mitral_granule_saturatingNMDA_rInf self.addField('graded') self.setField('graded', 'False')
def __init__(self, *args): #### The Mg_block way moose.SynChan.__init__(self, *args) self.mgblock = moose.Mg_block(self.path + "/mgblock") self.mgblock.CMg = mitral_granule_NMDA_MgConc self.mgblock.KMg_A = mitral_granule_NMDA_KMg_A ## KMg_B has not been wrapped properly in pymoose, ## needed to set it via setField available in every pymoose object #mgblock.KMg_B = mitral_granule_NMDA_KMg_B self.mgblock.setField('KMg_B', str(mitral_granule_NMDA_KMg_B)) ## connect source to destination. ## excsyn2 sends Gk and Ek to mgblock. other way around gives error. self.connect("origChannel", self.mgblock, "origChannel") self.addField('mgblock') self.setField('mgblock', 'True') #### The Mg_block way ends ##### The NMDAChan way #moose.NMDAChan.__init__(self,*args) #self.MgConc = mitral_granule_NMDA_MgConc #connect this in the calling script in the usual way as below: #granulecomp.connect("channel", excsyn2, "channel") ##### The NMDAChan way - ends self.Ek = mitral_granule_NMDA_Ek self.Gbar = mitral_granule_NMDA_Gbar self.tau1 = mitral_granule_NMDA_tau1 self.tau2 = mitral_granule_NMDA_tau2 self.addField('graded') self.setField('graded', 'False')
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_new_synapse(self, syn_name, postcomp, syn_name_full): ## if channel does not exist in library load it from xml file if not self.context.exists('/library/' + syn_name): cmlR = ChannelML(self.nml_params) cmlR.readChannelMLFromFile(syn_name + '.xml') synid = self.context.deepCopy( self.context.pathToId('/library/' + syn_name), postcomp.id, syn_name_full) syn = moose.SynChan(synid) #### connect the post compartment to the synapse if syn.getField( 'mgblock' ) == 'True': # If NMDA synapse based on mgblock, connect to mgblock mgblock = moose.Mg_block(syn.path + '/mgblock') postcomp.connect("channel", mgblock, "channel") else: # if SynChan or even NMDAChan, connect normally postcomp.connect("channel", syn, "channel")
def makeNewSynapse(self, synName, postcomp, synNameFull): '''This function creates a new synapses onto postcomp. SpikeGen is spikeGenerator (presynaptic). SpikeGen connects to SynChan, a synaptic channel which connects to post-synaptic compartment. SpikeGen models the pre-synaptic events. ''' synPath = "%s/%s" % (self.libraryPath, synName) utils.dump( "SYNAPSE", "Creating {} with path {} onto compartment {}".format( synName, synPath, postcomp.path)) # if channel does not exist in library load it from xml file if not moose.exists(synPath): utils.dump( "SYNAPSE", "Synaptic Channel {} does not exists. {}".format( synPath, "Loading is from XML file")) cmlR = ChannelML.ChannelML(self.nml_params) cmlR.readChannelMLFromFile(synName + '.xml') # deep copies the library synapse to an instance under postcomp named as # <arg3> if config.disbleCopyingOfObject: utils.dump( "WARN", "Copying existing SynChan ({}) to {}".format( synPath, postcomp)) synid = moose.copy(moose.Neutral(synPath), postcomp, synNameFull) else: synid = synPath syn = moose.SynChan(synid) syn = self.configureSynChan(syn, synParams={}) childmgblock = utils.get_child_Mstring(syn, 'mgblock') # connect the post compartment to the synapse # If NMDA synapse based on mgblock, connect to mgblock if childmgblock.value == 'True': mgblock = moose.Mg_block(syn.path + '/mgblock') self.connectWrapper(postcomp, "channel", mgblock, "channel") # if SynChan or even NMDAChan, connect normally else: self.connectWrapper(postcomp, "channel", syn, "channel")
def printRecursiveTree(elementid, level): """ Recursive helper function for printCellTree, specify depth/'level' to recurse and print subelements under MOOSE 'elementid'. """ spacefill = " " * level element = moose.Neutral(elementid) for childid in element.children: childobj = moose.Neutral(childid) classname = childobj.className if classname in ["SynChan", "KinSynChan"]: childobj = moose.SynChan(childid) print( spacefill + "|--", childobj.name, childobj.className, "Gbar=", childobj.Gbar, "numSynapses=", childobj.numSynapses, ) return # Have yet to figure out the children of SynChan, currently not going deeper elif classname in ["HHChannel", "HHChannel2D"]: childobj = moose.HHChannel(childid) print( spacefill + "|--", childobj.name, childobj.className, "Gbar=", childobj.Gbar, "Ek=", childobj.Ek, ) elif classname in ["CaConc"]: childobj = moose.CaConc(childid) print( spacefill + "|--", childobj.name, childobj.className, "thick=", childobj.thick, "B=", childobj.B, ) elif classname in ["Mg_block"]: childobj = moose.Mg_block(childid) print( spacefill + "|--", childobj.name, childobj.className, "CMg", childobj.CMg, "KMg_A", childobj.KMg_A, "KMg_B", childobj.KMg_B, ) elif classname in ["SpikeGen"]: childobj = moose.SpikeGen(childid) print( spacefill + "|--", childobj.name, childobj.className, "threshold", childobj.threshold, ) elif classname in ["Func"]: childobj = moose.Func(childid) print( spacefill + "|--", childobj.name, childobj.className, "expr", childobj.expr, ) elif classname in [ "Table" ]: # Table gives segfault if printRecursiveTree is called on it return # so go no deeper # for inmsg in childobj.inMessages(): # print spacefill+" |---", inmsg # for outmsg in childobj.outMessages(): # print spacefill+" |---", outmsg if len(childobj.children) > 0: printRecursiveTree(childid, level + 1)
syn_name = synapse_names[idx] context = moose.PyMooseBase.getContext() soma = moose.Compartment('/soma') soma.length = 1e-6 # m soma.diameter = 1e-6 # m soma.Cm = 0.01 * 3.14159 * soma.length * soma.diameter synid = context.deepCopy(context.pathToId('/library/' + syn_name), soma.id, syn_name) syn = moose.SynChan(synid) #### connect the soma to the synapse if syn.getField( 'mgblock' ) == 'True': # If NMDA synapse based on mgblock, connect to mgblock mgblock = moose.Mg_block(syn.path + '/mgblock') compartment_connection = mgblock else: # if SynChan or even NMDAChan, connect normally compartment_connection = syn soma.connect("channel", compartment_connection, "channel") tt = moose.TimeTable('/soma/tt') tt.connect("event", syn, "synapse") syn.setWeight(syn.numSynapses - 1, 1.0) syn.setDelay(syn.numSynapses - 1, 0) fn = 'temp_spikefile.txt' f = open(fn, 'w') f.write(str(SETTLETIME)) f.close() tt.filename = fn os.remove(fn)