Exemple #1
0
def _compile_nmodl(nineml_component,
                   weight_variables,
                   hierarchical_mode=None
                   ):  # weight variables should really be within component
    """
    Generate NMODL code for the 9ML component, run "nrnivmodl" and then load
    the mechanisms into NEURON.
    """
    wdir = os.path.join(NMODL_DIR, nineml_component.name)
    if not os.path.exists(wdir):
        os.makedirs(wdir)
    cwd = os.getcwd()
    os.chdir(wdir)

    xml_file = "%s.xml" % nineml_component.name
    logger.debug("Writing NineML component to %s" % xml_file)
    nineml_component.write(xml_file)
    mod_filename = nineml_component.name + ".mod"
    write_nmodldirect(component=nineml_component,
                      mod_filename=mod_filename,
                      weight_variables=weight_variables)
    #write_nmodl(xml_file, weight_variables) # weight variables should really come from xml file

    print("Running 'nrnivmodl' from %s" % wdir)
    import nineml2nmodl
    call_nrnivmodl()
    os.chdir(cwd)
    neuron.load_mechanisms(wdir)
Exemple #2
0
def _compile_nmodl(nineml_component, weight_variables, hierarchical_mode=None): # weight variables should really be within component
    """
    Generate NMODL code for the 9ML component, run "nrnivmodl" and then load
    the mechanisms into NEURON.
    """
    if not os.path.exists(NMODL_DIR):
        os.makedirs(NMODL_DIR)
    cwd = os.getcwd()
    os.chdir(NMODL_DIR)

    xml_file = "%s.xml" % nineml_component.name
    logger.debug("Writing NineML component to %s" % xml_file)
    nineml_component.write(xml_file)
    
    from nineml2nmodl import write_nmodl, write_nmodldirect
    mod_filename = nineml_component.name + ".mod"
    write_nmodldirect(component=nineml_component, mod_filename=mod_filename, weight_variables=weight_variables) 
    #write_nmodl(xml_file, weight_variables) # weight variables should really come from xml file


    print "Running 'nrnivmodl' from %s"%NMODL_DIR
    import nineml2nmodl
    nineml2nmodl.call_nrnivmodl()



    os.chdir(cwd)
    neuron.load_mechanisms(NMODL_DIR)