Exemple #1
0
 def test_liaf(self,
               plot=PLOT_DEFAULT,
               print_comparisons=False,
               simulators=SIMULATORS_TO_TEST,
               dt=0.001,
               duration=100.0,
               build_mode=BUILD_MODE_DEFAULT,
               **kwargs):  # @UnusedVariable
     # Perform comparison in subprocess
     comparer = Comparer(
         nineml_model=ninemlcatalog.load('neuron/LeakyIntegrateAndFire',
                                         'PyNNLeakyIntegrateAndFire'),
         state_variable='v',
         dt=dt,
         simulators=simulators,
         properties=ninemlcatalog.load(
             'neuron/LeakyIntegrateAndFire',
             'PyNNLeakyIntegrateAndFireProperties'),
         initial_states=self.liaf_initial_states,
         initial_regime='subthreshold',
         neuron_ref='ResetRefrac',
         nest_ref='iaf_psc_alpha',
         input_signal=input_step('i_synaptic', 1, 50, 100, dt, 20),
         nest_translations=self.liaf_nest_translations,
         neuron_translations=self.liaf_neuron_translations,
         neuron_build_args={'build_mode': build_mode},
         nest_build_args={'build_mode': build_mode},
         # auxiliary_states=['end_refractory'],
         extra_mechanisms=['pas'])
     comparer.simulate(duration * un.ms,
                       nest_rng_seed=NEST_RNG_SEED,
                       neuron_rng_seed=NEURON_RNG_SEED)
     comparisons = comparer.compare()
     if print_comparisons:
         for (name1, name2), diff in comparisons.items():
             print('{} v {}: {}'.format(name1, name2, diff))
     if plot:
         comparer.plot()
     if 'neuron' in simulators:
         self.assertLess(
             comparisons[('9ML-neuron', 'Ref-neuron')], 0.55 * pq.mV,
             "LIaF NEURON 9ML simulation did not match reference PyNN "
             "within {} ({})".format(
                 0.55 * pq.mV, comparisons[('9ML-neuron', 'Ref-neuron')]))
     if 'nest' in simulators:
         self.assertLess(
             comparisons[('9ML-nest', 'Ref-nest')], 0.01 * pq.mV,
             "LIaF NEST 9ML simulation did not match reference built-in "
             "within {} ({})".format(0.01 * pq.mV,
                                     comparisons[('9ML-nest', 'Ref-nest')]))
     if 'nest' in simulators and 'neuron' in simulators:
         self.assertLess(
             comparisons[('9ML-nest', '9ML-neuron')], 0.55 * pq.mV,
             "LIaF NEURON 9ML simulation did not match NEST 9ML simulation "
             "within {} ({})".format(
                 0.55 * pq.mV, comparisons[('9ML-nest', '9ML-neuron')]))
Exemple #2
0
 def test_izhiFS(self, plot=False, print_comparisons=False,
                 simulators=['nest', 'neuron'], dt=0.001, duration=100.0,
                 build_mode='force', **kwargs):  # @UnusedVariable
     # Force compilation of code generation
     # Perform comparison in subprocess
     comparer = Comparer(
         nineml_model=ninemlcatalog.load(
             'neuron/Izhikevich', 'IzhikevichFastSpiking'),
         state_variable='V', dt=dt, simulators=simulators,
         properties=ninemlcatalog.load(
             'neuron/Izhikevich', 'SampleIzhikevichFastSpiking'),
         initial_states={'U': -1.625 * pq.pA, 'V': -65.0 * pq.mV},
         input_signal=input_step('iSyn', 100 * pq.pA, 25.0, 100, dt),
         initial_regime='subVb',
         neuron_build_args={'build_mode': build_mode,
                            'external_currents': ['iSyn']},
         nest_build_args={'build_mode': build_mode}) #, auxiliary_states=['U']) # @IgnorePep8
     comparer.simulate(duration, nest_rng_seed=NEST_RNG_SEED,
                       neuron_rng_seed=NEURON_RNG_SEED)
     comparisons = comparer.compare()
     if print_comparisons:
         for (name1, name2), diff in comparisons.iteritems():
             print '{} v {}: {}'.format(name1, name2, diff)
     if plot:
         comparer.plot()
     if 'nest' in simulators and 'neuron' in simulators:
         self.assertLess(
             comparisons[('9ML-nest', '9ML-neuron')], 0.4 * pq.mV,
             "Izhikevich 2007 NEURON 9ML simulation did not match NEST 9ML")
Exemple #3
0
 def test_izhi(self, plot=PLOT_DEFAULT, print_comparisons=False,
               simulators=SIMULATORS_TO_TEST,
               dt=0.001, duration=100.0,
               build_mode=BUILD_MODE_DEFAULT, **kwargs):  # @UnusedVariable
     # Force compilation of code generation
     # Perform comparison in subprocess
     comparer = Comparer(
         nineml_model=ninemlcatalog.load(
             'neuron/Izhikevich', 'Izhikevich'),
         state_variable='V', dt=dt, simulators=simulators,
         properties=ninemlcatalog.load(
             'neuron/Izhikevich', 'SampleIzhikevich'),
         initial_states={'U': -14.0 * pq.mV / pq.ms, 'V': -65.0 * pq.mV},
         neuron_ref='Izhikevich', nest_ref='izhikevich',
         # auxiliary_states=['U'],
         input_signal=input_step('Isyn', 0.02, 50, 100, dt, 30),
         nest_translations={'V': ('V_m', 1), 'U': ('U_m', 1),
                            'weight': (None, 1), 'C_m': (None, 1),
                            'theta': ('V_th', 1),
                            'alpha': (None, 1), 'beta': (None, 1),
                            'zeta': (None, 1)},
         neuron_translations={'C_m': (None, 1), 'weight': (None, 1),
                              'V': ('v', 1), 'U': ('u', 1),
                              'alpha': (None, 1), 'beta': (None, 1),
                              'zeta': (None, 1), 'theta': ('vthresh', 1)},
         neuron_build_args={'build_mode': build_mode,
                            'build_version': 'TestDyn'},
         nest_build_args={'build_mode': build_mode,
                          'build_version': 'TestDyn'})
     comparer.simulate(duration * un.ms, nest_rng_seed=NEST_RNG_SEED,
                       neuron_rng_seed=NEURON_RNG_SEED)
     comparisons = comparer.compare()
     if print_comparisons:
         for (name1, name2), diff in comparisons.items():
             print('{} v {}: {}'.format(name1, name2, diff))
     if plot:
         comparer.plot()
     if 'nest' in simulators and 'neuron' in simulators:
         self.assertLess(
             comparisons[('9ML-nest', '9ML-neuron')], 0.4 * pq.mV,
             "Izhikevich NEURON 9ML simulation did not match NEST 9ML "
             "within {} ({})".format(
                 0.4 * pq.mV, comparisons[('9ML-nest', '9ML-neuron')]))
     if 'neuron' in simulators:
         self.assertLess(
             comparisons[('9ML-neuron', 'Ref-neuron')], 0.01 * pq.mV,
             "Izhikevich NEURON 9ML simulation did not match reference "
             "PyNN within {} ({})".format(
                 0.01 * pq.mV, comparisons[('9ML-neuron', 'Ref-neuron')]))
     if 'nest' in simulators:
         self.assertLess(
             comparisons[('9ML-nest', 'Ref-nest')], 0.02 * pq.mV,
             "Izhikevich NEST 9ML simulation did not match reference "
             "built-in within {} ({})".format(
                 0.02 * pq.mV, comparisons[('9ML-nest', 'Ref-nest')]))
Exemple #4
0
 def test_izhiFS(self,
                 plot=PLOT_DEFAULT,
                 print_comparisons=False,
                 simulators=SIMULATORS_TO_TEST,
                 dt=0.001,
                 duration=100.0,
                 build_mode=BUILD_MODE_DEFAULT,
                 **kwargs):  # @UnusedVariable @IgnorePep8
     # Force compilation of code generation
     # Perform comparison in subprocess
     comparer = Comparer(
         nineml_model=ninemlcatalog.load('neuron/Izhikevich',
                                         'IzhikevichFastSpiking'),
         state_variable='V',
         dt=dt,
         simulators=simulators,
         properties=ninemlcatalog.load('neuron/Izhikevich',
                                       'SampleIzhikevichFastSpiking'),
         initial_states={
             'U': -1.625 * pq.pA,
             'V': -65.0 * pq.mV
         },
         input_signal=input_step('iSyn', 100 * pq.pA, 25.0, 100, dt, 15),
         initial_regime='subVb',
         neuron_build_args={
             'build_mode': build_mode,
             'build_version': 'TestDyn',
             'external_currents': ['iSyn']
         },
         # auxiliary_states=['U'],
         nest_build_args={
             'build_mode': build_mode,
             'build_version': 'TestDyn'
         })
     comparer.simulate(duration * un.ms,
                       nest_rng_seed=NEST_RNG_SEED,
                       neuron_rng_seed=NEURON_RNG_SEED)
     comparisons = comparer.compare()
     if print_comparisons:
         for (name1, name2), diff in comparisons.items():
             print('{} v {}: {}'.format(name1, name2, diff))
     if plot:
         comparer.plot()
     if 'nest' in simulators and 'neuron' in simulators:
         self.assertLess(
             comparisons[('9ML-nest', '9ML-neuron')], 0.4 * pq.mV,
             "Izhikevich 2007 NEURON 9ML simulation did not match NEST 9ML")
Exemple #5
0
 def test_izhi(self, plot=False, print_comparisons=False,
               simulators=['nest', 'neuron'], dt=0.001, duration=100.0,
               build_mode='force', **kwargs):  # @UnusedVariable
     # Force compilation of code generation
     # Perform comparison in subprocess
     comparer = Comparer(
         nineml_model=ninemlcatalog.load(
             'neuron/Izhikevich', 'Izhikevich'),
         state_variable='V', dt=dt, simulators=simulators,
         properties=ninemlcatalog.load(
             'neuron/Izhikevich', 'SampleIzhikevich'),
         initial_states={'U': -14.0 * pq.mV / pq.ms, 'V': -65.0 * pq.mV},
         neuron_ref='Izhikevich', nest_ref='izhikevich',
         input_signal=input_step('Isyn', 0.02, 50, 100, dt),
         nest_translations={'V': ('V_m', 1), 'U': ('U_m', 1),
                            'weight': (None, 1), 'C_m': (None, 1),
                            'theta': ('V_th', 1),
                            'alpha': (None, 1), 'beta': (None, 1),
                            'zeta': (None, 1)},
         neuron_translations={'C_m': (None, 1), 'weight': (None, 1),
                              'V': ('v', 1), 'U': ('u', 1),
                              'alpha': (None, 1), 'beta': (None, 1),
                              'zeta': (None, 1), 'theta': ('vthresh', 1)},
         neuron_build_args={'build_mode': build_mode},
         nest_build_args={'build_mode': build_mode},
         build_name='Izhikevich9ML')
     comparer.simulate(duration, nest_rng_seed=NEST_RNG_SEED,
                       neuron_rng_seed=NEURON_RNG_SEED)
     comparisons = comparer.compare()
     if print_comparisons:
         for (name1, name2), diff in comparisons.iteritems():
             print '{} v {}: {}'.format(name1, name2, diff)
     if plot:
         comparer.plot()
     if 'nest' in simulators and 'neuron' in simulators:
         self.assertLess(
             comparisons[('9ML-nest', '9ML-neuron')], 0.4 * pq.mV,
             "Izhikevich NEURON 9ML simulation did not match NEST 9ML")
     if 'neuron' in simulators:
         self.assertLess(
             comparisons[('9ML-neuron', 'Ref-neuron')], 0.0015 * pq.mV,
             "Izhikevich NEURON 9ML simulation did not match reference "
             "PyNN")
     if 'nest' in simulators:
         self.assertLess(
             comparisons[('9ML-nest', 'Ref-nest')], 0.02 * pq.mV,
             "Izhikevich NEST 9ML simulation did not match reference "
             "built-in")
Exemple #6
0
 def test_liaf(self, plot=PLOT_DEFAULT, print_comparisons=False,
               simulators=SIMULATORS_TO_TEST, dt=0.001, duration=100.0,
               build_mode=BUILD_MODE_DEFAULT, **kwargs):  # @UnusedVariable
     # Perform comparison in subprocess
     comparer = Comparer(
         nineml_model=ninemlcatalog.load(
             'neuron/LeakyIntegrateAndFire',
             'PyNNLeakyIntegrateAndFire'),
         state_variable='v', dt=dt, simulators=simulators,
         properties=ninemlcatalog.load(
             'neuron/LeakyIntegrateAndFire',
             'PyNNLeakyIntegrateAndFireProperties'),
         initial_states=self.liaf_initial_states,
         initial_regime='subthreshold',
         neuron_ref='ResetRefrac', nest_ref='iaf_psc_alpha',
         input_signal=input_step('i_synaptic', 1, 50, 100, dt, 20),
         nest_translations=self.liaf_nest_translations,
         neuron_translations=self.liaf_neuron_translations,
         neuron_build_args={'build_mode': build_mode},
         nest_build_args={'build_mode': build_mode},
         # auxiliary_states=['end_refractory'],
         extra_mechanisms=['pas'])
     comparer.simulate(duration * un.ms, nest_rng_seed=NEST_RNG_SEED,
                       neuron_rng_seed=NEURON_RNG_SEED)
     comparisons = comparer.compare()
     if print_comparisons:
         for (name1, name2), diff in comparisons.items():
             print('{} v {}: {}'.format(name1, name2, diff))
     if plot:
         comparer.plot()
     if 'neuron' in simulators:
         self.assertLess(
             comparisons[('9ML-neuron', 'Ref-neuron')], 0.55 * pq.mV,
             "LIaF NEURON 9ML simulation did not match reference PyNN "
             "within {} ({})".format(
                 0.55 * pq.mV, comparisons[('9ML-neuron', 'Ref-neuron')]))
     if 'nest' in simulators:
         self.assertLess(
             comparisons[('9ML-nest', 'Ref-nest')], 0.01 * pq.mV,
             "LIaF NEST 9ML simulation did not match reference built-in "
             "within {} ({})".format(
                 0.01 * pq.mV, comparisons[('9ML-nest', 'Ref-nest')]))
     if 'nest' in simulators and 'neuron' in simulators:
         self.assertLess(
             comparisons[('9ML-nest', '9ML-neuron')], 0.55 * pq.mV,
             "LIaF NEURON 9ML simulation did not match NEST 9ML simulation "
             "within {} ({})".format(
                 0.55 * pq.mV, comparisons[('9ML-nest', '9ML-neuron')]))
Exemple #7
0
 def test_alpha_syn(self, plot=False, print_comparisons=False,
                    simulators=['nest', 'neuron'], dt=0.001,
                    duration=100.0, min_delay=5.0, device_delay=5.0,
                    build_mode='force', **kwargs):  # @UnusedVariable
     # Perform comparison in subprocess
     iaf = ninemlcatalog.load(
         'neuron/LeakyIntegrateAndFire', 'PyNNLeakyIntegrateAndFire')
     alpha_psr = ninemlcatalog.load(
         'postsynapticresponse/Alpha', 'PyNNAlpha')
     static = ninemlcatalog.load(
         'plasticity/Static', 'Static')
     iaf_alpha = MultiDynamics(
         name='IafAlpha',
         sub_components={
             'cell': iaf,
             'syn': MultiDynamics(
                 name="IafAlaphSyn",
                 sub_components={'psr': alpha_psr, 'pls': static},
                 port_connections=[
                     ('pls', 'fixed_weight', 'psr', 'q')],
                 port_exposures=[('psr', 'i_synaptic'),
                                 ('psr', 'spike')])},
         port_connections=[
             ('syn', 'i_synaptic__psr', 'cell', 'i_synaptic')],
         port_exposures=[('syn', 'spike__psr', 'spike')])
     iaf_alpha_with_syn = MultiDynamicsWithSynapses(
         'IafAlpha',
         iaf_alpha,
         connection_parameter_sets=[
             ConnectionParameterSet(
                 'spike', [iaf_alpha.parameter('weight__pls__syn')])])
     initial_states = {'a__psr__syn': 0.0 * pq.nA,
                       'b__psr__syn': 0.0 * pq.nA}
     initial_regime = 'subthreshold___sole_____sole'
     liaf_properties = ninemlcatalog.load(
         'neuron/LeakyIntegrateAndFire/',
         'PyNNLeakyIntegrateAndFireProperties')
     alpha_properties = ninemlcatalog.load(
         'postsynapticresponse/Alpha', 'SamplePyNNAlphaProperties')
     nest_tranlsations = {'tau__psr__syn': ('tau_syn_ex', 1),
                          'a__psr__syn': (None, 1),
                          'b__psr__syn': (None, 1),
                          'spike': ('spike', 1000.0)}
     neuron_tranlsations = {'tau__psr__syn': ('psr.tau', 1),
                            'q__psr__syn': ('psr.q', 1),
                            'spike': ('spike', 1),
                            'a__psr__syn': (None, 1),
                            'b__psr__syn': (None, 1)}
     initial_states.update(
         (k + '__cell', v) for k, v in self.liaf_initial_states.iteritems())
     properties = DynamicsProperties(
         name='IafAlphaProperties', definition=iaf_alpha,
         properties=dict(
             (p.name + '__' + suffix, p.quantity)
             for p, suffix in chain(
                 zip(liaf_properties.properties, repeat('cell')),
                 zip(alpha_properties.properties, repeat('psr__syn')),
                 [(Property('weight', 10 * un.nA), 'pls__syn')])))
     properties_with_syn = DynamicsWithSynapsesProperties(
         'IafAlpha_props_with_syn',
         properties,  # @IgnorePep8
         connection_property_sets=[
             ConnectionPropertySet(
                 'spike',
                 [properties.property('weight__pls__syn')])])
     nest_tranlsations.update(
         (k + '__cell', v)
         for k, v in self.liaf_nest_translations.iteritems())
     neuron_tranlsations.update(
         (k + '__cell', v)
         for k, v in self.liaf_neuron_translations.iteritems())
     build_dir = os.path.join(os.path.dirname(iaf.url), '9build')
     comparer = Comparer(
         nineml_model=iaf_alpha_with_syn,
         state_variable='v__cell', dt=dt,
         simulators=simulators,
         properties=properties_with_syn,
         initial_states=initial_states,
         initial_regime=initial_regime,
         neuron_ref='ResetRefrac',
         nest_ref='iaf_psc_alpha',
         input_train=input_freq('spike', 450 * pq.Hz, duration,
                                weight=[Property('weight__pls__syn',
                                                 10 * un.nA)],  # 20.680155243 * un.pA
                                offset=duration / 2.0),
         nest_translations=nest_tranlsations,
         neuron_translations=neuron_tranlsations,
         extra_mechanisms=['pas'],
         extra_point_process='AlphaISyn',
         neuron_build_args={
             'build_mode': build_mode,
             'build_dir': os.path.join(build_dir, 'neuron', 'IaFAlpha')},
         nest_build_args={
             'build_mode': build_mode,
             'build_dir': os.path.join(build_dir, 'nest', 'IaFAlpha')},
         min_delay=min_delay,
         device_delay=device_delay)
     comparer.simulate(duration, nest_rng_seed=NEST_RNG_SEED,
                       neuron_rng_seed=NEURON_RNG_SEED)
     comparisons = comparer.compare()
     if print_comparisons:
         for (name1, name2), diff in comparisons.iteritems():
             print '{} v {}: {}'.format(name1, name2, diff)
     if plot:
         comparer.plot()
     if 'nest' in simulators and 'neuron' in simulators:
         self.assertLess(
             comparisons[('9ML-nest', '9ML-neuron')], 0.015 * pq.mV,
             "LIaF with Alpha syn NEST 9ML simulation did not match NEURON "
             "9ML simulation")
     if 'nest' in simulators:
         self.assertLess(
             comparisons[('9ML-nest', 'Ref-nest')], 0.04 * pq.mV,
             "LIaF with Alpha syn NEST 9ML simulation did not match "
             "reference built-in")
     if 'neuron' in simulators:
         self.assertLess(
             comparisons[('9ML-neuron', 'Ref-neuron')], 0.03 * pq.mV,
             "LIaF with Alpha syn NEURON 9ML simulation did not match "
             "reference PyNN")
Exemple #8
0
 def test_hh(self, plot=False, print_comparisons=False,
             simulators=['nest', 'neuron'], dt=0.001, duration=100.0,
             build_mode='force', **kwargs):  # @UnusedVariable
     # Perform comparison in subprocess
     comparer = Comparer(
         nineml_model=ninemlcatalog.load(
             'neuron/HodgkinHuxley', 'PyNNHodgkinHuxley'),
         state_variable='v', dt=dt, simulators=simulators,
         initial_states={'v': -65.0 * pq.mV, 'm': 0.0, 'h': 1.0, 'n': 0.0},
         properties=ninemlcatalog.load(
             'neuron/HodgkinHuxley', 'PyNNHodgkinHuxleyProperties'),
         neuron_ref='hh_traub', nest_ref='hh_cond_exp_traub',
         input_signal=input_step('iExt', 0.5, 50, 100, dt),
         nest_translations={
             'v': ('V_m', 1), 'm': ('Act_m', 1),
             'h': ('Act_h', 1), 'n': ('Inact_n', 1),
             'eNa': ('E_Na', 1), 'eK': ('E_K', 1), 'C': ('C_m', 1),
             'gLeak': ('g_L', 1), 'eLeak': ('E_L', 1),
             'gbarNa': ('g_Na', 1), 'gbarK': ('g_K', 1),
             'v_rest': ('V_T', 1), 'v_threshold': (None, 1),
             'm_alpha_A': (None, 1), 'm_alpha_V0': (None, 1),
             'm_alpha_K': (None, 1), 'm_beta_A': (None, 1),
             'm_beta_V0': (None, 1), 'm_beta_K': (None, 1),
             'h_alpha_A': (None, 1), 'h_alpha_V0': (None, 1),
             'h_alpha_K': (None, 1), 'h_beta_A': (None, 1),
             'h_beta_V0': (None, 1), 'h_beta_K': (None, 1),
             'n_alpha_A': (None, 1), 'n_alpha_V0': (None, 1),
             'n_alpha_K': (None, 1), 'n_beta_A': (None, 1),
             'n_beta_V0': (None, 1), 'n_beta_K': (None, 1)},
         neuron_translations={
             'eNa': ('ena', 1), 'eK': ('ek', 1), 'C': ('cm', 1),
             'gLeak': ('gl', 1), 'eLeak': ('el', 1),
             'gbarNa': ('gnabar', 1), 'gbarK': ('gkbar', 1),
             'v_rest': ('vT', 1), 'v_threshold': (None, 1),
             'm_alpha_A': (None, 1), 'm_alpha_V0': (None, 1),
             'm_alpha_K': (None, 1), 'm_beta_A': (None, 1),
             'm_beta_V0': (None, 1), 'm_beta_K': (None, 1),
             'h_alpha_A': (None, 1), 'h_alpha_V0': (None, 1),
             'h_alpha_K': (None, 1), 'h_beta_A': (None, 1),
             'h_beta_V0': (None, 1), 'h_beta_K': (None, 1),
             'n_alpha_A': (None, 1), 'n_alpha_V0': (None, 1),
             'n_alpha_K': (None, 1), 'n_beta_A': (None, 1),
             'n_beta_V0': (None, 1), 'n_beta_K': (None, 1)},
         neuron_build_args={'build_mode': build_mode},
         nest_build_args={'build_mode': build_mode})
     comparer.simulate(duration, nest_rng_seed=NEST_RNG_SEED,
                       neuron_rng_seed=NEURON_RNG_SEED)
     comparisons = comparer.compare()
     if print_comparisons:
         for (name1, name2), diff in comparisons.iteritems():
             print '{} v {}: {}'.format(name1, name2, diff)
     if plot:
         comparer.plot()
     # FIXME: Need to work out what is happening with the reference NEURON
     if 'nest' in simulators and 'neuron' in simulators:
         self.assertLess(
             comparisons[('9ML-nest', '9ML-neuron')], 0.5 * pq.mV,
             "HH 9ML NEURON and NEST simulation did not match each other")
     if 'neuron' in simulators:
         self.assertLess(
             comparisons[('9ML-neuron', 'Ref-neuron')], 0.55 * pq.mV,
             "HH 9ML NEURON simulation did not match reference built-in")
     if 'nest' in simulators:
         self.assertLess(
             comparisons[('9ML-nest', 'Ref-nest')], 0.0015 * pq.mV,
             "HH 9ML NEST simulation did not match reference built-in")
Exemple #9
0
 def test_izhi(self,
               plot=PLOT_DEFAULT,
               print_comparisons=False,
               simulators=SIMULATORS_TO_TEST,
               dt=0.001,
               duration=100.0,
               build_mode=BUILD_MODE_DEFAULT,
               **kwargs):  # @UnusedVariable
     # Force compilation of code generation
     # Perform comparison in subprocess
     comparer = Comparer(
         nineml_model=ninemlcatalog.load('neuron/Izhikevich', 'Izhikevich'),
         state_variable='V',
         dt=dt,
         simulators=simulators,
         properties=ninemlcatalog.load('neuron/Izhikevich',
                                       'SampleIzhikevich'),
         initial_states={
             'U': -14.0 * pq.mV / pq.ms,
             'V': -65.0 * pq.mV
         },
         neuron_ref='Izhikevich',
         nest_ref='izhikevich',
         # auxiliary_states=['U'],
         input_signal=input_step('Isyn', 0.02, 50, 100, dt, 30),
         nest_translations={
             'V': ('V_m', 1),
             'U': ('U_m', 1),
             'weight': (None, 1),
             'C_m': (None, 1),
             'theta': ('V_th', 1),
             'alpha': (None, 1),
             'beta': (None, 1),
             'zeta': (None, 1)
         },
         neuron_translations={
             'C_m': (None, 1),
             'weight': (None, 1),
             'V': ('v', 1),
             'U': ('u', 1),
             'alpha': (None, 1),
             'beta': (None, 1),
             'zeta': (None, 1),
             'theta': ('vthresh', 1)
         },
         neuron_build_args={
             'build_mode': build_mode,
             'build_version': 'TestDyn'
         },
         nest_build_args={
             'build_mode': build_mode,
             'build_version': 'TestDyn'
         })
     comparer.simulate(duration * un.ms,
                       nest_rng_seed=NEST_RNG_SEED,
                       neuron_rng_seed=NEURON_RNG_SEED)
     comparisons = comparer.compare()
     if print_comparisons:
         for (name1, name2), diff in comparisons.items():
             print('{} v {}: {}'.format(name1, name2, diff))
     if plot:
         comparer.plot()
     if 'nest' in simulators and 'neuron' in simulators:
         self.assertLess(
             comparisons[('9ML-nest', '9ML-neuron')], 0.4 * pq.mV,
             "Izhikevich NEURON 9ML simulation did not match NEST 9ML "
             "within {} ({})".format(
                 0.4 * pq.mV, comparisons[('9ML-nest', '9ML-neuron')]))
     if 'neuron' in simulators:
         self.assertLess(
             comparisons[('9ML-neuron', 'Ref-neuron')], 0.01 * pq.mV,
             "Izhikevich NEURON 9ML simulation did not match reference "
             "PyNN within {} ({})".format(
                 0.01 * pq.mV, comparisons[('9ML-neuron', 'Ref-neuron')]))
     if 'nest' in simulators:
         self.assertLess(
             comparisons[('9ML-nest', 'Ref-nest')], 0.02 * pq.mV,
             "Izhikevich NEST 9ML simulation did not match reference "
             "built-in within {} ({})".format(
                 0.02 * pq.mV, comparisons[('9ML-nest', 'Ref-nest')]))
Exemple #10
0
 def test_alpha_syn(self,
                    plot=PLOT_DEFAULT,
                    print_comparisons=False,
                    simulators=SIMULATORS_TO_TEST,
                    dt=0.001,
                    duration=100.0,
                    min_delay=5.0,
                    device_delay=5.0,
                    build_mode=BUILD_MODE_DEFAULT,
                    **kwargs):  # @UnusedVariable @IgnorePep8
     # Perform comparison in subprocess
     iaf = ninemlcatalog.load('neuron/LeakyIntegrateAndFire',
                              'PyNNLeakyIntegrateAndFire')
     alpha_psr = ninemlcatalog.load('postsynapticresponse/Alpha',
                                    'PyNNAlpha')
     static = ninemlcatalog.load('plasticity/Static', 'Static')
     iaf_alpha = MultiDynamics(
         name='IafAlpha_sans_synapses',
         sub_components={
             'cell':
             iaf,
             'syn':
             MultiDynamics(name="IafAlaphSyn",
                           sub_components={
                               'psr': alpha_psr,
                               'pls': static
                           },
                           port_connections=[('pls', 'fixed_weight', 'psr',
                                              'q')],
                           port_exposures=[('psr', 'i_synaptic'),
                                           ('psr', 'spike')])
         },
         port_connections=[('syn', 'i_synaptic__psr', 'cell', 'i_synaptic')
                           ],
         port_exposures=[('syn', 'spike__psr', 'spike')])
     iaf_alpha_with_syn = MultiDynamicsWithSynapses(
         'IafAlpha',
         iaf_alpha,
         connection_parameter_sets=[
             ConnectionParameterSet(
                 'spike', [iaf_alpha.parameter('weight__pls__syn')])
         ])
     initial_states = {
         'a__psr__syn': 0.0 * pq.nA,
         'b__psr__syn': 0.0 * pq.nA
     }
     initial_regime = 'subthreshold___sole_____sole'
     liaf_properties = ninemlcatalog.load(
         'neuron/LeakyIntegrateAndFire/',
         'PyNNLeakyIntegrateAndFireProperties')
     alpha_properties = ninemlcatalog.load('postsynapticresponse/Alpha',
                                           'SamplePyNNAlphaProperties')
     nest_tranlsations = {
         'tau__psr__syn': ('tau_syn_ex', 1),
         'a__psr__syn': (None, 1),
         'b__psr__syn': (None, 1),
         'spike': ('spike', 1000.0)
     }
     neuron_tranlsations = {
         'tau__psr__syn': ('psr.tau', 1),
         'q__psr__syn': ('psr.q', 1),
         'spike': ('spike', 1),
         'a__psr__syn': (None, 1),
         'b__psr__syn': (None, 1)
     }
     initial_states.update(
         (k + '__cell', v) for k, v in self.liaf_initial_states.items())
     properties = DynamicsProperties(
         name='IafAlphaProperties',
         definition=iaf_alpha,
         properties=dict(
             (p.name + '__' + suffix, p.quantity) for p, suffix in chain(
                 list(zip(liaf_properties.properties, repeat('cell'))),
                 list(zip(alpha_properties.properties, repeat('psr__syn'))),
                 [(Property('weight', 10 * un.nA), 'pls__syn')])))
     properties_with_syn = DynamicsWithSynapsesProperties(
         'IafAlpha_props_with_syn',
         properties,  # @IgnorePep8
         connection_property_sets=[
             ConnectionPropertySet(
                 'spike', [properties.property('weight__pls__syn')])
         ])
     nest_tranlsations.update(
         (k + '__cell', v) for k, v in self.liaf_nest_translations.items())
     neuron_tranlsations.update(
         (k + '__cell', v)
         for k, v in self.liaf_neuron_translations.items())
     comparer = Comparer(
         nineml_model=iaf_alpha_with_syn,
         state_variable='v__cell',
         dt=dt,
         simulators=simulators,
         properties=properties_with_syn,
         initial_states=initial_states,
         initial_regime=initial_regime,
         neuron_ref='ResetRefrac',
         nest_ref='iaf_psc_alpha',
         input_train=input_freq(
             'spike',
             450 * pq.Hz,
             duration * pq.ms,
             weight=[Property('weight__pls__syn', 10 * un.nA)],
             offset=duration / 2.0),
         nest_translations=nest_tranlsations,
         neuron_translations=neuron_tranlsations,
         extra_mechanisms=['pas'],
         extra_point_process='AlphaISyn',
         neuron_build_args={'build_mode': build_mode},
         nest_build_args={'build_mode': build_mode},
         min_delay=min_delay,
         # auxiliary_states=['end_refractory__cell'],
         device_delay=device_delay)
     comparer.simulate(duration * un.ms,
                       nest_rng_seed=NEST_RNG_SEED,
                       neuron_rng_seed=NEURON_RNG_SEED)
     comparisons = comparer.compare()
     if print_comparisons:
         for (name1, name2), diff in comparisons.items():
             print('{} v {}: {}'.format(name1, name2, diff))
     if plot:
         comparer.plot()
     if 'nest' in simulators and 'neuron' in simulators:
         self.assertLess(
             comparisons[('9ML-nest', '9ML-neuron')], 0.015 * pq.mV,
             "LIaF with Alpha syn NEST 9ML simulation did not match NEURON "
             "9ML simulation within {} ({})".format(
                 0.015 * pq.mV, comparisons[('9ML-nest', '9ML-neuron')]))
     if 'nest' in simulators:
         self.assertLess(
             comparisons[('9ML-nest', 'Ref-nest')], 0.04 * pq.mV,
             "LIaF with Alpha syn NEST 9ML simulation did not match "
             "reference built-in within {} ({})".format(
                 0.04 * pq.mV, comparisons[('9ML-nest', 'Ref-nest')]))
     if 'neuron' in simulators:
         self.assertLess(
             comparisons[('9ML-neuron', 'Ref-neuron')], 0.03 * pq.mV,
             "LIaF with Alpha syn NEURON 9ML simulation did not match "
             "reference PyNN within {} ({})".format(
                 0.03 * pq.mV, comparisons[('9ML-neuron', 'Ref-neuron')]))
Exemple #11
0
 def test_hh(self,
             plot=PLOT_DEFAULT,
             print_comparisons=False,
             simulators=SIMULATORS_TO_TEST,
             dt=0.001,
             duration=100.0,
             build_mode=BUILD_MODE_DEFAULT,
             **kwargs):  # @UnusedVariable
     # Perform comparison in subprocess
     comparer = Comparer(
         nineml_model=ninemlcatalog.load('neuron/HodgkinHuxley',
                                         'PyNNHodgkinHuxley'),
         state_variable='v',
         dt=dt,
         simulators=simulators,
         initial_states={
             'v': -65.0 * pq.mV,
             'm': 0.0,
             'h': 1.0,
             'n': 0.0
         },
         properties=ninemlcatalog.load('neuron/HodgkinHuxley',
                                       'PyNNHodgkinHuxleyProperties'),
         neuron_ref='hh_traub',
         nest_ref='hh_cond_exp_traub',
         input_signal=input_step('iExt', 0.5, 50, 100, dt, 10),
         nest_translations={
             'v': ('V_m', 1),
             'm': ('Act_m', 1),
             'h': ('Act_h', 1),
             'n': ('Inact_n', 1),
             'eNa': ('E_Na', 1),
             'eK': ('E_K', 1),
             'C': ('C_m', 1),
             'gLeak': ('g_L', 1),
             'eLeak': ('E_L', 1),
             'gbarNa': ('g_Na', 1),
             'gbarK': ('g_K', 1),
             'v_rest': ('V_T', 1),
             'v_threshold': (None, 1),
             'm_alpha_A': (None, 1),
             'm_alpha_V0': (None, 1),
             'm_alpha_K': (None, 1),
             'm_beta_A': (None, 1),
             'm_beta_V0': (None, 1),
             'm_beta_K': (None, 1),
             'h_alpha_A': (None, 1),
             'h_alpha_V0': (None, 1),
             'h_alpha_K': (None, 1),
             'h_beta_A': (None, 1),
             'h_beta_V0': (None, 1),
             'h_beta_K': (None, 1),
             'n_alpha_A': (None, 1),
             'n_alpha_V0': (None, 1),
             'n_alpha_K': (None, 1),
             'n_beta_A': (None, 1),
             'n_beta_V0': (None, 1),
             'n_beta_K': (None, 1)
         },
         neuron_translations={
             'eNa': ('ena', 1),
             'eK': ('ek', 1),
             'C': ('cm', 1),
             'gLeak': ('gl', 1),
             'eLeak': ('el', 1),
             'gbarNa': ('gnabar', 1),
             'gbarK': ('gkbar', 1),
             'v_rest': ('vT', 1),
             'v_threshold': (None, 1),
             'm_alpha_A': (None, 1),
             'm_alpha_V0': (None, 1),
             'm_alpha_K': (None, 1),
             'm_beta_A': (None, 1),
             'm_beta_V0': (None, 1),
             'm_beta_K': (None, 1),
             'h_alpha_A': (None, 1),
             'h_alpha_V0': (None, 1),
             'h_alpha_K': (None, 1),
             'h_beta_A': (None, 1),
             'h_beta_V0': (None, 1),
             'h_beta_K': (None, 1),
             'n_alpha_A': (None, 1),
             'n_alpha_V0': (None, 1),
             'n_alpha_K': (None, 1),
             'n_beta_A': (None, 1),
             'n_beta_V0': (None, 1),
             'n_beta_K': (None, 1)
         },
         # auxiliary_states=['m', 'h', 'n'],
         neuron_build_args={'build_mode': build_mode},
         nest_build_args={'build_mode': build_mode})
     comparer.simulate(duration * un.ms,
                       nest_rng_seed=NEST_RNG_SEED,
                       neuron_rng_seed=NEURON_RNG_SEED)
     comparisons = comparer.compare()
     if print_comparisons:
         for (name1, name2), diff in comparisons.items():
             print('{} v {}: {}'.format(name1, name2, diff))
     if plot:
         comparer.plot()
     # FIXME: Need to work out what is happening with the reference NEURON
     if 'nest' in simulators and 'neuron' in simulators:
         self.assertLess(
             comparisons[('9ML-nest', '9ML-neuron')], 0.5 * pq.mV,
             "HH 9ML NEURON and NEST simulation did not match each other "
             "within {} ({})".format(
                 0.5 * pq.mV, comparisons[('9ML-nest', '9ML-neuron')]))
     if 'neuron' in simulators:
         self.assertLess(
             comparisons[('9ML-neuron', 'Ref-neuron')], 0.55 * pq.mV,
             "HH 9ML NEURON simulation did not match reference built-in "
             "within {} ({})".format(
                 0.55 * pq.mV, comparisons[('9ML-neuron', 'Ref-neuron')]))
     if 'nest' in simulators:
         self.assertLess(
             comparisons[('9ML-nest', 'Ref-nest')], 0.0015 * pq.mV,
             "HH 9ML NEST simulation did not match reference built-in "
             "within {} ({})".format(0.0015 * pq.mV,
                                     comparisons[('9ML-nest', 'Ref-nest')]))