Пример #1
0
"""

"""

from nineml.abstraction_layer import parse, writers, flattening
from nineml.abstraction_layer.testing_utils import (RecordValue,
                                                    TestableComponent,
                                                    std_pynn_simulation)

# Load the Component:
iz_file = '../../../../../../catalog/sample_xml_files/PostTF_izhikevich.xml'
iz = parse(iz_file)

# Write the component back out to XML
writers.XMLWriter.write(iz, 'TestOut_Iz.xml')
writers.DotWriter.write(iz, 'TestOut_Iz.dot')
writers.DotWriter.build('TestOut_Iz.dot')

# Simulate the Neuron:
records = [
    RecordValue(what='V', tag='V', label='V'),
    # RecordValue(what='U', tag='U', label='U'),
    # RecordValue( what='regime',     tag='Regime',  label='Regime' ),
]

parameters = flattening.ComponentFlattener.flatten_namespace_dict({
    'a':
    0.02,
    'b':
    0.2,
    'c':
Пример #2
0
# coba_syn.ports['Isyn'] -> leaky_iaf.ports['Isyn'] for multiple synapses (reduce port)
# Simulator attaches to SpikeInput and SpikeOutput ports for input and output.


# write to file object f if defined

c1 = leaky_iaf
try:
    # This case is used in the test suite for examples.
    c1.write(f)
except NameError:
    import os

    base = "gLIFid1"
    c1.write(base + ".xml")
    c2 = nineml.parse(base + ".xml")
    assert c1 == c2

    c1.to_dot(base + ".dot")
    os.system("dot -Tpng %s -o %s" % (base + ".dot", base + ".png"))


c1 = coba_syn
# write to file object f if defined
try:
    # This case is used in the test suite for examples.
    c1.write(f)
except NameError:
    import os

    base = "exp_cond_id1"
Пример #3
0
import nineml.abstraction_layer as nineml
from brian import *
import brian.stdunits as units
import numpy

# Single Union hh model definition, which is Sequence and Event free.
hh = nineml.parse("hh.xml")


def component_to_native_brian(c):

    assert len(c.regime_map) == 1, "brian supports 1 regime natively"

    # back substitute aliases which need aliases
    hh.backsub_aliases()
    # substitute aliases in equations
    hh.backsub_equations()

    eqns = []
    for e in hh.equations:
        # this fudges brian's unit system
        eqn = '%s = (  %s  )/__time_factor__ : 1.' % (
            e.lhs,
            e.rhs,
        )
        eqns += [eqn]
    return eqns


# have a look at what equations we got
eqns = component_to_native_brian(hh)
Пример #4
0
def get_Izh_FS_component():
    """
    Load Fast spiking Izhikevich XML definition from file and parse into
    Abstraction Layer of Python API.
    """
    return al.parse('NineML_Izh_FS.xml')
Пример #5
0
# leaky_iaf.ports['V'] -> delta_syn.ports['V']
# delta_syn.ports['Isyn'] -> leaky_iaf.ports['Isyn'] for multiple synapses (reduce port)
# Simulator attaches to SpikeInput and SpikeOutput ports for input and output.

# write to file object f if defined

c1 = leaky_iaf
try:
    # This case is used in the test suite for examples.
    c1.write(f)
except NameError:
    import os

    base = "gLIFid1"
    c1.write(base + ".xml")
    c2 = nineml.parse(base + ".xml")
    assert c1 == c2

    c1.to_dot(base + ".dot")
    os.system("dot -Tpng %s -o %s" % (base + ".dot", base + ".png"))

c1 = coba_syn
# write to file object f if defined
try:
    # This case is used in the test suite for examples.
    c1.write(f)
except NameError:
    import os

    base = "exp_cond_id1"
    c1.write(base + ".xml")
Пример #6
0
import nineml.abstraction_layer as nineml
from brian import *
import brian.stdunits as units
import numpy


# Single Union hh model definition, which is Sequence and Event free.
hh = nineml.parse("hh.xml")

def component_to_native_brian(c):

    assert len(c.regime_map)==1, "brian supports 1 regime natively"

    # back substitute aliases which need aliases
    hh.backsub_aliases()
    # substitute aliases in equations
    hh.backsub_equations()

    eqns = []
    for e in hh.equations:
        # this fudges brian's unit system
        eqn = '%s = (  %s  )/__time_factor__ : 1.' % (e.lhs,e.rhs,)
        eqns+=[eqn]
    return eqns
        
# have a look at what equations we got    
eqns = component_to_native_brian(hh)
for e in eqns:
    print e

Пример #7
0
        )]

    analog_ports = [al.RecvPort("V"),
                    al.SendPort("Isyn = g(E-V)")]

    coba_syn = al.ComponentClass("CoBaSynapse", regimes=regimes, analog_ports=analog_ports)

# User layer connects
# leaky_iaf.analog_ports['V'] -> coba_syn.analog_ports['V']
# coba_syn.analog_ports['Isyn'] -> leaky_iaf.analog_ports['Isyn'] for multiple synapses (reduce port)
# Simulator attaches to SpikeInput and SpikeOutput analog_ports for input and output.


# write to file object f if defined

c1 = coba_syn

try:
    # This case is used in the test suite for examples.
    c1.write(f)
except NameError:
    import os

    base = "leaky_iaf_ampa_analog_ports_events"
    c1.write(base + ".xml")
    c2 = al.parse(base + ".xml")
    assert c1 == c2

    c1.to_dot(base + ".dot")
    os.system("dot -Tpng %s -o %s" % (base + ".dot", base + ".png"))
"""

"""

from nineml.abstraction_layer import parse, writers, flattening
from nineml.abstraction_layer.testing_utils import (RecordValue,
                                                    TestableComponent,
                                                    std_pynn_simulation)

# Load the Component:
iz_file = '../../../../../../catalog/sample_xml_files/PostTF_izhikevich.xml'
iz = parse(iz_file)

# Write the component back out to XML
writers.XMLWriter.write(iz, 'TestOut_Iz.xml')
writers.DotWriter.write(iz, 'TestOut_Iz.dot')
writers.DotWriter.build('TestOut_Iz.dot')


# Simulate the Neuron:
records = [
    RecordValue(what='V', tag='V', label='V'),
    # RecordValue(what='U', tag='U', label='U'),
    # RecordValue( what='regime',     tag='Regime',  label='Regime' ),
]

parameters = flattening.ComponentFlattener.flatten_namespace_dict({
                                                                            'a': 0.02,
                                                                            'b': 0.2,
                                                                            'c': -65,
                                                                            'd': 8,
Пример #9
0
def get_Izh_FS_component():
    """
    Load Fast spiking Izhikevich XML definition from file and parse into
    Abstraction Layer of Python API.
    """
    return al.parse('NineML_Izh_FS.xml')