Create a LeakyIntegrate and Fire


Create a Leaky Integrate and Fire Component Neuron using libSpinemL


In [1]:
import sys
import libSpineML
from libSpineML import component as com

In [ ]:
from libSpineML.

In [3]:
# Create a new neuron body
c = com.ComponentClassType('LeakyIAF','neuronbody')
# Add neuron parameters
c.add_Parameter(com.ParameterType('C','nS'))
c.add_Parameter(com.ParameterType('C','nS'))
c.add_Parameter(com.ParameterType('Vt','mV'))
c.add_Parameter(com.ParameterType('Er','mV'))
c.add_Parameter(com.ParameterType('Vr','mV'))
c.add_Parameter(com.ParameterType('R','MOhm'))

print c


<libSpineML.component.ComponentClassType object at 0x7fea8edf5b10>

In [4]:
# Specify Neuron Dynamics
td = com.TimeDerivativeType('V', '((I_Syn) / C) + (Vr - V) / (R*C)')

sa = com.StateAssignmentType('V','Vr')
tr = com.TriggerType('V > Vt')
eo = com.EventOutType('spike')

# Create the On Condition
con = com.OnConditionType('integrating',[sa],[eo],None,tr)

# Create Dynamics
reg = com.RegimeType('integrating',[td],[con])

dyn = com.DynamicsType('integrating',[reg])
dyn.add_StateVariable(com.StateVariableType('V','mV'))
c.set_Dynamics(dyn)

In [5]:
# Add Ports
c.add_Port(com.EventSendPortType('spike'))
c.add_Port(com.AnalogReducePortType('I_syn','+','mA'))

In [6]:
# Finalise and Export
LeakyIAF = com.SpineMLType(c)
LeakyIAF.export(sys.stdout,0,namespacedef_='')


<NML:SpineMLType>
    <NML:ComponentClass xmlns:NML="http://www.shef.ac.uk/SpineMLComponentLayer" name="LeakyIAF" type="neuronbody">
        <NML:Dynamics xmlns:NML="http://www.shef.ac.uk/SpineMLComponentLayer" initial_regime="integrating">
            <NML:Regime xmlns:NML="http://www.shef.ac.uk/SpineMLComponentLayer" name="integrating">
                <NML:TimeDerivative xmlns:NML="http://www.shef.ac.uk/SpineMLComponentLayer" variable="V">
                    <NML:MathInline>((I_Syn) / C) + (Vr - V) / (R*C)</NML:MathInline>
                </NML:TimeDerivative>
                <NML:OnCondition xmlns:NML="http://www.shef.ac.uk/SpineMLComponentLayer" target_regime="integrating">
                    <NML:StateAssignment xmlns:NML="http://www.shef.ac.uk/SpineMLComponentLayer" variable="V">
                        <NML:MathInline>Vr</NML:MathInline>
                    </NML:StateAssignment>
                    <NML:EventOut xmlns:NML="http://www.shef.ac.uk/SpineMLComponentLayer" port="spike"/>
                    <NML:Trigger xmlns:NML="http://www.shef.ac.uk/SpineMLComponentLayer">
                        <NML:MathInline>V &gt; Vt</NML:MathInline>
                    </NML:Trigger>
                </NML:OnCondition>
            </NML:Regime>
            <NML:StateVariable xmlns:NML="http://www.shef.ac.uk/SpineMLComponentLayer" name="V" dimension="mV"/>
        </NML:Dynamics>
        <NML:Port xmlns:NML="http://www.shef.ac.uk/SpineMLComponentLayer" name="spike"/>
        <NML:Port xmlns:NML="http://www.shef.ac.uk/SpineMLComponentLayer" name="I_syn" reduce_op="+" dimension="mA"/>
        <NML:Parameter xmlns:NML="http://www.shef.ac.uk/SpineMLComponentLayer" name="C" dimension="nS"/>
        <NML:Parameter xmlns:NML="http://www.shef.ac.uk/SpineMLComponentLayer" name="C" dimension="nS"/>
        <NML:Parameter xmlns:NML="http://www.shef.ac.uk/SpineMLComponentLayer" name="Vt" dimension="mV"/>
        <NML:Parameter xmlns:NML="http://www.shef.ac.uk/SpineMLComponentLayer" name="Er" dimension="mV"/>
        <NML:Parameter xmlns:NML="http://www.shef.ac.uk/SpineMLComponentLayer" name="Vr" dimension="mV"/>
        <NML:Parameter xmlns:NML="http://www.shef.ac.uk/SpineMLComponentLayer" name="R" dimension="MOhm"/>
    </NML:ComponentClass>
</NML:SpineMLType>

In [ ]: