def _generate_projections(net_id, gather_subprojections): txt = "" proj_tpl = """ %(pre)s & %(post)s & %(target)s & %(synapse)s & %(description)s \\\\ \\hline """ if gather_subprojections: projections = [] for proj in Global._network[net_id]['projections']: for existing_proj in projections: if proj.pre.name == existing_proj.pre.name and proj.post.name == existing_proj.post.name and proj.target == existing_proj.target : # TODO break else: projections.append(proj) else: projections = Global._network[net_id]['projections'] for proj in projections: # Find a name for the synapse if proj.synapse_type.name in Synapse._default_names.values(): # name not set synapse_name = "Synapse " + str(proj.synapse_type._rk_synapses_type) else: synapse_name = proj.synapse_type.name txt += proj_tpl % { 'pre': LatexParser.pop_name(proj.pre.name), 'post': LatexParser.pop_name(proj.post.name), 'target': LatexParser._format_list(proj.target, ' / '), 'synapse': synapse_name, 'description': proj.connector_description} return connectivity_template % {'projections_description': txt}
def _generate_projections(net_id, gather_subprojections): txt = "" proj_tpl = """ %(pre)s & %(post)s & %(target)s & %(synapse)s & %(description)s \\\\ \\hline """ if gather_subprojections: projections = [] for proj in Global._network[net_id]['projections']: for existing_proj in projections: if proj.pre.name == existing_proj.pre.name and proj.post.name == existing_proj.post.name and proj.target == existing_proj.target : # TODO break else: projections.append(proj) else: projections = Global._network[net_id]['projections'] for proj in projections: # Find a name for the synapse if proj.synapse_type.name in Synapse._default_names.values(): # name not set synapse_name = "Synapse " + str(proj.synapse_type._rk_synapses_type) else: synapse_name = proj.synapse_type.name txt += proj_tpl % { 'pre': LatexParser.pop_name(proj.pre.name), 'post': LatexParser.pop_name(proj.post.name), 'target': LatexParser._format_list(proj.target, ' / '), 'synapse': synapse_name, 'description': proj.connector_description} return connectivity_template % {'projections_description': txt}
def _generate_projection_parameters(net_id, gather_subprojections): txt = "" proj_tpl = """ %(name)s & $%(param)s$ & %(value)s \\\\ \\hline """ if gather_subprojections: projections = [] for proj in Global._network[net_id]['projections']: for existing_proj in projections: if proj.pre.name == existing_proj.pre.name and proj.post.name == existing_proj.post.name and proj.target == existing_proj.target: # TODO break else: projections.append(proj) else: projections = Global._network[net_id]['projections'] first = True for rk, proj in enumerate(projections): parameters = "" for idx, param in enumerate(proj.parameters): if param == 'w': continue if idx == 0: proj_name = "%(pre)s $\\rightarrow$ %(post)s with target %(target)s" % { 'pre': LatexParser.pop_name(proj.pre.name), 'post': LatexParser.pop_name(proj.post.name), 'target': LatexParser._format_list(proj.target, ' / ') } else: proj_name = "" val = proj.init[param] if isinstance(val, (list, np.ndarray)): val = "$[" + str(np.min(val)) + ", " + str(np.max(val)) + "]$" parameters += proj_tpl % { 'name': proj_name, 'param': LatexParser._latexify_name(param, []), 'value': val } if parameters != "": txt += projparameters_template % { 'parameters': parameters, 'firstprojection': "\hdr{3}{H}{Projection parameters}\\\\ \\hline" if first else "" } first = False return txt
def _generate_projection_parameters(net_id, gather_subprojections): txt = "" proj_tpl = """ %(name)s & $%(param)s$ & %(value)s \\\\ \\hline """ if gather_subprojections: projections = [] for proj in Global._network[net_id]['projections']: for existing_proj in projections: if proj.pre.name == existing_proj.pre.name and proj.post.name == existing_proj.post.name and proj.target == existing_proj.target : # TODO break else: projections.append(proj) else: projections = Global._network[net_id]['projections'] first = True for rk, proj in enumerate(projections): parameters = "" for idx, param in enumerate(proj.parameters): if param == 'w': continue if idx == 0: proj_name = "%(pre)s $\\rightarrow$ %(post)s with target %(target)s" % { 'pre': LatexParser.pop_name(proj.pre.name), 'post': LatexParser.pop_name(proj.post.name), 'target': LatexParser._format_list(proj.target, ' / ')} else: proj_name = "" val = proj.init[param] if isinstance(val, (list, np.ndarray)): val = "$[" + str(np.min(val)) + ", " + str(np.max(val)) + "]$" parameters += proj_tpl % {'name': proj_name, 'param': LatexParser._latexify_name(param, []), 'value': val} if parameters != "": txt += projparameters_template % {'parameters': parameters, 'firstprojection': "\hdr{3}{H}{Projection parameters}\\\\ \\hline" if first else ""} first = False return txt
def _generate_summary(net_id): txt = """ # Structure of the network """ # General information backend = 'default' if Global.config['paradigm'] == 'cuda': backend = "CUDA" elif Global.config['paradigm'] == "openmp" and Global.config['num_threads'] > 1: backend = "OpenMP" txt +=""" * ANNarchy %(version)s using the %(backend)s backend. * Numerical step size: %(dt)s ms. """ % {'version': ANNarchy.__release__, 'backend': backend, 'dt': Global.config['dt']} # Populations if len(Global._network[net_id]['populations']) > 0: headers = ["Population", "Size", "Neuron type"] populations = [] for pop in Global._network[net_id]['populations']: # Find a name for the neuron neuron_name = "Neuron " + str(pop.neuron_type._rk_neurons_type) if pop.neuron_type.name in Neuron._default_names.values() \ else pop.neuron_type.name populations.append([ pop.name, pop.geometry if len(pop.geometry)>1 else pop.size, neuron_name]) txt += """ ## Populations """ txt += _make_table(headers, populations) # Projections if len(Global._network[net_id]['projections']) > 0 : headers = ["Source", "Destination", "Target", "Synapse type", "Pattern"] projections = [] for proj in Global._network[net_id]['projections']: # Find a name for the synapse synapse_name = "Synapse " + str(proj.synapse_type._rk_synapses_type) if proj.synapse_type.name in Synapse._default_names.values() \ else proj.synapse_type.name projections.append([ proj.pre.name, proj.post.name, LatexParser._format_list(proj.target, ' / '), synapse_name, proj.connector_description ]) txt += """ ## Projections """ txt += _make_table(headers, projections) # Monitors if len(Global._network[net_id]['monitors']) > 0: headers = ["Object", "Variables", "Period"] monitors = [] for monitor in Global._network[net_id]['monitors']: monitors.append([ monitor.object.name + (" (subset)" if isinstance(monitor.object, PopulationView) else ""), LatexParser._format_list(monitor.variables, ', '), monitor.period ]) txt += """ ## Monitors """ txt += _make_table(headers, monitors) # Functions if len(Global._objects['functions']) > 0 : txt += """## Functions """ for name, func in Global._objects['functions']: txt += LatexParser._process_functions(func, begin="$$", end="$$\n\n") return txt
def _generate_parameters(net_id, gather_subprojections): txt = """ # Parameters """ # Constants if len(Global._objects['constants']) > 0: txt += """ ## Constants """ constants_list = [ ["$" + LatexParser._latexify_name(constant.name, []) + "$", constant.value] for constant in Global._objects['constants']] constants_headers = ["Name", "Value"] txt += _make_table(constants_headers, constants_list) # Population parameters txt += """ ## Population parameters """ parameters_list = [] for rk, pop in enumerate(Global._network[net_id]['populations']): neuron_name = "Neuron " + str(pop.neuron_type._rk_neurons_type) if pop.neuron_type.name in Neuron._default_names.values() \ else pop.neuron_type.name for idx, param in enumerate(pop.parameters): val = pop.init[param] if isinstance(val, (list, np.ndarray)): val = "$[" + str(np.array(val).min()) + ", " + str(np.array(val).max()) + "]$" parameters_list.append( [ LatexParser.pop_name(pop.name) if idx==0 else "", neuron_name if idx==0 else "", "$" + LatexParser._latexify_name(param, []) + "$", val ] ) population_headers = ["Population", "Neuron type", "Name", "Value"] txt += _make_table(population_headers, parameters_list) # Projection parameters txt += """ ## Projection parameters """ if gather_subprojections: projections = [] for proj in Global._network[net_id]['projections']: for existing_proj in projections: if proj.pre.name == existing_proj.pre.name and proj.post.name == existing_proj.post.name \ and proj.target == existing_proj.target : # TODO break else: projections.append(proj) else: projections = Global._network[net_id]['projections'] parameters_list = [] for rk, proj in enumerate(projections): for idx, param in enumerate(proj.parameters): if param == 'w': continue if idx == 0: proj_name = "%(pre)s $\\rightarrow$ %(post)s with target %(target)s" % { 'pre': LatexParser.pop_name(proj.pre.name), 'post': LatexParser.pop_name(proj.post.name), 'target': LatexParser._format_list(proj.target, ' / ')} else: proj_name = "" synapse_name = "Synapse " + str(proj.synapse_type._rk_synapses_type) if proj.synapse_type.name in Synapse._default_names.values() \ else proj.synapse_type.name val = proj.init[param] if isinstance(val, (list, np.ndarray)): val = "$[" + str(np.array(val).min()) + ", " + str(np.array(val).max()) + "]$" parameters_list.append( [ proj_name, synapse_name if idx == 0 else "", "$" + LatexParser._latexify_name(param, []) + "$", val ] ) projection_headers = ["Projection", "Synapse type", "Name", "Value"] txt += _make_table(projection_headers, parameters_list) return txt
def _generate_summary(net_id): txt = """ # Structure of the network """ # General information backend = 'default' if Global.config['paradigm'] == 'cuda': backend = "CUDA" elif Global.config['paradigm'] == "openmp" and Global.config['num_threads'] > 1: backend = "OpenMP" txt +=""" * ANNarchy %(version)s using the %(backend)s backend. * Numerical step size: %(dt)s ms. """ % {'version': ANNarchy.__release__, 'backend': backend, 'dt': Global.config['dt']} # Populations if len(Global._network[net_id]['populations']) > 0: headers = ["Population", "Size", "Neuron type"] populations = [] for pop in Global._network[net_id]['populations']: # Find a name for the neuron neuron_name = "Neuron " + str(pop.neuron_type._rk_neurons_type) if pop.neuron_type.name in Neuron._default_names.values() \ else pop.neuron_type.name populations.append([ pop.name, pop.geometry if len(pop.geometry)>1 else pop.size, neuron_name]) txt += """ ## Populations """ txt += _make_table(headers, populations) # Projections if len(Global._network[net_id]['projections']) > 0 : headers = ["Source", "Destination", "Target", "Synapse type", "Pattern"] projections = [] for proj in Global._network[net_id]['projections']: # Find a name for the synapse synapse_name = "Synapse " + str(proj.synapse_type._rk_synapses_type) if proj.synapse_type.name in Synapse._default_names.values() \ else proj.synapse_type.name projections.append([ proj.pre.name, proj.post.name, LatexParser._format_list(proj.target, ' / '), synapse_name, proj.connector_description ]) txt += """ ## Projections """ txt += _make_table(headers, projections) # Monitors if len(Global._network[net_id]['monitors']) > 0: headers = ["Object", "Variables", "Period"] monitors = [] for monitor in Global._network[net_id]['monitors']: monitors.append([ monitor.object.name + (" (subset)" if isinstance(monitor.object, PopulationView) else ""), LatexParser._format_list(monitor.variables, ', '), monitor.period ]) txt += """ ## Monitors """ txt += _make_table(headers, monitors) # Functions if len(Global._objects['functions']) > 0 : txt += """## Functions """ for name, func in Global._objects['functions']: txt += LatexParser._process_functions(func, begin="$$", end="$$\n\n") return txt
def _generate_parameters(net_id, gather_subprojections): txt = """ # Parameters """ # Constants if len(Global._objects['constants']) > 0: txt += """ ## Constants """ constants_list = [ ["$" + LatexParser._latexify_name(constant.name, []) + "$", constant.value] for constant in Global._objects['constants']] constants_headers = ["Name", "Value"] txt += _make_table(constants_headers, constants_list) # Population parameters txt += """ ## Population parameters """ parameters_list = [] for rk, pop in enumerate(Global._network[net_id]['populations']): neuron_name = "Neuron " + str(pop.neuron_type._rk_neurons_type) if pop.neuron_type.name in Neuron._default_names.values() \ else pop.neuron_type.name for idx, param in enumerate(pop.parameters): val = pop.init[param] if isinstance(val, (list, np.ndarray)): val = "$[" + str(np.array(val).min()) + ", " + str(np.array(val).max()) + "]$" parameters_list.append( [ LatexParser.pop_name(pop.name) if idx==0 else "", neuron_name if idx==0 else "", "$" + LatexParser._latexify_name(param, []) + "$", val ] ) population_headers = ["Population", "Neuron type", "Name", "Value"] txt += _make_table(population_headers, parameters_list) # Projection parameters txt += """ ## Projection parameters """ if gather_subprojections: projections = [] for proj in Global._network[net_id]['projections']: for existing_proj in projections: if proj.pre.name == existing_proj.pre.name and proj.post.name == existing_proj.post.name \ and proj.target == existing_proj.target : # TODO break else: projections.append(proj) else: projections = Global._network[net_id]['projections'] parameters_list = [] for rk, proj in enumerate(projections): for idx, param in enumerate(proj.parameters): if param == 'w': continue if idx == 0: proj_name = "%(pre)s $\\rightarrow$ %(post)s with target %(target)s" % { 'pre': LatexParser.pop_name(proj.pre.name), 'post': LatexParser.pop_name(proj.post.name), 'target': LatexParser._format_list(proj.target, ' / ')} else: proj_name = "" synapse_name = "Synapse " + str(proj.synapse_type._rk_synapses_type) if proj.synapse_type.name in Synapse._default_names.values() \ else proj.synapse_type.name val = proj.init[param] if isinstance(val, (list, np.ndarray)): val = "$[" + str(np.array(val).min()) + ", " + str(np.array(val).max()) + "]$" parameters_list.append( [ proj_name, synapse_name if idx == 0 else "", "$" + LatexParser._latexify_name(param, []) + "$", val ] ) projection_headers = ["Projection", "Synapse type", "Name", "Value"] txt += _make_table(projection_headers, parameters_list) return txt