Example #1
0
def test_pynn_neuron_std(testable_component):
    t = testable_component

    flg = 'supports_test_pynn_neuron_std'
    assert t.metadata.__dict__.get(flg, False)

    std_pynn_simulation(
        test_component=testable_component(),
        parameters=t.metadata.parameters,
        initial_values=t.metadata.initial_values,
        synapse_components=t.metadata.synapse_components,
        records=t.metadata.records
    )
Example #2
0
    def functest(self):

        cc = ComponentClass(
            name='PulsingCurrentClamp',
            parameters=['i', 'cycle_length'],
            analog_ports=[SendPort('I')],
            regimes=[
                Regime(
                    name='off',
                    transitions=On('t > tchange + cycle_length',
                                   do=['tchange = t', 'I = 0'],
                                   to='on'),
                ),
                Regime(
                    name='on',
                    transitions=On('t > tchange + cycle_length',
                                   do=['tchange = t', 'I = i'],
                                   to='off'),
                ),
            ])

        nrn = ComponentClass(
            name='LeakyNeuron',
            parameters=['Cm', 'gL', 'E'],
            regimes=[
                Regime('dV/dt = (iInj + (E-V)*gL )/Cm'),
            ],
            analog_ports=[SendPort('V'),
                          ReducePort('iInj', reduce_op='+')],
        )

        combined_comp = ComponentClass(name='Comp1',
                                       subnodes={
                                           'nrn': nrn,
                                           'cc1': cc
                                       },
                                       portconnections=[('cc1.I', 'nrn.iInj')])

        records = [
            RecordValue(what='cc1_I', tag='Current', label='Current Clamp 1'),
            RecordValue(what='nrn_V', tag='Voltage', label='Neuron Voltage'),
            RecordValue(what='cc1_tchange', tag='Tchange', label='tChange'),
            RecordValue(what='regime', tag='Regime', label='Regime'),
        ]
        parameters = {
            'cc1_i': 13.8,
            'cc1_cycle_length': 20,
            'nrn_gL': 2,
            'nrn_E': -70
        }

        results = std_pynn_simulation(test_component=combined_comp,
                                      parameters=parameters,
                                      initial_values={},
                                      synapse_components=[],
                                      records=records,
                                      plot=True)
Example #3
0
    def functest(self):

        cc = ComponentClass(
            name='PulsingCurrentClamp',
            parameters=['i', 'cycle_length'],
            analog_ports=[SendPort('I')],
            regimes=[
                Regime(name='off',
                       transitions=On(
                            't > tchange + cycle_length', do=['tchange = t', 'I = 0'], to='on'),

                       ),
                Regime(name='on',
                       transitions=On(
                            't > tchange + cycle_length', do=['tchange = t', 'I = i'], to='off'),
                       ),
            ]

        )

        nrn = ComponentClass(
            name='LeakyNeuron',
            parameters=['Cm', 'gL', 'E'],
            regimes=[Regime('dV/dt = (iInj + (E-V)*gL )/Cm'), ],
            analog_ports=[SendPort('V'),
                          ReducePort('iInj', reduce_op='+')],
        )

        combined_comp = ComponentClass(name='Comp1',
                                       subnodes={'nrn': nrn, 'cc1': cc},
                                       portconnections=[('cc1.I', 'nrn.iInj')])

        from nineml.abstraction_layer.testing_utils import std_pynn_simulation
        from nineml.abstraction_layer.testing_utils import RecordValue

        records = [
            RecordValue(what='cc1_I', tag='Current', label='Current Clamp 1'),
            RecordValue(what='nrn_V', tag='Voltage', label='Neuron Voltage'),
            RecordValue(what='cc1_tchange', tag='Tchange', label='tChange'),
            RecordValue(what='regime',     tag='Regime',  label='Regime'),

        ]
        parameters = {
            'cc1_i': 13.8,
            'cc1_cycle_length': 20,
            'nrn_gL': 2,
            'nrn_E': -70}

        results = std_pynn_simulation(test_component=combined_comp,
                                      parameters=parameters,
                                      initial_values={},
                                      synapse_components=[],
                                      records=records,
                                      plot=True
                                      )
Example #4
0
    def test1(self):

        cc = ComponentClass(
            name='SimpleCurrentClamp',
            parameters=['i'],
            analog_ports=[SendPort('I')],
            aliases='I:=i',
        )

        nrn = ComponentClass(
            name='LeakyNeuron',
            parameters=['Cm', 'gL', 'E'],
            regimes=[
                Regime('dV/dt = (iInj + (E-V)*gL )/Cm'),
            ],
            analog_ports=[SendPort('V'),
                          ReducePort('iInj', reduce_op='+')],
        )

        combined_comp = ComponentClass(name='Comp1',
                                       subnodes={
                                           'nrn': nrn,
                                           'cc1': cc
                                       },
                                       portconnections=[('cc1.I', 'nrn.iInj')])

        records = [
            RecordValue(what='cc1_I', tag='Current', label='Current Clamp 1'),
            RecordValue(what='nrn_V', tag='Voltage', label='Neuron Voltage'),
        ]

        res = std_pynn_simulation(test_component=combined_comp,
                                  parameters={
                                      'cc1_i': 13.8,
                                      'nrn_gL': 2,
                                      'nrn_E': -70
                                  },
                                  initial_values={},
                                  synapse_components=[],
                                  records=records,
                                  plot=False)

        t, records = res

        self.assertAlmostEqual(records['cc1_I'][t > 10].mean(), 13.8)
        self.assertAlmostEqual(records['cc1_I'][t > 10].std(), 0.0)

        self.assertAlmostEqual(records['nrn_V'][t > 10].mean(), -63.1)
        self.assertAlmostEqual(records['nrn_V'][t > 10].std(), 0.0)
Example #5
0
    def test1(self):

        cc = ComponentClass(
            name='SimpleCurrentClamp',
            parameters=['i'],
            analog_ports=[SendPort('I')],
            aliases='I:=i',
        )

        nrn = ComponentClass(
            name='LeakyNeuron',
            parameters=['Cm', 'gL', 'E'],
            regimes=[Regime('dV/dt = (iInj + (E-V)*gL )/Cm'), ],
            analog_ports=[SendPort('V'),
                          ReducePort('iInj', reduce_op='+')],
        )

        combined_comp = ComponentClass(name='Comp1',
                                       subnodes={'nrn': nrn, 'cc1': cc},
                                       portconnections=[('cc1.I', 'nrn.iInj')])

        from nineml.abstraction_layer.testing_utils import std_pynn_simulation
        from nineml.abstraction_layer.testing_utils import RecordValue

        records = [
            RecordValue(what='cc1_I', tag='Current', label='Current Clamp 1'),
            RecordValue(what='nrn_V', tag='Voltage', label='Neuron Voltage'),
        ]

        res = std_pynn_simulation(test_component=combined_comp,
                                  parameters={'cc1_i': 13.8, 'nrn_gL': 2, 'nrn_E': -70},
                                  initial_values={},
                                  synapse_components=[],
                                  records=records,
                                  plot=False
                                  )

        t, records = res

        self.assertAlmostEqual(records['cc1_I'][t > 10].mean(), 13.8)
        self.assertAlmostEqual(records['cc1_I'][t > 10].std(),  0.0)

        self.assertAlmostEqual(records['nrn_V'][t > 10].mean(), -63.1)
        self.assertAlmostEqual(records['nrn_V'][t > 10].std(),  0.0)
Example #6
0
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,
    'iinj_constant':
    50.0,
})

res = std_pynn_simulation(
    test_component=iz,
    parameters=parameters,
    initial_values={},
    synapse_components=[],
    records=records,
)
Example #7
0
    def func_test(self):

        emitter = ComponentClass(
            name='EventEmitter',
            parameters=['cyclelength'],
            regimes=[
                Regime(transitions=On('t > tchange + cyclelength',
                                      do=[OutputEvent('emit'), 'tchange=t'])),
            ])

        ev_based_cc = ComponentClass(
            name='EventBasedCurrentClass',
            parameters=['dur', 'i'],
            analog_ports=[SendPort('I')],
            regimes=[
                Regime(transitions=[
                    On('inputevent', do=['I=i', 'tchange = t']),
                    On('t>tchange + dur', do=['I=0', 'tchange=t'])
                ])
            ])

        pulsing_emitter = ComponentClass(name='pulsing_cc',
                                         subnodes={
                                             'evs': emitter,
                                             'cc': ev_based_cc
                                         },
                                         portconnections=[('evs.emit',
                                                           'cc.inputevent')])

        nrn = ComponentClass(
            name='LeakyNeuron',
            parameters=['Cm', 'gL', 'E'],
            regimes=[
                Regime('dV/dt = (iInj + (E-V)*gL )/Cm'),
            ],
            aliases=['iIn := iInj'],
            analog_ports=[SendPort('V'),
                          ReducePort('iInj', reduce_op='+')],
        )

        combined_comp = ComponentClass(name='Comp1',
                                       subnodes={
                                           'nrn': nrn,
                                           'cc1': pulsing_emitter,
                                           'cc2': pulsing_emitter
                                       },
                                       portconnections=[
                                           ('cc1.cc.I', 'nrn.iInj'),
                                           ('cc2.cc.I', 'nrn.iInj')
                                       ])

        combined_comp = flattening.flatten(combined_comp)

        records = [
            RecordValue(what='cc1_cc_I',
                        tag='Current',
                        label='Current Clamp 1'),
            RecordValue(what='cc2_cc_I',
                        tag='Current',
                        label='Current Clamp 2'),
            RecordValue(what='nrn_iIn',
                        tag='Current',
                        label='Total Input Current'),
            RecordValue(what='nrn_V', tag='Voltage', label='Neuron Voltage'),
            RecordValue(what='cc1_cc_tchange',
                        tag='Tchange',
                        label='tChange CC1'),
            RecordValue(what='cc2_cc_tchange',
                        tag='Tchange',
                        label='tChange CC2'),
            RecordValue(what='regime', tag='Regime', label='Regime'),
        ]

        parameters = flattening.ComponentFlattener.flatten_namespace_dict({
            'cc1.cc.i':
            13.8,
            'cc1.cc.dur':
            10,
            'cc1.evs.cyclelength':
            30,
            'cc2.cc.i':
            20.8,
            'cc2.cc.dur':
            5.0,
            'cc2.evs.cyclelength':
            20,
            'nrn.gL':
            4.3,
            'nrn.E':
            -70
        })

        res = std_pynn_simulation(
            test_component=combined_comp,
            parameters=parameters,
            initial_values={},
            synapse_components=[],
            records=records,
            # plot = False,
        )
        return
        t, records = res

        def check_trace(trace_name, time_period, exp_mean, exp_std=0):
            t_indices = (t > time_period[0] + 1) & (t < time_period[1] - 1)
            self.assertAlmostEqual(records[trace_name][t_indices].mean(),
                                   exp_mean,
                                   places=3)
            self.assertAlmostEqual(records[trace_name][t_indices].std(),
                                   exp_std,
                                   places=3)

        check_trace('cc1_cc_I', (00, 30), exp_mean=0.0)
        check_trace('cc1_cc_I', (30, 40), exp_mean=13.8)
        check_trace('cc1_cc_I', (40, 60), exp_mean=0.0)
        check_trace('cc1_cc_I', (60, 70), exp_mean=13.8)
        check_trace('cc1_cc_I', (70, 90), exp_mean=0.0)
        check_trace('cc1_cc_I', (90, 100), exp_mean=13.8)

        check_trace('cc2_cc_I', (00, 20), exp_mean=0.0)
        check_trace('cc2_cc_I', (20, 25), exp_mean=20.8)
        check_trace('cc2_cc_I', (25, 40), exp_mean=0.0)
        check_trace('cc2_cc_I', (40, 45), exp_mean=20.8)
        check_trace('cc2_cc_I', (45, 60), exp_mean=0.0)
        check_trace('cc2_cc_I', (60, 65), exp_mean=20.8)
        check_trace('cc2_cc_I', (65, 80), exp_mean=0.0)
        check_trace('cc2_cc_I', (80, 85), exp_mean=20.8)
        check_trace('cc2_cc_I', (85, 100), exp_mean=0.0)

        check_trace('nrn_iIn', (00, 20), exp_mean=0.0)
        check_trace('nrn_iIn', (20, 25), exp_mean=20.8)
        check_trace('nrn_iIn', (25, 30), exp_mean=0.0)
        check_trace('nrn_iIn', (30, 40), exp_mean=13.8)
        check_trace('nrn_iIn', (40, 45), exp_mean=20.8)
        check_trace('nrn_iIn', (45, 60), exp_mean=0.0)
        check_trace('nrn_iIn', (60, 65), exp_mean=34.6)
        check_trace('nrn_iIn', (65, 70), exp_mean=13.8)
        check_trace('nrn_iIn', (70, 80), exp_mean=0.0)
        check_trace('nrn_iIn', (80, 85), exp_mean=20.8)
        check_trace('nrn_iIn', (85, 90), exp_mean=0.0)
        check_trace('nrn_iIn', (90, 100), exp_mean=13.8)

        check_trace('nrn_V', (00 + 2, 20), exp_mean=(0.0 / 4.3) - 70)
        check_trace('nrn_V', (20 + 2, 25), exp_mean=(20.8 / 4.3) - 70)
        check_trace('nrn_V', (25 + 2, 30), exp_mean=(0.0 / 4.3) - 70)
        check_trace('nrn_V', (30 + 2, 40), exp_mean=(13.8 / 4.3) - 70)
        check_trace('nrn_V', (40 + 2, 45), exp_mean=(20.8 / 4.3) - 70)
        check_trace('nrn_V', (45 + 2, 60), exp_mean=(0.0 / 4.3) - 70)
        check_trace('nrn_V', (60 + 2, 65), exp_mean=(34.6 / 4.3) - 70)
        check_trace('nrn_V', (65 + 2, 70), exp_mean=(13.8 / 4.3) - 70)
        check_trace('nrn_V', (70 + 2, 80), exp_mean=(0.0 / 4.3) - 70)
        check_trace('nrn_V', (80 + 2, 85), exp_mean=(20.8 / 4.3) - 70)
        check_trace('nrn_V', (85 + 2, 90), exp_mean=(0.0 / 4.3) - 70)
        check_trace('nrn_V', (90 + 2, 100), exp_mean=(13.8 / 4.3) - 70)
Example #8
0
    def func_test(self):

        emitter = ComponentClass(
            name='EventEmitter',
            parameters=['cyclelength'],
            regimes=[
                Regime(
                    transitions=On(
                        't > tchange + cyclelength', do=[OutputEvent('emit'), 'tchange=t'])),
            ])

        ev_based_cc = ComponentClass(
            name='EventBasedCurrentClass',
            parameters=['dur', 'i'],
            analog_ports=[SendPort('I')],
            regimes=[
                Regime(
                    transitions=[
                        On('inputevent', do=['I=i', 'tchange = t']),
                        On('t>tchange + dur', do=['I=0', 'tchange=t'])
                    ]
                )
            ]
        )

        pulsing_emitter = ComponentClass(name='pulsing_cc',
                                         subnodes={'evs': emitter, 'cc': ev_based_cc},
                                         portconnections=[('evs.emit', 'cc.inputevent')]
                                         )

        nrn = ComponentClass(
            name='LeakyNeuron',
            parameters=['Cm', 'gL', 'E'],
            regimes=[Regime('dV/dt = (iInj + (E-V)*gL )/Cm'), ],
            aliases=['iIn := iInj'],
            analog_ports=[SendPort('V'),
                          ReducePort('iInj', reduce_op='+')],
        )

        combined_comp = ComponentClass(name='Comp1',
                                       subnodes={
                                       'nrn': nrn,  'cc1': pulsing_emitter, 'cc2': pulsing_emitter},
                                       portconnections=[('cc1.cc.I', 'nrn.iInj'),
                                                        ('cc2.cc.I', 'nrn.iInj')]
                                       )

        combined_comp = nineml.al.flattening.flatten(combined_comp)

        records = [
            RecordValue(what='cc1_cc_I', tag='Current', label='Current Clamp 1'),
            RecordValue(what='cc2_cc_I', tag='Current', label='Current Clamp 2'),
            RecordValue(what='nrn_iIn', tag='Current', label='Total Input Current'),
            RecordValue(what='nrn_V', tag='Voltage', label='Neuron Voltage'),
            RecordValue(what='cc1_cc_tchange', tag='Tchange', label='tChange CC1'),
            RecordValue(what='cc2_cc_tchange', tag='Tchange', label='tChange CC2'),
            RecordValue(what='regime',     tag='Regime',  label='Regime'),
        ]

        parameters = nineml.al.flattening.ComponentFlattener.flatten_namespace_dict({
                                                                                    'cc1.cc.i': 13.8,
                                                                                    'cc1.cc.dur': 10,
                                                                                    'cc1.evs.cyclelength': 30,

                                                                                    'cc2.cc.i': 20.8,
                                                                                    'cc2.cc.dur': 5.0,
                                                                                    'cc2.evs.cyclelength': 20,

                                                                                    'nrn.gL': 4.3,
                                                                                    'nrn.E': -70})

        res = std_pynn_simulation(test_component=combined_comp,
                                  parameters=parameters,
                                  initial_values={},
                                  synapse_components=[],
                                  records=records,
                                  # plot = False,
                                  )
        return
        t, records = res

        def check_trace(trace_name, time_period, exp_mean, exp_std=0):
            t_indices = (t > time_period[0] + 1) & (t < time_period[1] - 1)
            self.assertAlmostEqual(records[trace_name][t_indices].mean(), exp_mean, places=3)
            self.assertAlmostEqual(records[trace_name][t_indices].std(),  exp_std, places=3)

        check_trace('cc1_cc_I', (00, 30),  exp_mean=0.0)
        check_trace('cc1_cc_I', (30, 40), exp_mean=13.8)
        check_trace('cc1_cc_I', (40, 60), exp_mean=0.0)
        check_trace('cc1_cc_I', (60, 70), exp_mean=13.8)
        check_trace('cc1_cc_I', (70, 90), exp_mean=0.0)
        check_trace('cc1_cc_I', (90, 100), exp_mean=13.8)

        check_trace('cc2_cc_I', (00, 20),  exp_mean=0.0)
        check_trace('cc2_cc_I', (20, 25),  exp_mean=20.8)
        check_trace('cc2_cc_I', (25, 40),  exp_mean=0.0)
        check_trace('cc2_cc_I', (40, 45),  exp_mean=20.8)
        check_trace('cc2_cc_I', (45, 60),  exp_mean=0.0)
        check_trace('cc2_cc_I', (60, 65),  exp_mean=20.8)
        check_trace('cc2_cc_I', (65, 80),  exp_mean=0.0)
        check_trace('cc2_cc_I', (80, 85),  exp_mean=20.8)
        check_trace('cc2_cc_I', (85, 100), exp_mean=0.0)

        check_trace('nrn_iIn', (00, 20),  exp_mean=0.0)
        check_trace('nrn_iIn', (20, 25),  exp_mean=20.8)
        check_trace('nrn_iIn', (25, 30),  exp_mean=0.0)
        check_trace('nrn_iIn', (30, 40),  exp_mean=13.8)
        check_trace('nrn_iIn', (40, 45),  exp_mean=20.8)
        check_trace('nrn_iIn', (45, 60),  exp_mean=0.0)
        check_trace('nrn_iIn', (60, 65),  exp_mean=34.6)
        check_trace('nrn_iIn', (65, 70),  exp_mean=13.8)
        check_trace('nrn_iIn', (70, 80),  exp_mean=0.0)
        check_trace('nrn_iIn', (80, 85),  exp_mean=20.8)
        check_trace('nrn_iIn', (85, 90),  exp_mean=0.0)
        check_trace('nrn_iIn', (90, 100),  exp_mean=13.8)

        check_trace('nrn_V', (00 + 2, 20),  exp_mean=(0.0 / 4.3) - 70)
        check_trace('nrn_V', (20 + 2, 25),  exp_mean=(20.8 / 4.3) - 70)
        check_trace('nrn_V', (25 + 2, 30),  exp_mean=(0.0 / 4.3) - 70)
        check_trace('nrn_V', (30 + 2, 40),  exp_mean=(13.8 / 4.3) - 70)
        check_trace('nrn_V', (40 + 2, 45),  exp_mean=(20.8 / 4.3) - 70)
        check_trace('nrn_V', (45 + 2, 60),  exp_mean=(0.0 / 4.3) - 70)
        check_trace('nrn_V', (60 + 2, 65),  exp_mean=(34.6 / 4.3) - 70)
        check_trace('nrn_V', (65 + 2, 70),  exp_mean=(13.8 / 4.3) - 70)
        check_trace('nrn_V', (70 + 2, 80),  exp_mean=(0.0 / 4.3) - 70)
        check_trace('nrn_V', (80 + 2, 85),  exp_mean=(20.8 / 4.3) - 70)
        check_trace('nrn_V', (85 + 2, 90),  exp_mean=(0.0 / 4.3) - 70)
        check_trace('nrn_V', (90 + 2, 100),  exp_mean=(13.8 / 4.3) - 70)
    'tspike': -1e99,
    'regime': 1002,
        }

synapse_components = [
    ( 'nmda',  'weight' ),
    ( 'cobaExcit', 'q' ),
    ]



records = [
    RecordValue( what='iaf_V',       tag='Voltage [mV]',     label='Membrane Voltage' ),
    RecordValue( what='nmda_g',      tag='Conductance [ns]', label='NMDA-g' ),
    RecordValue( what='cobaExcit_g', tag='Conductance [ns]', label='cobaexcit-g' ),
    RecordValue( what='regime',      tag='Regime',           label='Regime' ),
        ]


std_pynn_simulation( test_component = test_component,
                     parameters = parameters, 
                     initial_values = initial_values, 
                     synapse_components = synapse_components, 
                     records = records
                     )

           



Example #10
0
    def func_test(self):

        emitter = ComponentClass(
            name="EventEmitter",
            parameters=["cyclelength"],
            regimes=[Regime(transitions=On("t > tchange + cyclelength", do=[OutputEvent("emit"), "tchange=t"]))],
        )

        ev_based_cc = ComponentClass(
            name="EventBasedCurrentClass",
            parameters=["dur", "i"],
            analog_ports=[SendPort("I")],
            regimes=[
                Regime(
                    transitions=[
                        On("inputevent", do=["I=i", "tchange = t"]),
                        On("t>tchange + dur", do=["I=0", "tchange=t"]),
                    ]
                )
            ],
        )

        pulsing_emitter = ComponentClass(
            name="pulsing_cc",
            subnodes={"evs": emitter, "cc": ev_based_cc},
            portconnections=[("evs.emit", "cc.inputevent")],
        )

        nrn = ComponentClass(
            name="LeakyNeuron",
            parameters=["Cm", "gL", "E"],
            regimes=[Regime("dV/dt = (iInj + (E-V)*gL )/Cm")],
            aliases=["iIn := iInj"],
            analog_ports=[SendPort("V"), ReducePort("iInj", reduce_op="+")],
        )

        combined_comp = ComponentClass(
            name="Comp1",
            subnodes={"nrn": nrn, "cc1": pulsing_emitter, "cc2": pulsing_emitter},
            portconnections=[("cc1.cc.I", "nrn.iInj"), ("cc2.cc.I", "nrn.iInj")],
        )

        combined_comp = flattening.flatten(combined_comp)

        records = [
            RecordValue(what="cc1_cc_I", tag="Current", label="Current Clamp 1"),
            RecordValue(what="cc2_cc_I", tag="Current", label="Current Clamp 2"),
            RecordValue(what="nrn_iIn", tag="Current", label="Total Input Current"),
            RecordValue(what="nrn_V", tag="Voltage", label="Neuron Voltage"),
            RecordValue(what="cc1_cc_tchange", tag="Tchange", label="tChange CC1"),
            RecordValue(what="cc2_cc_tchange", tag="Tchange", label="tChange CC2"),
            RecordValue(what="regime", tag="Regime", label="Regime"),
        ]

        parameters = flattening.ComponentFlattener.flatten_namespace_dict(
            {
                "cc1.cc.i": 13.8,
                "cc1.cc.dur": 10,
                "cc1.evs.cyclelength": 30,
                "cc2.cc.i": 20.8,
                "cc2.cc.dur": 5.0,
                "cc2.evs.cyclelength": 20,
                "nrn.gL": 4.3,
                "nrn.E": -70,
            }
        )

        res = std_pynn_simulation(
            test_component=combined_comp,
            parameters=parameters,
            initial_values={},
            synapse_components=[],
            records=records,
            # plot = False,
        )
        return
        t, records = res

        def check_trace(trace_name, time_period, exp_mean, exp_std=0):
            t_indices = (t > time_period[0] + 1) & (t < time_period[1] - 1)
            self.assertAlmostEqual(records[trace_name][t_indices].mean(), exp_mean, places=3)
            self.assertAlmostEqual(records[trace_name][t_indices].std(), exp_std, places=3)

        check_trace("cc1_cc_I", (00, 30), exp_mean=0.0)
        check_trace("cc1_cc_I", (30, 40), exp_mean=13.8)
        check_trace("cc1_cc_I", (40, 60), exp_mean=0.0)
        check_trace("cc1_cc_I", (60, 70), exp_mean=13.8)
        check_trace("cc1_cc_I", (70, 90), exp_mean=0.0)
        check_trace("cc1_cc_I", (90, 100), exp_mean=13.8)

        check_trace("cc2_cc_I", (00, 20), exp_mean=0.0)
        check_trace("cc2_cc_I", (20, 25), exp_mean=20.8)
        check_trace("cc2_cc_I", (25, 40), exp_mean=0.0)
        check_trace("cc2_cc_I", (40, 45), exp_mean=20.8)
        check_trace("cc2_cc_I", (45, 60), exp_mean=0.0)
        check_trace("cc2_cc_I", (60, 65), exp_mean=20.8)
        check_trace("cc2_cc_I", (65, 80), exp_mean=0.0)
        check_trace("cc2_cc_I", (80, 85), exp_mean=20.8)
        check_trace("cc2_cc_I", (85, 100), exp_mean=0.0)

        check_trace("nrn_iIn", (00, 20), exp_mean=0.0)
        check_trace("nrn_iIn", (20, 25), exp_mean=20.8)
        check_trace("nrn_iIn", (25, 30), exp_mean=0.0)
        check_trace("nrn_iIn", (30, 40), exp_mean=13.8)
        check_trace("nrn_iIn", (40, 45), exp_mean=20.8)
        check_trace("nrn_iIn", (45, 60), exp_mean=0.0)
        check_trace("nrn_iIn", (60, 65), exp_mean=34.6)
        check_trace("nrn_iIn", (65, 70), exp_mean=13.8)
        check_trace("nrn_iIn", (70, 80), exp_mean=0.0)
        check_trace("nrn_iIn", (80, 85), exp_mean=20.8)
        check_trace("nrn_iIn", (85, 90), exp_mean=0.0)
        check_trace("nrn_iIn", (90, 100), exp_mean=13.8)

        check_trace("nrn_V", (00 + 2, 20), exp_mean=(0.0 / 4.3) - 70)
        check_trace("nrn_V", (20 + 2, 25), exp_mean=(20.8 / 4.3) - 70)
        check_trace("nrn_V", (25 + 2, 30), exp_mean=(0.0 / 4.3) - 70)
        check_trace("nrn_V", (30 + 2, 40), exp_mean=(13.8 / 4.3) - 70)
        check_trace("nrn_V", (40 + 2, 45), exp_mean=(20.8 / 4.3) - 70)
        check_trace("nrn_V", (45 + 2, 60), exp_mean=(0.0 / 4.3) - 70)
        check_trace("nrn_V", (60 + 2, 65), exp_mean=(34.6 / 4.3) - 70)
        check_trace("nrn_V", (65 + 2, 70), exp_mean=(13.8 / 4.3) - 70)
        check_trace("nrn_V", (70 + 2, 80), exp_mean=(0.0 / 4.3) - 70)
        check_trace("nrn_V", (80 + 2, 85), exp_mean=(20.8 / 4.3) - 70)
        check_trace("nrn_V", (85 + 2, 90), exp_mean=(0.0 / 4.3) - 70)
        check_trace("nrn_V", (90 + 2, 100), exp_mean=(13.8 / 4.3) - 70)
iz_file = '../../../../../../catalog/sample_xml_files/PostTF_izhikevich.xml'
iz = nineml.al.parse(iz_file)

# Write the component back out to XML
nineml.al.writers.XMLWriter.write(iz, 'TestOut_Iz.xml')
nineml.al.writers.DotWriter.write(iz, 'TestOut_Iz.dot')
nineml.al.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 = nineml.al.flattening.ComponentFlattener.flatten_namespace_dict({
                                                                            'a': 0.02,
                                                                            'b': 0.2,
                                                                            'c': -65,
                                                                            'd': 8,
                                                                            'iinj_constant': 50.0,
                                                                            })

res = std_pynn_simulation(test_component=iz,
                          parameters=parameters,
                          initial_values={},
                          synapse_components=[],
                          records=records,
                          )
Example #12
0
    'cobaInhib.vrev': -70.0,
}

initial_values = {
    'iaf_V': parameters['iaf.vrest'],
    'tspike': -1e99,
    'regime': 1002,
}

synapse_components = [
    ('cobaInhib', 'q'),
    ('cobaExcit', 'q'),
]

records = [
    RecordValue(what='iaf_V', tag='Voltage [mV]', label='Membrane Voltage'),
    RecordValue(what='cobaInhib_g',
                tag='Conductance [ns]',
                label='cobaInhib-g'),
    RecordValue(what='cobaExcit_g',
                tag='Conductance [ns]',
                label='cobaExcit-g'),
    RecordValue(what='regime', tag='Regime', label='Regime'),
]

std_pynn_simulation(test_component=test_component,
                    parameters=parameters,
                    initial_values=initial_values,
                    synapse_components=synapse_components,
                    records=records)
    RecordValue(what='iaf_V', tag='V', label='V'),
    RecordValue(what='regime', tag='Regime', label='Regime'),
]

parameters = flattening.ComponentFlattener.flatten_namespace_dict({
                                                                            'cobaExcit_tau': 5.0,
                                                                            'cobaExcit_vrev': 0,
                                                                            'iaf_cm': 1,
                                                                            'iaf_gl': 50,
                                                                            'iaf_taurefrac': 8,
                                                                            'iaf_vreset': -60,
                                                                            'iaf_vrest': -60,
                                                                            'iaf_vthresh': -40
                                                                            })

initial_values = {
    'iaf_V': parameters['iaf_vrest'],
    'tspike': -1e99,
    'regime': 1002,
}

res = std_pynn_simulation(test_component=coba1,
                          parameters=parameters,
                          initial_values=initial_values,
                          synapse_components=[('cobaExcit', 'q')],
                          synapse_weights=15.0,
                          records=records,
                          sim_time=250,
                          syn_input_rate=100
                          )
    'cobaExcit_vrev':
    0,
    'iaf_cm':
    1,
    'iaf_gl':
    50,
    'iaf_taurefrac':
    8,
    'iaf_vreset':
    -60,
    'iaf_vrest':
    -60,
    'iaf_vthresh':
    -40
})

initial_values = {
    'iaf_V': parameters['iaf_vrest'],
    'tspike': -1e99,
    'regime': 1002,
}

res = std_pynn_simulation(test_component=coba1,
                          parameters=parameters,
                          initial_values=initial_values,
                          synapse_components=[('cobaExcit', 'q')],
                          synapse_weights=15.0,
                          records=records,
                          sim_time=250,
                          syn_input_rate=100)