def _generate_synapse_models(net_id): txt = """ # Synapse models """ for idx, synapse in enumerate(Global._objects['synapses']): # Do not document default synapses if synapse.name == "-": continue # Find a name for the synapse synapse_name = "Synapse " + str(synapse._rk_synapses_type) if synapse.name in Synapse._default_names.values() else synapse.name # Description description = synapse.short_description if description == None: description = "Spiking synapse." if synapse.type == 'spike' else 'Rate-coded synapse' # Parameters parameters = extract_parameters(synapse.parameters, synapse.extra_values) parameters_list = [ ["$" + LatexParser._latexify_name(param['name'], []) + "$", param['init'], _adapt_locality_synapse(param['locality']), param['ctype']] for param in parameters] parameters_headers = ["Name", "Default value", "Locality", "Type"] parameters_table = _make_table(parameters_headers, parameters_list) if len(parameters) == 0: parameters_table = "$$\\varnothing$$" # Generate the code for the equations psp, variables, pre_desc, post_desc = LatexParser._process_synapse_equations(synapse) eqs = _process_variables(variables, neuron = False) # PSP if synapse.type == "rate": psp = """ **Weighted sum:** $$%(transmission)s$$ """ % {'transmission': psp} elif synapse.type == "spike" and psp != "": psp = """ **Continuous transmission:** $$%(transmission)s$$ """ % {'transmission': psp} else: psp = "" # Pre- and post-events if synapse.type == "spike": if len(pre_desc) > 0: eqs += """ **Pre-synaptic event at $t_\\text{pre} + d$:** """ for pre in pre_desc: eqs += "$$"+pre+"$$\n" if len(post_desc) > 0: eqs += """ **Post-synaptic event at $t_\\text{post}$:** """ for post in post_desc: eqs += "$$"+post+"$$\n" # Finalize the template txt += synapse_tpl % { 'name': synapse_name, 'description': description, 'psp': psp, 'parameters': parameters_table, 'eqs': eqs} return txt
def _generate_synapse_models(net_id): firstsynapse = "" synapses = "" firstsynapse = "\\hdr{2}{E}{Synapse Models}\\\\ \\hline" synapse_tpl = """ \\noindent \\begin{tabularx}{\\linewidth}{|p{0.15\\linewidth}|X|}\\hline %(firstsynapse)s \\textbf{Name} & %(name)s \\\\ \\hline \\textbf{Type} & %(description)s\\\\ \\hline %(psp)s %(variables)s %(preevent)s %(postevent)s %(functions)s \\end{tabularx} \\vspace{2ex} """ for idx, synapse in enumerate(Global._objects['synapses']): # Do not document default synapses if synapse.name == "-": continue # Find a name for the synapse if synapse.name in Synapse._default_names.values(): # name not set synapse_name = "Synapse " + str(synapse._rk_synapses_type) else: synapse_name = synapse.name # Generate the code for the equations psp, variables, pre_desc, post_desc = LatexParser._process_synapse_equations(synapse) eqs = "" for var in variables: eqs += """ \\begin{dmath*} %(eq)s \\end{dmath*} """ % {'eq': var['latex']} variables_eqs = """ %(eqs)s \\\\ \\hline """ % {'eqs': eqs} # Synaptic variables variables = """ \\textbf{Equations} & %(variables)s \\\\ \\hline""" % {'variables':eqs} if eqs != "" else "" # PSP if psp != "": psp_code = """ \\textbf{PSP} & \\begin{dmath*} %(psp)s \\end{dmath*} \\\\ \\hline""" % {'psp': psp} else: psp_code = "" # Spiking neurons have extra fields for the event-driven if synapse.type == 'spike': if len(pre_desc) > 0: txt_pre = "" for l in pre_desc: txt_pre += """ \\begin{dmath*} %(eq)s \\end{dmath*} """ % {'eq': l} preevent = """ \\textbf{Pre-synaptic event} & %(preevent)s \\\\ \\hline """ % {'preevent': txt_pre} else: preevent = "" if len(post_desc) > 0: txt_post = "" for l in post_desc: txt_post += """ \\begin{dmath*} %(eq)s \\end{dmath*} """ % {'eq': l} postevent = """ \\textbf{Post-synaptic event} & %(postevent)s \\\\ \\hline """ % {'postevent': txt_post} else: postevent = "" else: preevent = "" postevent = "" # Possible functions functions = "" if not synapse.functions == None: functions = """ \\textbf{Functions} & %(functions)s \\\\ \\hline """ % {'functions': LatexParser._process_functions(synapse.functions)} # Build the dictionary desc = { 'name': synapse_name, 'description': synapse.short_description, 'firstsynapse': firstsynapse if idx == 0 else "", 'variables': variables, 'psp': psp_code, 'preevent': preevent, 'postevent': postevent, 'functions': functions } # Generate the code synapses += synapse_tpl % desc return synapses