def createPopulations(self): self.populationDict = {} for population in self.network.findall(".//{"+nml_ns+"}population"): cellname = population.attrib["cell_type"] populationname = population.attrib["name"] print "loading", populationname ## if cell does not exist in library load it from xml file if not moose.exists('/library/'+cellname): mmlR = MorphML(self.nml_params) model_filenames = (cellname+'.xml', cellname+'.morph.xml') success = False for model_filename in model_filenames: model_path = find_first_file(model_filename,self.model_dir) if model_path is not None: cellDict = mmlR.readMorphMLFromFile(model_path) success = True break if not success: raise IOError( 'For cell {0}: files {1} not found under {2}.'.format( cellname, model_filenames, self.model_dir ) ) self.cellSegmentDict.update(cellDict) if cellname == 'LIF': libcell = moose.LeakyIaF('/library/'+cellname) else: libcell = moose.Neuron('/library/'+cellname) #added cells as a Neuron class. self.populationDict[populationname] = (cellname,{}) moose.Neutral('/cells') for instance in population.findall(".//{"+nml_ns+"}instance"): instanceid = instance.attrib['id'] location = instance.find('./{'+nml_ns+'}location') rotationnote = instance.find('./{'+meta_ns+'}notes') if rotationnote is not None: ## the text in rotationnote is zrotation=xxxxxxx zrotation = float(string.split(rotationnote.text,'=')[1]) else: zrotation = 0 ## deep copies the library cell to an instance under '/cells' named as <arg3> ## /cells is useful for scheduling clocks as all sim elements are in /cells cellid = moose.copy(libcell,moose.Neutral('/cells'),populationname+"_"+instanceid) if cellname == 'LIF': cell = moose.LeakyIaF(cellid) self.populationDict[populationname][1][int(instanceid)]=cell else: cell = moose.Neuron(cellid) # No Cell class in MOOSE anymore! :( addded Neuron class - Chaitanya self.populationDict[populationname][1][int(instanceid)]=cell x = float(location.attrib['x'])*self.length_factor y = float(location.attrib['y'])*self.length_factor z = float(location.attrib['z'])*self.length_factor self.translate_rotate(cell,x,y,z,zrotation)
def createPopulations(self): self.populationDict = {} for population in self.network.findall(".//{"+nml_ns+"}population"): cellname = population.attrib["cell_type"] populationname = population.attrib["name"] print "loading", populationname ## if cell does not exist in library load it from xml file if not self.library.has_key(cellname): mmlR = MorphML(self.nml_params) model_filenames = (cellname+'.xml', cellname+'.morph.xml') success = False for model_filename in model_filenames: model_path = find_first_file(model_filename,self.model_dir) if model_path is not None: cellDict = mmlR.readMorphMLFromFile(model_path) success = True break if not success: raise IOError( 'For cell {0}: files {1} not found under {2}.'.format( cellname, model_filenames, self.model_dir ) ) self.cellSegmentDict.update(cellDict) self.library[cellname] = cellDict #self.populationDict[populationname] = (cellname,{}) for instance in population.findall(".//{"+nml_ns+"}instance"): instanceid = instance.attrib['id'] location = instance.find('./{'+nml_ns+'}location') rotationnote = instance.find('./{'+meta_ns+'}notes') if rotationnote is not None: zrotation = float(string.split(rotationnote.text,'=')[1]) else: zrotation = 0 x = float(location.attrib['x'])*self.length_factor y = float(location.attrib['y'])*self.length_factor z = float(location.attrib['z'])*self.length_factor self.populationDict.update(self.translate_rotate(populationname,instanceid,self.library[cellname],x,y,z,zrotation))