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")
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')]))
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')]))
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")
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')]))
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")
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")
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')]))
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')]))