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_populations(net_id): def format_size(pop): size = str(pop.size) if pop.dimension >1: size += ' (' for d in range(pop.dimension): size += str(pop.geometry[d]) + '*' size = size.rsplit('*', 1)[0] + ')' return size txt = "" pop_tpl = """ %(pop_name)s & %(neuron_type)s & $N_{\\text{%(pop_name)s}}$ = %(size)s \\\\ \\hline """ for pop in Global._network[net_id]['populations']: # Find a name for the neuron if pop.neuron_type.name in Neuron._default_names.values(): # name not set neuron_name = "Neuron " + str(pop.neuron_type._rk_neurons_type) else: neuron_name = pop.neuron_type.name txt += pop_tpl % { 'pop_name': LatexParser.pop_name(pop.name), 'neuron_type': neuron_name, 'size': format_size(pop)} return populations_template % {'populations_description': txt}
def _generate_population_parameters(net_id): txt = "" pop_tpl = """ %(name)s & $%(param)s$ & %(value)s \\\\ \\hline """ for rk, pop in enumerate(Global._network[net_id]['populations']): parameters = "" 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 += pop_tpl % { 'name': LatexParser.pop_name(pop.name) if idx == 0 else "", 'param': LatexParser._latexify_name(param, []), 'value': val } txt += popparameters_template % { 'parameters': parameters, 'firstpopulation': "\hdr{3}{H}{Population parameters}\\\\ \\hline" if rk == 0 else "" } return txt
def _generate_summary(net_id): "part A" population_names = str(len(Global._network[net_id]['populations'])) + ': ' connectivity = "" neuron_models = "" synapse_models = "" # List the names of all populations for pop in Global._network[net_id]['populations']: # population name population_names += LatexParser.pop_name(pop.name) + ", " population_names = population_names[:-2] # suppress the last , # List all BOLD recordings measurements = "" # List all neuron types neuron_model_names = [] for neur in Global._objects['neurons']: # bold models sorted in measurements if isinstance(neur, BoldModel): if neur._model_instantiated: measurements += neur.name + ', ' # neuron model else: neuron_model_names.append(neur.name) for neur in list(set(neuron_model_names)): neuron_models += neur + ', ' # suppress the last , measurements = measurements[:-2] neuron_models = neuron_models[:-2] list_connectivity = [] list_synapse_models = [] for proj in Global._network[net_id]['projections']: list_connectivity.append(proj.connector_name) if not proj.synapse_type.name in list(Synapse._default_names.values()) + ['-']: list_synapse_models.append(proj.synapse_type.name) for con in list(set(list_connectivity)): connectivity += con + ', ' for syn in list(set(list_synapse_models)): synapse_models += syn + ', ' connectivity = connectivity[:-2] synapse_models = synapse_models[:-2] # suppress the last , # Write the summary txt = summary_template % { 'population_names' : population_names, 'connectivity' : connectivity, 'neuron_models' : neuron_models, 'synapse_models' : synapse_models, 'measurements': measurements } 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_population_parameters(net_id): txt = "" pop_tpl = """ %(name)s & $%(param)s$ & %(value)s \\\\ \\hline """ for rk, pop in enumerate(Global._network[net_id]['populations']): parameters = "" 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 += pop_tpl % {'name': LatexParser.pop_name(pop.name) if idx==0 else "", 'param': LatexParser._latexify_name(param, []), 'value': val} txt += popparameters_template % {'parameters': parameters, 'firstpopulation': "\hdr{3}{H}{Population parameters}\\\\ \\hline" if rk==0 else ""} return txt
def _generate_summary(net_id): "part A" population_names = str(len(Global._network[net_id]['populations'])) + ': ' connectivity = "" neuron_models = "" synapse_models = "" # List the names of all populations for pop in Global._network[net_id]['populations']: # population name population_names += LatexParser.pop_name(pop.name) + ", " population_names = population_names[:-2] # suppress the last , # List all neuron types neuron_model_names = [] for neur in Global._objects['neurons']: neuron_model_names.append(neur.name) for neur in list(set(neuron_model_names)): neuron_models += neur + ', ' neuron_models = neuron_models[:-2] # suppress the last , list_connectivity = [] list_synapse_models = [] for proj in Global._network[net_id]['projections']: list_connectivity.append(proj.connector_name) if not proj.synapse_type.name in list(Synapse._default_names.values()) + ['-']: list_synapse_models.append(proj.synapse_type.name) for con in list(set(list_connectivity)): connectivity += con + ', ' for syn in list(set(list_synapse_models)): synapse_models += syn + ', ' connectivity = connectivity[:-2] synapse_models = synapse_models[:-2] # suppress the last , # Write the summary txt = summary_template % { 'population_names' : population_names, 'connectivity' : connectivity, 'neuron_models' : neuron_models, 'synapse_models' : synapse_models } 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