Commit 6571c170 authored by DeLaVlag's avatar DeLaVlag

manual merge with dsl branche

parent ad314e23
from mako.template import Template
from model.model import Model
import os
import tvb
def regTVB_templating(filename, modelname):
def regTVB_templating(model_filename):
"""
function will start generation of regular TVB models according to fp_xml
modelfile.py is placed results into tvb/simulator/models
......@@ -9,14 +11,17 @@ def regTVB_templating(filename, modelname):
file_class_name is the name of the producedfile and also the class name
"""
fp_xml = 'NeuroML/' + filename.lower() + '.xml'
modelfile = "../simulator/models/" + filename.lower() + "T.py"
fp_xml = "{}{}{}{}".format(os.path.dirname(tvb.__file__),'/dsl/NeuroML/XMLmodels/',model_filename.lower(),'.xml')
modelfile = "{}{}{}{}".format(os.path.dirname(tvb.__file__),'/simulator/models/',model_filename.lower(),'.py')
fp_xml = 'NeuroML/XMLmodels/' + model_filename.lower() + '.xml'
modelfile = "../simulator/models/" + model_filename.lower() + "T.py"
model = Model()
model.import_from_file(fp_xml)
modelist = list()
modelist.append(model.component_types[modelname])
modelist.append(model.component_types[model_filename])
# do some inventory. check if boundaries are set for any sv to print the boundaries section in template
svboundaries = 0
......@@ -27,7 +32,7 @@ def regTVB_templating(filename, modelname):
# add a T to the class name to not overwrite existing models
# start templating
modelname=modelname+'T'
modelname=model_filename+'T'
template = Template(filename='tmpl8_regTVB.py')
model_str = template.render(
dfunname=modelname,
......@@ -41,13 +46,37 @@ def regTVB_templating(filename, modelname):
f.writelines(model_str)
# write new model to init.py such it is familiar to TVB
doprint=1
with open("../simulator/models/__init__.py", "r+") as f:
for line in f.readlines():
if ("from ." + filename.lower() + "T import " + modelname) in line:
doprint=0
# doprint=1
# with open("../simulator/models/__init__.py", "r+") as f:
# for line in f.readlines():
# if ("from ." + filename.lower() + "T import " + modelname) in line:
# doprint=0
# if doprint:
# f.writelines("\nfrom ." + filename.lower() + "T import " + modelname)
# write new model to init.py such it is familiar to TVB if not already present
# try:
doprint=True
modelenumnum=0
modulemodnum=0
with open("{}{}".format(os.path.dirname(tvb.__file__),'/simulator/models/__init__.py'), "r+") as f:
lines = f.readlines()
for num, line in enumerate(lines):
if (model_filename.upper() + 'T = ' + "\"" + model_filename + "T\"") in line:
doprint=False
elif ("class ModelsEnum(Enum):") in line:
modelenumnum = num
elif ("_module_models = {") in line:
modulemodnum = num
if doprint:
f.writelines("\nfrom ." + filename.lower() + "T import " + modelname)
lines.insert(modelenumnum + 1, " " + model_filename.upper() + 'T = ' + "\"" + model_filename + "T\"\n")
lines.insert(modulemodnum + 2, " " + "'" + model_filename.lower() + "T'" + ': '
+ "[ModelsEnum." + model_filename.upper() + "T],\n")
f.truncate(0)
f.seek(0)
f.writelines(lines)
# except:
# print('unable to add new model to __init__.py')
if __name__ == '__main__':
drift_templating('Generic2dOscillator')
......
<Lems
xmlns="http://www.neuroml.org/lems/0.7.4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.neuroml.org/lems/0.7.4 ../../LEMS/Schemas/LEMS/LEMS_v0.7.4.xsd"
description="A number of ComponentTypes for rate based/population models.
Base type of any cell/population which has a (dimensionless) rate _R.
Epileptor 2-D (phase plane) oscillator.">
<ComponentType name="EpileptorT"
description="Rate based 2D oscillator for TVB"
value="">
<!-- If empty then none -->
<Constant name="a" domain="None" default="1.0" description="Coefficient of the cubic term in the first state-variable."/>
<Constant name="b" domain="None" default="3.0" description="Coefficient of the squared term in the first state-variable."/>
<Constant name="c" domain="None" default="1.0" description="Additive coefficient for the second state-variable x_{2}, called :math:`y_{0}` in Jirsa paper."/>
<Constant name="d" domain="None" default="5.0" description="Coefficient of the squared term in the second state-variable x_{2}."/>
<Constant name="r" domain="lo=0.0, hi=0.001, step=0.00005" default="0.00035" description="Temporal scaling in the slow state-variable, called :math:`1\\tau_{0}` in Jirsa paper (see class Epileptor)."/>
<Constant name="s" domain="None" default="4.0" description="Linear coefficient in the third state variable"/>
<Constant name="x0" domain="lo=-3.0, hi=-1.0, step=0.1" default="-1.6" description="Epileptogenicity parameter."/>
<Constant name="Iext" domain="lo=1.5, hi=5.0, step=0.1" default="3.1" description="External input current to the first state-variable."/>
<Constant name="slope" domain="lo=-16.0, hi=6.0, step=0.1" default="0." description="Linear coefficient in the first state-variable."/>
<Constant name="Iext2" domain="lo=0.0, hi=1.0, step=0.05" default="0.45" description="External input current to the first state-variable."/>
<Constant name="tau" domain="None" default="10.0" description="Temporal scaling coefficient in fifth state variable."/>
<Constant name="aa" domain="None" default="6.0" description="Linear coefficient in fifth state variable."/>
<Constant name="bb" domain="None" default="2.0" description="Linear coefficient of lowpass excitatory coupling in fourth state variable."/>
<Constant name="Kvf" domain="lo=0.0, hi=4.0, step=0.5" default="0.0" description="Coupling scaling on a very fast time scale."/>
<Constant name="Kf" domain="lo=0.0, hi=4.0, step=0.5" default="0.0" description="Correspond to the coupling scaling on a fast time scale."/>
<Constant name="Ks" domain="lo=-4.0, hi=4.0, step=0.1" default="0.0" description="Permittivity coupling, that is from the fast time scale toward the slow time scale."/>
<Constant name="tt" domain="lo=0.001, hi=10.0, step=0.001" default="1.0" description="Time scaling of the whole system to the system in real time."/>
<Constant name="modification" domain="None" default="False" description="When modification is True, then use nonlinear influence on z. The default value is False, i.e., linear influence."/>
<Dynamics>
<!-- "State variable ranges [lo, hi]" values are entered with keyword "default" -->
<!-- For each state variable a set of bondaries can be added to encompass the boundaries of the dynamic range -->
<!-- Leave empty "" for no boundaries. Set None for one-sided boundaries, ie: "1.0, None" -->
<StateVariable name="x1" default="-2., 1." boundaries=""/>
<StateVariable name="y1" default="-20., 2." boundaries=""/>
<StateVariable name="z" default="2.0, 5.0" boundaries=""/>
<StateVariable name="x2" default="-2., 0." boundaries=""/>
<StateVariable name="y2" default="0., 2." boundaries=""/>
<StateVariable name="g" default="-1, 1." boundaries=""/>
<!-- Derived variables can be used to 'easify' the time derivatives, enter the local coupling formulas or any formula -->
<!-- sytax: [name]=[expression] -->
<!-- Define for ex. global and local coupling: c_0 = coupling[0, ] and lc_0 = local_coupling -->
<DerivedVariable name="c_pop1" expression="coupling[0]"/>
<DerivedVariable name="c_pop2" expression="coupling[1]"/>
<DerivedVariable name="Iext" expression="Iext + local_coupling * x1"/>
<!-- For conditionals use &lt(=); or &gt;(=) for less- or greater then (equal to) -->
<!-- Conditional used for if statement, syntax: if {condition} -> {cases[0]} else {cases[1]}. Cases are separated by (,) -->
<!-- Population 1 -->
<ConditionalDerivedVariable name="ydot0" condition="x1 &lt; 0.0" cases="-a * x1**2 + b * x1, slope - x2 + 0.6 * (z - 4)**2 "/>
<TimeDerivative name="dx1" expression="tt * (y1 - z + Iext + Kvf * c_pop1 + ydot0 * x1)"/>
<TimeDerivative name="dy1" expression="tt * (c - d * x1**2 - y1)"/>
<!-- Energy -->
<ConditionalDerivedVariable name="ydot2" condition="z &lt; 0.0" cases="- 0.1 * (z**7), 0"/>
<ConditionalDerivedVariable name="h" condition="modification" cases="x0 + 3. / (1. + exp(-(x1 + 0.5) / 0.1)), 4 * (x1 - x0) + ydot2"/>
<TimeDerivative name="dz" expression="tt * (r * (h - z + Ks * c_pop1))"/>
<!-- Population 2 -->
<TimeDerivative name="dx2" expression="tt * (-y2 + x2 - x2**3 + Iext2 + bb * g - 0.3 * (z - 3.5) + Kf * c_pop2)"/>
<ConditionalDerivedVariable name="ydot4" condition="x2 &lt; -0.25" cases="0.0, aa * (x2 + 0.25)"/>
<TimeDerivative name="dy2" expression="tt * ((-y2 + ydot4) / tau)"/>
<!-- Filter -->
<TimeDerivative name="dg" expression="tt * (-0.01 * (g - 0.1 * x1) )"/>
</Dynamics>
<!-- Exposures are used for observables, for the name enter variable to be observed (usually states)
and for dimension enter the reduction functionality. Will be represented as variables_of_interest.
Choices and default list with a (,) separator-->
<Exposure name="x1" default="x2 - x1, z" choices="x1, y1, z, x2, y2, g, x2 - x1" description="Quantities of the Epileptor available to monitor."/>
</ComponentType>
</Lems>
\ No newline at end of file
<Lems
xmlns="http://www.neuroml.org/lems/0.7.4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.neuroml.org/lems/0.7.4 ../../LEMS/Schemas/LEMS/LEMS_v0.7.4.xsd"
description="A number of ComponentTypes for rate based/population models.
Base type of any cell/population which has a (dimensionless) rate _R.
Generic nonlinear 2-D (phase plane) oscillator.">
<ComponentType name="Generic2dOscillator"
description="Rate based 2D oscillator for TVB"
value="">
<!-- If empty then none -->
<Constant name="tau" domain="lo=1.0, hi=5.0, step=0.01" default="1.0"
description="A time-scale hierarchy can be introduced for the state variables :math:`V` and :math:`W`. Default parameter is 1, which means no time-scale hierarchy."/>
<Constant name="I" domain="lo=-5.0, hi=5.0, step=0.01" default="0.0" description="Baseline shift of the cubic nullcline"/>
<Constant name="a" domain="lo=-5.0, hi=5.0, step=0.01" default="-2.0" description="Vertical shift of the configurable nullcline"/>
<Constant name="b" domain="lo=-20.0, hi=15.0, step=0.01" default="-10.0" description="Linear slope of the configurable nullcline"/>
<Constant name="c" domain="lo=-10.0, hi=10.0, step=0.01" default="0" description="Parabolic term of the configurable nullcline"/>
<Constant name="d" domain="lo=0.0001, hi=1.0, step=0.0001" default="0.02" description="Temporal scale factor. Warning: do not use it unless you know what you are doing and know about time tides."/>
<Constant name="e" domain="lo=-5.0, hi=5.0, step=0.0001" default="3.0" description="Coefficient of the quadratic term of the cubic nullcline."/>
<Constant name="f" domain="lo=-5.0, hi=5.0, step=0.0001" default="1.0" description="Coefficient of the cubic term of the cubic nullcline."/>
<Constant name="g" domain="lo=-5.0, hi=5.0, step=0.5" default="0.0" description="Coefficient of the linear term of the cubic nullcline."/>
<Constant name="alpha" domain="lo=-5.0, hi=5.0, step=0.0001" default="1.0" description="Constant parameter to scale the rate of feedback from the slow variable to the fast variable."/>
<Constant name="beta" domain="lo=-5.0, hi=5.0, step=0.0001" default="1.0" description="Constant parameter to scale the rate of feedback from the slow variable to itself"/>
<Constant name="gamma" domain="lo=-1.0, hi=1.0, step=0.1" default="1.0" description="Constant parameter to reproduce FHN dynamics where excitatory input currents are negative. It scales both I and the long range coupling term.."/>
<Dynamics>
<!-- "State variable ranges [lo, hi]" values are entered with keyword "default" -->
<!-- For each state variable a set of bondaries can be added to encompass the boundaries of the dynamic range -->
<!-- Leave empty "" for no boundaries. Set None for one-sided boundaries, ie: "1.0, None" -->
<StateVariable name="V" default="-2.0, 4.0" boundaries=""/>
<StateVariable name="W" default="-6.0, 6.0" />
<!-- For conditionals use &lt(=); or &gt;(=) for less- or greater then (equal to) -->
<!-- Conditional used for if statement, syntax: if {condition} -> {cases[0]} else {cases[1]}. Cases are separated by (,) -->
<TimeDerivative name="dV" expression="d * tau * (alpha * W - f * V**3 + e * V**2 + g * V + gamma * I + gamma * coupling[0] + local_coupling)"/>
<TimeDerivative name="dW" expression="d * (a + b * V + c * V**2 - beta * W) / tau"/>
</Dynamics>
<!-- Exposures are used for observables, for the name enter variable to be observed (usually states)
and for dimension enter the reduction functionality. Will be represented as variables_of_interest.
Choices and default list with a (,) separator-->
<Exposure name="V" choices="V, W, V + W, V - W" default="V"/>
</ComponentType>
</Lems>
\ No newline at end of file
<Lems
xmlns="http://www.neuroml.org/lems/0.7.4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.neuroml.org/lems/0.7.4 ../../LEMS/Schemas/LEMS/LEMS_v0.7.4.xsd"
description="A number of ComponentTypes for rate based/population models.
Base type of any cell/population which has a (dimensionless) rate _R.
Generic nonlinear 2-D (phase plane) oscillator.">
<ComponentType name="Generic2dOscillatorT"
description="Rate based 2D oscillator for TVB"
value="">
<!-- If empty then none -->
<Constant name="tau" domain="lo=1.0, hi=5.0, step=0.01" default="1.0"
description="A time-scale hierarchy can be introduced for the state variables :math:`V` and :math:`W`. Default parameter is 1, which means no time-scale hierarchy."/>
<Constant name="I" domain="lo=-5.0, hi=5.0, step=0.01" default="0.0" description="Baseline shift of the cubic nullcline"/>
<Constant name="a" domain="lo=-5.0, hi=5.0, step=0.01" default="-2.0" description="Vertical shift of the configurable nullcline"/>
<Constant name="b" domain="lo=-20.0, hi=15.0, step=0.01" default="-10.0" description="Linear slope of the configurable nullcline"/>
<Constant name="c" domain="lo=-10.0, hi=10.0, step=0.01" default="0" description="Parabolic term of the configurable nullcline"/>
<Constant name="d" domain="lo=0.0001, hi=1.0, step=0.0001" default="0.02" description="Temporal scale factor. Warning: do not use it unless you know what you are doing and know about time tides."/>
<Constant name="e" domain="lo=-5.0, hi=5.0, step=0.0001" default="3.0" description="Coefficient of the quadratic term of the cubic nullcline."/>
<Constant name="f" domain="lo=-5.0, hi=5.0, step=0.0001" default="1.0" description="Coefficient of the cubic term of the cubic nullcline."/>
<Constant name="g" domain="lo=-5.0, hi=5.0, step=0.5" default="0.0" description="Coefficient of the linear term of the cubic nullcline."/>
<Constant name="alpha" domain="lo=-5.0, hi=5.0, step=0.0001" default="1.0" description="Constant parameter to scale the rate of feedback from the slow variable to the fast variable."/>
<Constant name="beta" domain="lo=-5.0, hi=5.0, step=0.0001" default="1.0" description="Constant parameter to scale the rate of feedback from the slow variable to itself"/>
<Constant name="gamma" domain="lo=-1.0, hi=1.0, step=0.1" default="1.0" description="Constant parameter to reproduce FHN dynamics where excitatory input currents are negative. It scales both I and the long range coupling term.."/>
<Dynamics>
<!-- "State variable ranges [lo, hi]" values are entered with keyword "default" -->
<!-- For each state variable a set of bondaries can be added to encompass the boundaries of the dynamic range -->
<!-- Leave empty "" for no boundaries. Set None for one-sided boundaries, ie: "1.0, None" -->
<StateVariable name="V" default="-2.0, 4.0" boundaries=""/>
<StateVariable name="W" default="-6.0, 6.0" />
<!-- For conditionals use &lt(=); or &gt;(=) for less- or greater then (equal to) -->
<!-- Conditional used for if statement, syntax: if {condition} -> {cases[0]} else {cases[1]}. Cases are separated by (,) -->
<TimeDerivative name="dV" expression="d * tau * (alpha * W - f * V**3 + e * V**2 + g * V + gamma * I + gamma * coupling[0] + local_coupling)"/>
<TimeDerivative name="dW" expression="d * (a + b * V + c * V**2 - beta * W) / tau"/>
</Dynamics>
<!-- Exposures are used for observables, for the name enter variable to be observed (usually states)
and for dimension enter the reduction functionality. Will be represented as variables_of_interest.
Choices and default list with a (,) separator-->
<Exposure name="V" choices="V, W, V + W, V - W" default="V"/>
</ComponentType>
</Lems>
\ No newline at end of file
<Lems
xmlns="http://www.neuroml.org/lems/0.7.4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.neuroml.org/lems/0.7.4 ../../LEMS/Schemas/LEMS/LEMS_v0.7.4.xsd"
description="A number of ComponentTypes for rate based/population models.">
<ComponentType name="KuramotoT"
description="Base type of any cell/population which has a (dimensionless) rate _R."
value="none">
<Constant name="omega" domain="lo=0.01, hi=200.0, step=0.1" default="1.0" description="sets the base line frequency for the Kuramoto oscillator in [rad/ms]"/>
<Dynamics>
<!-- "State variable ranges [lo, hi]" values are entered with keyword "default" -->
<!-- For each state variable a set of bondaries can be added to encompass the boundaries of the dynamic range -->
<!-- Leave empty "" for no boundaries. Set None for one-sided boundaries, ie: "1.0, None" -->
<StateVariable name="theta" default="0.0, pi * 2.0" boundaries=""/>
<!-- Derived variables can be used to 'easify' the time derivatives, enter the local coupling formulas or any formula -->
<!-- sytax: [name]=[expression] -->
<!-- Define for ex. global and local coupling: c_0 = coupling[0, ] and lc_0 = local_coupling -->
<DerivedVariable name="I" expression="coupling[0] + sin(local_coupling * theta)"/>
<TimeDerivative name="dV" expression="omega + I"/>
</Dynamics>
<!-- Exposures are used for observables, for the name enter variable to be observed (usually states)
and for dimension enter the reduction functionality. Will be represented as variables_of_interest.
Choices and default list with a (,) separator-->
<Exposure name="theta" default="theta" choices="theta"/>
</ComponentType>
</Lems>
......@@ -4,7 +4,7 @@
xsi:schemaLocation="http://www.neuroml.org/lems/0.7.4 ../../LEMS/Schemas/LEMS/LEMS_v0.7.4.xsd"
description="Rate based/population models translated using LEMS.">
<ComponentType name="Theta2D"
<ComponentType name="Montbrio"
description="2D model describing the Ott-Antonsen reduction of infinitely all-to-all coupled QIF neurons (Theta-neurons)."
value="">
......
<Lems
xmlns="http://www.neuroml.org/lems/0.7.4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.neuroml.org/lems/0.7.4 ../../LEMS/Schemas/LEMS/LEMS_v0.7.4.xsd"
description="Rate based/population models translated using LEMS.">
<ComponentType name="MontbrioT"
description="2D model describing the Ott-Antonsen reduction of infinitely all-to-all coupled QIF neurons (Theta-neurons)."
value="">
<!-- If empty then none -->
<Constant name="I" domain="lo=-10.0, hi=10.0, step=0.01" default="0.0" description="???"/>
<Constant name="Delta" domain="lo=0.0, hi=10.0, step=0.01" default="1.0" description="Vertical shift of the configurable nullcline."/>
<Constant name="alpha" domain="lo=0.0, hi=1.0, step=0.1" default="1.0" description=":math:`\alpha` ratio of effect between long-range and local connectivity."/>
<Constant name="s" domain="lo=-15.0, hi=15.0, step=0.01" default="0.0" description="QIF membrane reversal potential."/>
<Constant name="k" domain="lo=-15.0, hi=15.0, step=0.01" default="0.0" description="Switch for the terms specific to Coombes model."/>
<Constant name="J" domain="lo=-25.0, hi=25.0, step=0.0001" default="15.0" description="Constant parameter to scale the rate of feedback from the slow variable to the firing rate variable."/>
<Constant name="eta" domain="lo=-10.0, hi=10.0, step=0.0001" default="-5.0" description="Constant parameter to scale the rate of feedback from the firing rate variable to itself"/>
<Constant name="Gamma" domain="lo=0., hi=10.0, step=0.1" default="0.0" description="Derived from eterogeneous currents and synaptic weights (see Montbrio p.12)."/>
<Constant name="gamma" domain="lo=-2.0, hi=2.0, step=0.1" default="1.0" description="Constant parameter to reproduce FHN dynamics where excitatory input currents are negative. It scales both I and the long range coupling term."/>
<Dynamics>
<!-- "State variable ranges [lo, hi]" values are entered with keyword "default" -->
<!-- For each state variable a set of bondaries can be added to encompass the boundaries of the dynamic range -->
<!-- Leave empty "" for no boundaries. Set None for one-sided boundaries, ie: "1.0, None" -->
<StateVariable name="r" default="0., 2.0" boundaries="0.0, inf"/>
<StateVariable name="V" default="-2.0, 1.5" boundaries=""/>
<!-- Derived variables can be used to 'easify' the time derivatives, enter the local coupling formulas or any formula -->
<!-- sytax: [name]=[expression] -->
<!-- Define for ex. global and local coupling: c_0 = coupling[0, ] and lc_0 = local_coupling -->
<DerivedVariable name="Coupling_global" expression="alpha * coupling[0]"/>
<DerivedVariable name="Coupling_local" expression="(1-alpha) * local_coupling * r"/>
<DerivedVariable name="Coupling_Term" expression="Coupling_global + Coupling_local"/>
<!-- For conditionals use &lt(=); or &gt;(=) for less- or greater then (equal to) -->
<!-- Conditional used for if statement, syntax: if {condition} -> {cases[0]} else {cases[1]}. Cases are separated by (,) -->
<TimeDerivative name="dx" expression="Delta / pi + 2 * V * r - k * r**2 + Gamma * r / pi"/>
<TimeDerivative name="dy" expression="V**2 - pi**2 * r**2 + eta + (k * s + J) * r - k * V * r + gamma * I + Coupling_Term"/>
</Dynamics>
<!-- Exposures are used for observables, for the name enter variable to be observed (usually states)
and for dimension enter the reduction functionality. Will be represented as variables_of_interest.
Choices and default list with a (,) separator-->
<Exposure name="r" choices="r, V" default="r, V" description="The quantities of interest for monitoring for the Infinite QIF 2D oscillator."/>
</ComponentType>
</Lems>
\ No newline at end of file
<Lems
xmlns="http://www.neuroml.org/lems/0.7.4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.neuroml.org/lems/0.7.4 ../../LEMS/Schemas/LEMS/LEMS_v0.7.4.xsd"
description="A number of ComponentTypes for rate based/population models.
Base type of any cell/population which has a (dimensionless) rate _R.
Generic nonlinear 2-D (phase plane) oscillator.">
<ComponentType name="ReducedWongWang"
description="Rate based 2D oscillator for TVB"
value="">
<Constant name="a" domain="lo=0.0, hi=0.270, step=0.01" default="0.270" description="[n/C]. Input gain parameter, chosen to fit numerical solutions."/>
<Constant name="b" domain="lo=0.0, hi=1.0, step=0.01" default="0.108" description="[kHz]. Input shift parameter chosen to fit numerical solutions."/>
<Constant name="d" domain="lo=0.0, hi=200.0, step=0.01" default="154." description="[ms]. Parameter chosen to fit numerical solutions."/>
<Constant name="gamma" domain="lo=0.0, hi=1.0, step=0.01" default="0.641" description="Kinetic parameter"/>
<Constant name="tau_s" domain="lo=50., hi=150., step=1." default="100." description="Kinetic parameter. NMDA decay time constant."/>
<Constant name="w" domain="lo=0.0, hi=1.0, step=0.01" default="0.6" description="Excitatory recurrence"/>
<Constant name="J_N" domain="lo=0.2609, hi=0.5, step=0.001" default="0.2609" description="Excitatory recurrence"/>
<Constant name="I_o" domain="lo=0.0, hi=1.0, step=0.01" default="0.33" description="[nA] Effective external input"/>
<!-- <Constant name="sigma_noise" symbol="NArray" dimension="lo=0.0, hi=0.005, step=0.0001" value="0.000000001" description="[nA] Noise amplitude. Take this value into account for stochatic-->
<!-- integration schemes."/>-->
<Dynamics>
<!-- "State variable ranges [lo, hi]" values are entered with keyword "default" -->
<!-- For each state variable a set of bondaries can be added to encompass the boundaries of the dynamic range -->
<!-- Leave empty "" for no boundaries. Set None for one-sided boundaries, ie: "1.0, None" -->
<StateVariable name="S" default="0.0, 1.0" boundaries="0.0, 1.0"/>
<!-- Derived variables can be used to 'easify' the time derivatives, enter the local coupling formulas or any formula -->
<!-- sytax: [name]=[expression] -->
<!-- Define for ex. global and local coupling: c_0 = coupling[0, ] and lc_0 = local_coupling -->
<DerivedVariable name="x" expression="w * J_N * S + I_o + J_N * coupling[0] + J_N * local_coupling"/>
<DerivedVariable name="H" expression="(a * x - b) / (1 - exp(-d * (a * x - b)))"/>
<TimeDerivative name="dS" expression="- (S / tau_s) + (1 - S) * H * gamma"/>
</Dynamics>
<!-- Exposures are used for observables, for the name enter variable to be observed (usually states)
and for dimension enter the reduction functionality. Will be represented as variables_of_interest.
Choices and default list with a (,) seperator-->
<Exposure name="S" choices="S" default="S" description="default state variables to be monitored"/>
</ComponentType>
</Lems>
\ No newline at end of file
<Lems
xmlns="http://www.neuroml.org/lems/0.7.4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.neuroml.org/lems/0.7.4 ../../LEMS/Schemas/LEMS/LEMS_v0.7.4.xsd"
description="A number of ComponentTypes for rate based/population models.
Base type of any cell/population which has a (dimensionless) rate _R.
Generic nonlinear 2-D (phase plane) oscillator.">
<ComponentType name="ReducedWongWangT"
description="Rate based 2D oscillator for TVB"
value="">
<Constant name="a" domain="lo=0.0, hi=0.270, step=0.01" default="0.270" description="[n/C]. Input gain parameter, chosen to fit numerical solutions."/>
<Constant name="b" domain="lo=0.0, hi=1.0, step=0.01" default="0.108" description="[kHz]. Input shift parameter chosen to fit numerical solutions."/>
<Constant name="d" domain="lo=0.0, hi=200.0, step=0.01" default="154." description="[ms]. Parameter chosen to fit numerical solutions."/>
<Constant name="gamma" domain="lo=0.0, hi=1.0, step=0.01" default="0.641" description="Kinetic parameter"/>
<Constant name="tau_s" domain="lo=50., hi=150., step=1." default="100." description="Kinetic parameter. NMDA decay time constant."/>
<Constant name="w" domain="lo=0.0, hi=1.0, step=0.01" default="0.6" description="Excitatory recurrence"/>
<Constant name="J_N" domain="lo=0.2609, hi=0.5, step=0.001" default="0.2609" description="Excitatory recurrence"/>
<Constant name="I_o" domain="lo=0.0, hi=1.0, step=0.01" default="0.33" description="[nA] Effective external input"/>
<!-- <Constant name="sigma_noise" symbol="NArray" dimension="lo=0.0, hi=0.005, step=0.0001" value="0.000000001" description="[nA] Noise amplitude. Take this value into account for stochatic-->
<!-- integration schemes."/>-->
<Dynamics>
<!-- "State variable ranges [lo, hi]" values are entered with keyword "default" -->
<!-- For each state variable a set of bondaries can be added to encompass the boundaries of the dynamic range -->
<!-- Leave empty "" for no boundaries. Set None for one-sided boundaries, ie: "1.0, None" -->
<StateVariable name="S" default="0.0, 1.0" boundaries="0.0, 1.0"/>
<!-- Derived variables can be used to 'easify' the time derivatives, enter the local coupling formulas or any formula -->
<!-- sytax: [name]=[expression] -->
<!-- Define for ex. global and local coupling: c_0 = coupling[0, ] and lc_0 = local_coupling -->
<DerivedVariable name="x" expression="w * J_N * S + I_o + J_N * coupling[0] + J_N * local_coupling"/>
<DerivedVariable name="H" expression="(a * x - b) / (1 - exp(-d * (a * x - b)))"/>
<TimeDerivative name="dS" expression="- (S / tau_s) + (1 - S) * H * gamma"/>
</Dynamics>
<!-- Exposures are used for observables, for the name enter variable to be observed (usually states)
and for dimension enter the reduction functionality. Will be represented as variables_of_interest.
Choices and default list with a (,) seperator-->
<Exposure name="S" choices="S" default="S" description="default state variables to be monitored"/>
</ComponentType>
</Lems>
\ No newline at end of file
......@@ -4,19 +4,19 @@ Parameter, ComponentType and Component class definitions.
@author: Gautham Ganapathy
@organization: LEMS (http://neuroml.org/lems/, https://github.com/organizations/LEMS)
@contact: gautham@lisphacker.org
MAvdVlag: altered attributes for constants and exposures. Added type 'function for CUDA generation'
"""
from base.base import LEMSBase
from base.map import Map
# from lems.base.errors import ModelError,ParseError
#
from base.errors import ModelError,ParseError
from model.dynamics import Dynamics
from model.structure import Structure
from model.simulation import Simulation
import sys
from parser.expr import ExprParser
# from lems.parser.expr import ExprParser
from tvb.dsl.NeuroML.lems.parser.expr import ExprParser
class Parameter(LEMSBase):
"""
......
......@@ -4,16 +4,16 @@ Behavioral dynamics of component types.
@author: Gautham Ganapathy
@organization: LEMS (http://neuroml.org/lems/, https://github.com/organizations/LEMS)
@contact: gautham@lisphacker.org
MAvdVlag: altered attributes for state_variables, derived_variables, time_derivatives and
conditional_derived_variable.
"""
from base.base import LEMSBase
from base.map import Map
from base.errors import ModelError,ParseError
import sys
# sys.path.insert(0, '/home/michiel/Documents/TVB/dsl_datafitting/lems/parser')
from parser.expr import ExprParser
# from lems.parser.expr import ExprParser
from tvb.dsl.NeuroML.lems.parser.expr import ExprParser
class StateVariable(LEMSBase):
"""
......
......@@ -8,21 +8,18 @@ Model storage.
import os
from os.path import dirname
import sys
from base.base import LEMSBase
from base.map import Map
# from lems.parser.LEMS import LEMSFileParser
# sys.path.insert(0, '/home/michiel/Documents/TVB/dsl_datafitting/lems/')
from parser.LEMS import LEMSFileParser
from tvb.dsl.NeuroML.lems.parser.LEMS import LEMSFileParser
from tvb.dsl.NeuroML.lems.parser.LEMS import LEMSFileParser
from base.util import merge_maps, merge_lists
from model.component import Constant,ComponentType,Component,FatComponent
from base.errors import ModelError
from base.errors import SimBuildError
from model.fundamental import Dimension,Unit,Include
# from lems.model.component import Constant,ComponentType,Component,FatComponent
from model.component import Constant,ComponentType,Component,FatComponent
from model.simulation import Run,Record,EventRecord,DataDisplay,DataWriter,EventWriter
from model.structure import With,EventConnection,ChildInstance,MultiInstantiate
......@@ -212,55 +209,55 @@ class Model(LEMSBase):
else:
raise ModelError('Unsupported child element')
# def add_include_directory(self, path):
# """
# Adds a directory to the include file search path.
#
# @param path: Directory to be added.
# @type path: str
# """
#
# self.include_directories.append(path)
# def include_file(self, path, include_dirs = []):
# """
# Includes a file into the current model.
#
# @param path: Path to the file to be included.
# @type path: str
#
# @param include_dirs: Optional alternate include search path.
# @type include_dirs: list(str)
# """
# if self.include_includes:
# if self.debug: print("------------------ Including a file: %s"%path)
# inc_dirs = include_dirs if include_dirs else self.include_dirs
#
# parser = LEMSFileParser(self, inc_dirs, self.include_includes)
# if os.access(path, os.F_OK):
# if not path in self.included_files:
# parser.parse(open(path).read())
# self.included_files.append(path)
# return
# else:
# if self.debug: print("Already included: %s"%path)
# return
# else:
# for inc_dir in inc_dirs:
# new_path = (inc_dir + '/' + path)
# if os.access(new_path, os.F_OK):
# if not new_path in self.included_files:
# parser.parse(open(new_path).read())
# self.included_files.append(new_path)
# return
# else:
# if self.debug: print("Already included: %s"%path)
# return
# msg = 'Unable to open ' + path
# if self.fail_on_missing_includes:
# raise Exception(msg)
# elif self.debug:
# print(msg)
def add_include_directory(self, path):
"""