• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pynml.print_comment_v函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyneuroml.pynml.print_comment_v函数的典型用法代码示例。如果您正苦于以下问题:Python print_comment_v函数的具体用法?Python print_comment_v怎么用?Python print_comment_v使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了print_comment_v函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: export_to_neuroml1

def export_to_neuroml1(hoc_file, nml1_file_name, level=1, validate=True):

    if not (level == 1 or level == 2):
        print_comment_v("Only options for Levels in NeuroMLv1.8.1 are 1 or 2")
        return None

    from neuron import *
    from nrn import *

    h.load_file(hoc_file)

    print_comment_v("Loaded NEURON file: %s" % hoc_file)

    h.load_file("mview.hoc")

    h("objref mv")
    h("mv = new ModelView()")

    h.load_file("%s/mview_neuroml1.hoc" % (os.path.dirname(__file__)))

    h("objref mvnml1")
    h("mvnml1 = new ModelViewNeuroML1(mv)")

    h.mvnml1.exportNeuroML(nml1_file_name, level)

    if validate:

        validate_neuroml1(nml1_file_name)
开发者ID:valentin314,项目名称:pyNeuroML,代码行数:28,代码来源:__init__.py


示例2: process_channel_file

def process_channel_file(channel_file,a):
    ## Get name of channel mechanism to test
    if a.v: 
        print_comment_v("Going to test channel from file: "+ channel_file)

    if not os.path.isfile(channel_file):
        raise IOError("File could not be found: %s!\n" % channel_file)
    
    channels = get_channels_from_channel_file(channel_file)

    channels_info = []
    for channel in channels:  
        if len(get_channel_gates(channel)) == 0:
            print_comment_v("Skipping %s in %s as it has no channels (probably passive conductance)"%(channel.id,channel_file))
        else:
            new_lems_file = make_lems_file(channel,a)
            if not a.norun:
                results = run_lems_file(new_lems_file,a)        

            if a.iv_curve:
                iv_data = compute_iv_curve(channel,a,results)
            else:
                iv_data = None

            if not a.nogui and not a.norun:
                plot_channel(channel,a,results,iv_data=iv_data)

            channel_info = {key:getattr(channel,key) for key in ['id','file','notes', 'species']}
            
            channel_info['expression'] = get_conductance_expression(channel)
            channel_info['ion_color'] = get_ion_color(channel.species)
            
            channels_info.append(channel_info)
    return channels_info
开发者ID:christian-oreilly,项目名称:pyNeuroML,代码行数:34,代码来源:NML2ChannelAnalysis.py


示例3: make_lems_file

def make_lems_file(channel, a):
    gates = get_channel_gates(channel)
    lems_content = generate_lems_channel_analyser(
        channel.file,
        channel.id,
        a.min_v,
        a.step_target_voltage,
        a.max_v,
        a.clamp_delay,
        a.clamp_duration,
        a.clamp_base_voltage,
        a.duration,
        a.erev,
        gates,
        a.temperature,
        a.ca_conc,
        a.iv_curve,
        a.dat_suffix,
    )
    new_lems_file = os.path.join(OUTPUT_DIR, "LEMS_Test_%s.xml" % channel.id)
    lf = open(new_lems_file, "w")
    lf.write(lems_content)
    lf.close()
    if a.v:
        print_comment_v("Written generated LEMS file to %s\n" % new_lems_file)
    return new_lems_file
开发者ID:valentin314,项目名称:pyNeuroML,代码行数:26,代码来源:NML2ChannelAnalysis.py


示例4: make_html_file

def make_html_file(info):
    merged = merge_with_template(info, HTML_TEMPLATE_FILE)
    html_dir = make_overview_dir()
    new_html_file = os.path.join(html_dir,'ChannelInfo.html')
    lf = open(new_html_file, 'w')
    lf.write(merged)
    lf.close()
    print_comment_v('Written HTML info to: %s' % new_html_file)
开发者ID:christian-oreilly,项目名称:pyNeuroML,代码行数:8,代码来源:NML2ChannelAnalysis.py


示例5: make_md_file

def make_md_file(info):
    merged = merge_with_template(info, MD_TEMPLATE_FILE)
    md_dir = make_overview_dir()
    new_md_file = os.path.join(md_dir,'README.md')
    lf = open(new_md_file, 'w')
    lf.write(merged)
    lf.close()
    print_comment_v('Written Markdown info to: %s' % new_md_file)
开发者ID:christian-oreilly,项目名称:pyNeuroML,代码行数:8,代码来源:NML2ChannelAnalysis.py


示例6: merge_with_template

def merge_with_template(info):
    
    templfile = "TEMPLATE.channel.nml"
    if not os.path.isfile(templfile):
        templfile = os.path.join(os.path.dirname(sys.argv[0]), templfile)
    print_comment_v("Merging with template %s"%templfile)
    with open(templfile) as f:
        templ = airspeed.Template(f.read())
    return templ.merge(info)
开发者ID:NeuroML,项目名称:pyNeuroML,代码行数:9,代码来源:parse_mod_file.py


示例7: include_neuroml2_file

 def include_neuroml2_file(self, nml2_file_name, include_included=True, relative_to_dir='.'):
     full_path = os.path.abspath(relative_to_dir+'/'+nml2_file_name)
     base_path = os.path.dirname(full_path)
     print_comment_v("Including in generated LEMS file: %s (%s)"%(nml2_file_name, full_path))
     self.lems_info['include_files'].append(nml2_file_name)
     if include_included:
         cell = read_neuroml2_file(full_path)
         for include in cell.includes:
             self.include_neuroml2_file(include.href, include_included=True, relative_to_dir=base_path)
开发者ID:RokasSt,项目名称:pyNeuroML,代码行数:9,代码来源:LEMSSimulation.py


示例8: check_brackets

def check_brackets(line, bracket_depth):
    if len(line)>0:
        bracket_depth0 = bracket_depth
        for c in line:
            if c=='{':
                bracket_depth+=1
            elif c=='}':
                bracket_depth-=1
        if bracket_depth0 !=bracket_depth:
            print_comment_v("       <%s> moved bracket %i -> %i"%(line, bracket_depth0,bracket_depth))
    return bracket_depth
开发者ID:NeuroML,项目名称:pyNeuroML,代码行数:11,代码来源:parse_mod_file.py


示例9: generate_lems_channel_analyser

def generate_lems_channel_analyser(channel_file, channel, min_target_voltage, 
                      step_target_voltage, max_target_voltage, clamp_delay, 
                      clamp_duration, clamp_base_voltage, duration, erev, 
                      gates, temperature, ca_conc, iv_curve, dat_suffix=''):
                          
    print_comment_v("Generating LEMS file to investigate %s in %s, %smV->%smV, %sdegC"%(channel, \
                     channel_file, min_target_voltage, max_target_voltage, temperature))
                                      
    target_voltages = []
    v = min_target_voltage
    while v <= max_target_voltage:
        target_voltages.append(v)
        v+=step_target_voltage

    target_voltages_map = []
    for t in target_voltages:
        fract = float(target_voltages.index(t)) / (len(target_voltages)-1)
        info = {}
        info["v"] = t
        info["v_str"] = str(t).replace("-", "min")
        info["col"] = get_colour_hex(fract)
        target_voltages_map.append(info)
        
    includes = get_includes_from_channel_file(channel_file)
    includes_relative = []
    base_path = os.path.dirname(channel_file)
    for inc in includes:
        includes_relative.append(os.path.abspath(base_path+'/'+inc))

    model = {"channel_file":        channel_file, 
             "includes":            includes_relative, 
             "channel":             channel, 
             "target_voltages" :    target_voltages_map,
             "clamp_delay":         clamp_delay,
             "clamp_duration":      clamp_duration,
             "clamp_base_voltage":  clamp_base_voltage,
             "min_target_voltage":  min_target_voltage,
             "max_target_voltage":  max_target_voltage,
             "duration":  duration,
             "erev":  erev,
             "gates":  gates,
             "temperature":  temperature,
             "ca_conc":  ca_conc,
             "iv_curve":  iv_curve,
             "dat_suffix": dat_suffix}
             
    #pp.pprint(model)

    merged = merge_with_template(model, TEMPLATE_FILE)

    return merged
开发者ID:34383c,项目名称:pyNeuroML,代码行数:51,代码来源:NML2ChannelAnalysis.py


示例10: convert_to_swc

def convert_to_swc(nml_file_name):

    global line_count
    global line_index_vs_distals
    global line_index_vs_proximals
    
    # Reset
    line_count = 1
    line_index_vs_distals = {}
    line_index_vs_proximals = {}

    base_dir = os.path.dirname(os.path.realpath(nml_file_name))
    nml_doc = pynml.read_neuroml2_file(nml_file_name, include_includes=True, verbose=False, optimized=True)

    lines = []

    for cell in nml_doc.cells:
        
        swc_file_name = '%s/%s.swc' % (base_dir, cell.id)
            
        swc_file = open(swc_file_name, 'w')

        print_comment_v("Converting cell %s as found in NeuroML doc %s to SWC..." % (cell.id, nml_file_name))

        lines_sg, seg_ids = _get_lines_for_seg_group(cell, 'soma_group', 1)
        soma_seg_count = len(seg_ids)
        lines += lines_sg

        lines_sg, seg_ids = _get_lines_for_seg_group(cell, 'dendrite_group', 3)
        dend_seg_count = len(seg_ids)
        lines += lines_sg

        lines_sg, seg_ids = _get_lines_for_seg_group(cell, 'axon_group', 2)
        axon_seg_count = len(seg_ids)
        lines += lines_sg

        if not len(cell.morphology.segments) == soma_seg_count + dend_seg_count + axon_seg_count:
            raise Exception("The numbers of the segments in groups: soma_group+dendrite_group+axon_group (%i), is not the same as total number of segments (%s)! All bets are off!" % (soma_seg_count + dend_seg_count + axon_seg_count, len(cell.morphology.segments)))

        for i in range(len(lines)):
            l = lines[i]
            swc_line = '%s' % (l)
            print(swc_line)
            swc_file.write('%s\n' % swc_line)

        swc_file.close()

        print("Written to %s" % swc_file_name)    
开发者ID:NeuroML,项目名称:pyNeuroML,代码行数:48,代码来源:ExportSWC.py


示例11: run

def run(a=None,**kwargs): 
    a = build_namespace(a,**kwargs)
    
    #if (not a.nogui) or a.html:
    #    print('mpl')

    info = {'info': ("Channel information at: "
                     "T = %s degC, "
                     "E_rev = %s mV, "
                     "[Ca2+] = %s mM") % (a.temperature, a.erev, a.ca_conc),
            'channels': []}
            
    na_chan_files = []
    k_chan_files = []
    ca_chan_files = []
    other_chan_files = []
    
    if len(a.channel_files) > 0:
        
        for channel_file in a.channel_files:
            channels = get_channels_from_channel_file(channel_file)
            #TODO look past 1st channel...
            if channels[0].species == 'na':
                na_chan_files.append(channel_file)
            elif channels[0].species == 'k':
                k_chan_files.append(channel_file)
            elif channels[0].species == 'ca':
                ca_chan_files.append(channel_file)
            else:
                other_chan_files.append(channel_file)
            
    channel_files = na_chan_files + k_chan_files + ca_chan_files + other_chan_files
    print_comment_v("\nAnalysing channels from files: %s\n"%channel_files)
    
    for channel_file in channel_files:
        channels_info = process_channel_file(channel_file,a)
        for channel_info in channels_info:
            info['channels'].append(channel_info)
                       
    if not a.nogui and not a.html and not a.md:
        plt.show()
    else:
        if a.html:
            make_html_file(info)
        if a.md:
            make_md_file(info)
开发者ID:christian-oreilly,项目名称:pyNeuroML,代码行数:46,代码来源:NML2ChannelAnalysis.py


示例12: run

    def run(self,candidates,parameters):
        """
        Run simulation for each candidate
        
        This run method will loop through each candidate and run the simulation
        corresponding to it's parameter values. It will populate an array called
        traces with the resulting voltage traces for the simulation and return it.
        """

        traces = []
        for candidate in candidates:
            sim_var = dict(zip(parameters,candidate))
            print_comment_v('\n\n  - RUN %i; variables: %s\n'%(self.count,sim_var))
            self.count+=1
            t,v = self.run_individual(sim_var)
            traces.append([t,v])

        return traces
开发者ID:34383c,项目名称:pyNeuroML,代码行数:18,代码来源:NeuroMLController.py


示例13: read_sonata_spikes_hdf5_file

def read_sonata_spikes_hdf5_file(file_name):
    
    full_path = os.path.abspath(file_name)
    pynml.print_comment_v("Loading SONATA spike times from: %s (%s)"%(file_name,full_path))
    
    import tables   # pytables for HDF5 support
    h5file=tables.open_file(file_name,mode='r')
    
    pynml.print_comment_v("Opened HDF5 file: %s; sorting=%s"%(h5file.filename,h5file.root.spikes._v_attrs.sorting))
    gids = h5file.root.spikes.gids
    timestamps = h5file.root.spikes.timestamps
    ids_times = {}
    count=0
    max_t = -1*sys.float_info.max
    min_t = sys.float_info.max
    for i in range(len(gids)):
        id = gids[i]
        t = timestamps[i]
        max_t = max(max_t,t)
        min_t = min(min_t,t)
        if not id in ids_times:
            ids_times[id] = []
        ids_times[id].append(t)
        count+=1
        
    ids = ids_times.keys()
    
    h5file.close()
    
    pynml.print_comment_v("Loaded %s spiketimes, ids (%s -> %s) times (%s -> %s)"%(count,min(ids), max(ids),min_t,max_t))
    
    return ids_times
开发者ID:NeuroML,项目名称:pyNeuroML,代码行数:32,代码来源:PlotSpikes.py


示例14: export_to_neuroml2

def export_to_neuroml2(hoc_or_python_file, 
                       nml2_file_name, 
                       includeBiophysicalProperties=True, 
                       separateCellFiles=False, 
                       known_rev_potentials={},
                       validate=True):
    
    from neuron import *
    from nrn import *
    
    if hoc_or_python_file is not None:
        if hoc_or_python_file.endswith(".py"):
            print_comment_v("***************\nImporting Python scripts not yet implemented...\n***************")
        else:
            if not os.path.isfile(hoc_or_python_file):
                print_comment_v("***************\nProblem importing file %s (%s)..\n***************"%(hoc_or_python_file, os.path.abspath(hoc_or_python_file)))
            h.load_file(1, hoc_or_python_file) # Using 1 to force loading of the file, in case file with same name was loaded before...
    else:
        print_comment_v("hoc_or_python_file variable is None; exporting what's currently in memory...")

    for ion in known_rev_potentials.keys():
        set_erev_for_mechanism(ion,known_rev_potentials[ion])

    print_comment_v("Loaded NEURON file: %s"%hoc_or_python_file)

    h.load_file("mview.hoc")
    
    h('objref mv')
    h('mv = new ModelView(0)')
    
    h.load_file("%s/mview_neuroml2.hoc"%(os.path.dirname(__file__)))
    
    h('objref mvnml')
    h('mvnml = new ModelViewNeuroML2(mv)')
    
    nml2_level = 2 if includeBiophysicalProperties else 1
    
    h.mvnml.exportNeuroML2(nml2_file_name, nml2_level, int(separateCellFiles))
    
    if validate:
        validate_neuroml2(nml2_file_name)
        
        
    h('mv.destroy()')
开发者ID:RokasSt,项目名称:pyNeuroML,代码行数:44,代码来源:__init__.py


示例15: go

 def go(self):
     
     
     lems_file_name = 'LEMS_%s.xml'%(self.reference)
     
     generate_lems_file_for_neuroml(self.reference, 
                                    self.neuroml_file, 
                                    self.target, 
                                    self.sim_time, 
                                    self.dt, 
                                    lems_file_name = lems_file_name,
                                    target_dir = self.generate_dir)
     
     pynml.print_comment_v("Running a simulation of %s ms with timestep %s ms: %s"%(self.sim_time, self.dt, lems_file_name))
     
     self.already_run = True
     
     start = time.time()
     if self.simulator == 'jNeuroML':
         results = pynml.run_lems_with_jneuroml(lems_file_name, 
                                                nogui=True, 
                                                load_saved_data=True, 
                                                plot=False, 
                                                exec_in_dir = self.generate_dir,
                                                verbose=False)
     elif self.simulator == 'jNeuroML_NEURON':
         results = pynml.run_lems_with_jneuroml_neuron(lems_file_name, 
                                                       nogui=True, 
                                                       load_saved_data=True, 
                                                       plot=False, 
                                                       exec_in_dir = self.generate_dir,
                                                       verbose=False)
     else:
         pynml.print_comment_v('Unsupported simulator: %s'%self.simulator)
         exit()
         
     secs = time.time()-start
 
     pynml.print_comment_v("Ran simulation in %s in %f seconds (%f mins)\n\n"%(self.simulator, secs, secs/60.0))
     
     
     self.t = [t*1000 for t in results['t']]
     
     self.volts = {}
     
     for key in results.keys():
         if key != 't':
             self.volts[key] = [v*1000 for v in results[key]]
开发者ID:34383c,项目名称:pyNeuroML,代码行数:48,代码来源:NeuroMLSimulation.py


示例16: export_to_neuroml2

def export_to_neuroml2(
    hoc_or_python_file, nml2_file_name, includeBiophysicalProperties=True, separateCellFiles=False, validate=True
):

    from neuron import *
    from nrn import *

    if hoc_or_python_file is not None:
        if hoc_or_python_file.endswith(".py"):
            print_comment_v("Importing Python scripts not yet implemented...")
        else:
            h.load_file(
                1, hoc_or_python_file
            )  # Using 1 to force loading of the file, in case file with same name was loaded before...
    else:
        print_comment_v("hoc_or_python_file variable is None; exporting what's currently in memory...")

    print_comment_v("Loaded NEURON file: %s" % hoc_or_python_file)

    h.load_file("mview.hoc")

    h("objref mv")
    h("mv = new ModelView(0)")

    h.load_file("%s/mview_neuroml2.hoc" % (os.path.dirname(__file__)))

    h("objref mvnml")
    h("mvnml = new ModelViewNeuroML2(mv)")

    nml2_level = 2 if includeBiophysicalProperties else 1

    h.mvnml.exportNeuroML2(nml2_file_name, nml2_level, int(separateCellFiles))

    if validate:
        validate_neuroml2(nml2_file_name)

    h("mv.destroy()")
开发者ID:christian-oreilly,项目名称:pyNeuroML,代码行数:37,代码来源:__init__.py


示例17: main

def main ():

    args = process_args()
        
    xmlfile = args.neuroml_file

    pov_file_name = xmlfile
    endings = [".xml",".h5",".nml"]
    for e in endings:
        if pov_file_name.endswith(e):
            pov_file_name.replace(e, ".pov")
            
    if pov_file_name == xmlfile:
        pov_file_name+='.pov'

    pov_file = open(pov_file_name, "w")


    header='''
/*
POV-Ray file generated from NeuroML network
*/
#version 3.6;

#include "colors.inc"

background {rgbt %s}


    \n''' ###    end of header


    pov_file.write(header%(args.background))

    cells_file = pov_file
    net_file = pov_file
    splitOut = False

    cf = pov_file_name.replace(".pov", "_cells.inc")
    nf = pov_file_name.replace(".pov", "_net.inc")

    if args.split:
        splitOut = True
        cells_file = open(cf, "w")
        net_file = open(nf, "w")
        print_comment_v("Saving into %s and %s and %s"%(pov_file_name, cf, nf))

    print_comment_v("Converting XML file: %s to %s"%(xmlfile, pov_file_name))


    nml_doc = pynml.read_neuroml2_file(xmlfile, include_includes=True, verbose=args.v, optimized=True)

    cell_elements = []
    cell_elements.extend(nml_doc.cells)
    cell_elements.extend(nml_doc.cell2_ca_poolses)
    
    
    minXc = 1e9
    minYc = 1e9
    minZc = 1e9
    maxXc = -1e9
    maxYc = -1e9
    maxZc = -1e9

    minX = 1e9
    minY = 1e9
    minZ = 1e9
    maxX = -1e9
    maxY = -1e9
    maxZ = -1e9

    declaredcells = {}

    print_comment_v("There are %i cells in the file"%len(cell_elements))
    
    cell_id_vs_seg_id_vs_proximal = {}
    cell_id_vs_seg_id_vs_distal = {}
    cell_id_vs_cell = {}

    for cell in cell_elements:
        
        cellName = cell.id 
        cell_id_vs_cell[cell.id] = cell
        print_comment_v("Handling cell: %s"%cellName)
        cell_id_vs_seg_id_vs_proximal[cell.id] = {}
        cell_id_vs_seg_id_vs_distal[cell.id] = {}
        
        declaredcell = "cell_"+cellName

        declaredcells[cellName] = declaredcell

        cells_file.write("#declare %s = \n"%declaredcell)
        cells_file.write("union {\n")

        prefix = ""


        segments = cell.morphology.segments

        distpoints = {}
#.........这里部分代码省略.........
开发者ID:NeuroML,项目名称:pyNeuroML,代码行数:101,代码来源:NeuroML2ToPOVRay.py


示例18: main

def main():

    args = process_args()

    xmlfile = args.neuroml_file

    pov_file_name = (
        xmlfile.replace(".xml", ".pov").replace(".nml1", ".pov").replace(".nml.h5", ".pov").replace(".nml", ".pov")
    )

    pov_file = open(pov_file_name, "w")

    header = """
/*
POV-Ray file generated from NeuroML network
*/
#version 3.6;

#include "colors.inc"

background {rgbt %s}


    \n"""  ###    end of header

    pov_file.write(header % (args.background))

    cells_file = pov_file
    net_file = pov_file
    splitOut = False

    cf = pov_file_name.replace(".pov", "_cells.inc")
    nf = pov_file_name.replace(".pov", "_net.inc")

    if args.split:
        splitOut = True
        cells_file = open(cf, "w")
        net_file = open(nf, "w")
        print_comment_v("Saving into %s and %s and %s" % (pov_file_name, cf, nf))

    print_comment_v("Converting XML file: %s to %s" % (xmlfile, pov_file_name))

    nml_doc = pynml.read_neuroml2_file(xmlfile, include_includes=True, verbose=args.v)

    cell_elements = []
    cell_elements.extend(nml_doc.cells)
    cell_elements.extend(nml_doc.cell2_ca_poolses)

    minXc = 1e9
    minYc = 1e9
    minZc = 1e9
    maxXc = -1e9
    maxYc = -1e9
    maxZc = -1e9

    minX = 1e9
    minY = 1e9
    minZ = 1e9
    maxX = -1e9
    maxY = -1e9
    maxZ = -1e9

    declaredcells = {}

    print_comment_v("There are %i cells in the file" % len(cell_elements))

    cell_id_vs_seg_id_vs_proximal = {}
    cell_id_vs_seg_id_vs_distal = {}
    cell_id_vs_cell = {}

    for cell in cell_elements:

        cellName = cell.id
        cell_id_vs_cell[cell.id] = cell
        print_comment_v("Handling cell: %s" % cellName)
        cell_id_vs_seg_id_vs_proximal[cell.id] = {}
        cell_id_vs_seg_id_vs_distal[cell.id] = {}

        declaredcell = "cell_" + cellName

        declaredcells[cellName] = declaredcell

        cells_file.write("#declare %s = \n" % declaredcell)
        cells_file.write("union {\n")

        prefix = ""

        segments = cell.morphology.segments

        distpoints = {}
        proxpoints = {}

        for segment in segments:

            id = int(segment.id)

            distal = segment.distal

            x = float(distal.x)
            y = float(distal.y)
#.........这里部分代码省略.........
开发者ID:RokasSt,项目名称:pyNeuroML,代码行数:101,代码来源:NeuroML2ToPOVRay.py


示例19: generate_lems_file_for_neuroml

def generate_lems_file_for_neuroml(sim_id, 
                                   neuroml_file, 
                                   target, 
                                   duration, 
                                   dt, 
                                   lems_file_name,
                                   target_dir,
                                   gen_plots_for_all_v = True,
                                   gen_saves_for_all_v = True,
                                   copy_neuroml = True,
                                   seed=None):
                                       
    
    if seed:
        random.seed(seed) # To ensure same LEMS file (e.g. colours of plots) are generated every time for the same input
    
    file_name_full = '%s/%s'%(target_dir,lems_file_name)
    
    print_comment_v('Creating LEMS file at: %s for NeuroML 2 file: %s'%(file_name_full,neuroml_file))
    
    ls = LEMSSimulation(sim_id, duration, dt, target)
    
    nml_doc = read_neuroml2_file(neuroml_file)
    
    quantities_saved = []
    
    if not copy_neuroml:
        rel_nml_file = os.path.relpath(os.path.abspath(neuroml_file), os.path.abspath(target_dir))
        print_comment_v("Including existing NeuroML file (%s) as: %s"%(neuroml_file, rel_nml_file))
        ls.include_neuroml2_file(rel_nml_file, include_included=True, relative_to_dir=os.path.abspath(target_dir))
    else:
        if os.path.abspath(os.path.dirname(neuroml_file))!=os.path.abspath(target_dir):
            shutil.copy(neuroml_file, target_dir)
        
        neuroml_file_name = os.path.basename(neuroml_file)
        
        ls.include_neuroml2_file(neuroml_file_name, include_included=False)
        
        
        for include in nml_doc.includes:
            incl_curr = '%s/%s'%(os.path.dirname(neuroml_file),include.href)
            print_comment_v(' - Including %s located at %s'%(include.href, incl_curr))
            shutil.copy(incl_curr, target_dir)
            ls.include_neuroml2_file(include.href, include_included=False)
            
            sub_doc = read_neuroml2_file(incl_curr)
        
            for include in sub_doc.includes:
                incl_curr = '%s/%s'%(os.path.dirname(neuroml_file),include.href)
                print_comment_v(' -- Including %s located at %s'%(include.href, incl_curr))
                shutil.copy(incl_curr, target_dir)
                ls.include_neuroml2_file(include.href, include_included=False)
                
                
    if gen_plots_for_all_v or gen_saves_for_all_v:
        
        for network in nml_doc.networks:
            for population in network.populations:
                size = population.size
                component = population.component
                
                quantity_template = "%s[%i]/v"
                if population.type and population.type == 'populationList':
                    quantity_template = "%s/%i/"+component+"/v"
                
                if gen_plots_for_all_v:
                    print_comment('Generating %i plots for %s in population %s'%(size, component, population.id))
   
                    disp0 = 'DispPop__%s'%population.id
                    ls.create_display(disp0, "Voltages of %s"%disp0, "-90", "50")
                    for i in range(size):
                        quantity = quantity_template%(population.id, i)
                        ls.add_line_to_display(disp0, "v %s"%safe_variable(quantity), quantity, "1mV", get_next_hex_color())
                
                if gen_saves_for_all_v:
                    print_comment('Saving %i values of v for %s in population %s'%(size, component, population.id))
   
                    of0 = 'Volts_file__%s'%population.id
                    ls.create_output_file(of0, "%s.%s.v.dat"%(sim_id,population.id))
                    for i in range(size):
                        quantity = quantity_template%(population.id, i)
                        ls.add_column_to_output_file(of0, 'v_%s'%safe_variable(quantity), quantity)
                        quantities_saved.append(quantity)
                        
        
    ls.save_to_file(file_name=file_name_full)
    
    return quantities_saved
开发者ID:christian-oreilly,项目名称:pyNeuroML,代码行数:88,代码来源:__init__.py


示例20: run

def run(a=None,**kwargs): 

    a = build_namespace(a,**kwargs)
    
    pynml.print_comment_v('Generating spiketime plot for %s; plotting: %s; save to: %s'%(a.spiketime_files, a.show_plots_already, a.save_spike_plot_to))
        
    xs = []
    ys = []
    labels = []
    markers = []
    linestyles = []

    offset_id = 0

    max_time = 0
    max_id = 0
    unique_ids = []
    times = OrderedDict()
    ids_in_file = OrderedDict()
    
    if a.format == 'sonata' or a.format == 's':
        
        for file_name in a.spiketime_files:
            ids_times = read_sonata_spikes_hdf5_file(file_name)
            
            x = []
            y = []
            max_id_here = 0

            name = file_name.split('/')[-1]
            if name.endswith('_spikes.h5'): name = name[:-10]
            elif name.endswith('.h5'): name = name[:-3]
            times[name] = []
            ids_in_file[name] = []

            for id in ids_times:
                
                for t in ids_times[id]:
            
                    id_shifted = offset_id+int(float(id))
                    max_id = max(max_id,id_shifted)

                    if not id_shifted in ids_in_file[name]:
                        ids_in_file[name].append(id_shifted)
                    times[name].append(t)
                    max_id_here = max(max_id_here,id_shifted) 
                    max_time = max(t,max_time)
                    if not id_shifted in unique_ids:
                        unique_ids.append(id_shifted)
                    x.append(t)
                    y.append(id_shifted)

            print("max_id_here in %s: %i"%(file_name,max_id_here))
            labels.append("%s (%i)"%(name,max_id_here-offset_id))
            offset_id = max_id_here+1
            xs.append(x)
            ys.append(y)
            markers.append('.')
            linestyles.append('')
            

        xlim = [max_time/-20.0, max_time*1.05]
        ylim = [max_id_here/-20., max_id_here*1.05]
        markersizes = []
        for xx in xs:
            if len(unique_ids)>50:
               markersizes.append(2) 
            elif len(unique_ids)>200:
               markersizes.append(1) 
            else:
               markersizes.append(4) 
    else:
    
        for file_name in a.spiketime_files:
            pynml.print_comment_v("Loading spike times from: %s"%file_name)
            spikes_file = open(file_name)
            x = []
            y = []
            max_id_here = 0

            name = spikes_file.name
            if name.endswith('.spikes'): name = name[:-7]
            if name.endswith('.spike'): name = name[:-6]
            times[name] = []
            ids_in_file[name] = []

            for line in spikes_file:
                if not line.startswith('#'):
                    if a.format == 'id_t':
                        [id, t] = line.split()
                    elif a.format == 't_id':
                        [t, id] = line.split()
                    id_shifted = offset_id+int(float(id))
                    max_id = max(max_id,id_shifted)
                    t = float(t)
                    if not id_shifted in ids_in_file[name]:
                        ids_in_file[name].append(id_shifted)
                    times[name].append(t)
                    max_id_here = max(max_id_here,id_shifted) 
                    max_time = max(t,max_time)
#.........这里部分代码省略.........
开发者ID:NeuroML,项目名称:pyNeuroML,代码行数:101,代码来源:PlotSpikes.py



注:本文中的pyneuroml.pynml.print_comment_v函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.so_numeros函数代码示例发布时间:2022-05-27
下一篇:
Python logger.Logger类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap