def write_nmodl(nineml_file, weight_variables={}, hierarchical_mode=False): from nineml.abstraction_layer.readers import XMLReader components = XMLReader.read_components(nineml_file) if len(components) == 0: print 'No components found in file!' elif len(components) == 1: output_filename = nineml_file.replace(".xml", ".mod").replace("-", "_") print "Converting %s to %s" % (nineml_file, output_filename) write_nmodldirect(component=component, mod_filename=output_filename, weight_variables=weight_variables, hierarchical_mode=hierarchical_mode) else: for c in components: output_filename = nineml_file.replace(".xml", "_%s.mod"%c.name).replace("-", "_") print "Converting %s to %s" % (nineml_file, output_filename) write_nmodldirect(component=component, mod_filename=output_filename, weight_variables=weight_variables, hierarchical_mode=hierarchical_mode)
Andrew Davison, May 2012 """ # Example 1 import pyNN.neuron as sim from neuroml import load_morphology, load_lems, Section from pyramidal.spatial_distributions import uniform, by_distance from nineml.abstraction_layer.readers import XMLReader from quantities import S, cm, um from pyNN.space import Grid2D, RandomStructure, Sphere pkj_morph = load_morphology("http://neuromorpho.org/...") # smart inference of morphology file format # support ion channel models defined in NineML, LEMS, or from built-in library na_channel = XMLReader.read("na.xml") kdr_channel = load_lems("kd.xml") ka_channel = XMLReader.read("ka.xml") ampa = XMLReader.read("ampa.xml") gabaa = sim.ExpSynCond # first we define cell types (templates) # ... declarative style purkinje_cell = sim.MultiCompartmentNeuron( morphology=pkj_morph, ion_channels={'na': na_channel, 'kdr': kdr_channel, 'kA': kA_channel}, channel_distribution={'na': uniform('all', 0.1*S/cm**2), 'kdr': by_distance(lambda d: 0.05*S/cm**2*d/200.0*um), 'kA': uniform('soma', 0.02*S/cm**2)}, # need to specify cm, Ra (possibly with spatial variation) somewhere here
def alConnectionRuleFromURI(uri): component = XMLReader.read(uri) return CgClosure(component.parameters, component.connection_rule)
def parse(filename): """Left over from orignal Version. This will be deprecated""" from nineml.abstraction_layer.readers import XMLReader return XMLReader.read_component(filename)