Example #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)
Example #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)
Example #3
0
def write_and_compile_nmodl(component):
    build_dir = os.path.join(BUILD_DIR, component.name.replace('-', '_'))
    clear_and_recreate_dir(build_dir)
    if not component.is_flat():
        component = flatten(component)
    ComponentModifier.close_all_reduce_ports(component=component)
    print '  -- Writing Component to .mod'
    modfilename = os.path.join(build_dir, component.name + '.mod').replace('-', '_')
    write_nmodldirect(component=component, mod_filename=modfilename, weight_variables={})
    compile_nmodl(build_dir)
Example #4
0
def write_and_compile_nmodl(component):
    build_dir = os.path.join(BUILD_DIR, component.name.replace('-', '_'))
    clear_and_recreate_dir(build_dir)
    if not component.is_flat():
        component = flatten(component)
    ComponentModifier.close_all_reduce_ports(component=component)
    print '  -- Writing Component to .mod'
    modfilename = os.path.join(build_dir,
                               component.name + '.mod').replace('-', '_')
    write_nmodldirect(component=component,
                      mod_filename=modfilename,
                      weight_variables={})
    compile_nmodl(build_dir)
    return build_dir
Example #5
0
    def write(cls, component, filename):

        from nineml2nmodl import write_nmodl, write_nmodldirect
        write_nmodldirect(component=component, mod_filename=filename, weight_variables={})