From bd5d964b7f8dd566d34bb26faed985f02389a2b3 Mon Sep 17 00:00:00 2001 From: clinssen Date: Tue, 5 Mar 2024 16:52:28 +0100 Subject: [PATCH 1/5] fix raster plot physical units --- pynest/nest/raster_plot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pynest/nest/raster_plot.py b/pynest/nest/raster_plot.py index 811ecfeedd..e97869d2ec 100644 --- a/pynest/nest/raster_plot.py +++ b/pynest/nest/raster_plot.py @@ -268,7 +268,7 @@ def _make_plot(ts, ts1, node_ids, neurons, hist=True, hist_binwidth=5.0, graysca plt.bar(t_bins, heights, width=hist_binwidth, color=color_bar, edgecolor=color_edge) plt.yticks([int(x) for x in numpy.linspace(0.0, int(max(heights) * 1.1) + 5, 4)]) - plt.ylabel("Rate (Hz)") + plt.ylabel("Rate (spks/s)") plt.xlabel(xlabel) plt.xlim(xlim) plt.axes(ax1) From d1d0589a2dda4ae8c34fabd405a411da52990dc6 Mon Sep 17 00:00:00 2001 From: "C.A.P. Linssen" Date: Wed, 6 Mar 2024 07:57:05 -0800 Subject: [PATCH 2/5] fix spike rate physical units --- doc/htmldoc/faqs/qa-precise-spike-times.rst | 2 +- doc/htmldoc/ref_material/glossary.rst | 13 +++++-------- models/mip_generator.cpp | 4 ++-- models/mip_generator.h | 2 +- models/poisson_generator.cpp | 4 ++-- models/poisson_generator_ps.cpp | 2 +- models/poisson_generator_ps.h | 2 +- models/sinusoidal_poisson_generator.cpp | 2 +- models/step_rate_generator.h | 2 +- nestkernel/growth_curve.h | 6 +++--- nestkernel/structural_plasticity_node.h | 2 +- pynest/examples/astrocytes/astrocyte_interaction.py | 2 +- pynest/examples/balancedneuron.py | 8 ++++---- pynest/examples/brunel_alpha_nest.py | 8 ++++---- pynest/examples/brunel_delta_nest.py | 6 +++--- pynest/examples/brunel_exp_multisynapse_nest.py | 8 ++++---- pynest/examples/brunel_siegert_nest.py | 4 ++-- pynest/examples/gap_junctions_inhibitory_network.py | 4 ++-- pynest/examples/gif_pop_psc_exp.py | 12 ++++++------ pynest/examples/gif_population.py | 2 +- pynest/examples/one_neuron_with_noise.py | 6 +++--- pynest/examples/pong/networks.py | 2 +- pynest/examples/urbanczik_synapse_example.py | 2 +- testsuite/pytests/test_jonke_synapse.py | 4 ++-- testsuite/pytests/test_stdp_nn_synapses.py | 4 ++-- testsuite/pytests/test_tsodyks2_synapse.py | 2 +- 26 files changed, 56 insertions(+), 59 deletions(-) diff --git a/doc/htmldoc/faqs/qa-precise-spike-times.rst b/doc/htmldoc/faqs/qa-precise-spike-times.rst index 6a4b0ae641..d01caed9e0 100644 --- a/doc/htmldoc/faqs/qa-precise-spike-times.rst +++ b/doc/htmldoc/faqs/qa-precise-spike-times.rst @@ -140,7 +140,7 @@ Questions and answers about precise neurons 13. Q: **What is the rate at which spikes are missed in a typical large-scale neuronal network simulation of integrate-and-fire model neurons with linear subthreshold dynamics in the balanced state and - a spike rate of around 10 Hz**? + a spike rate of around 10 spks/s**? A: At a typical parameter setting for a simulation with around 10,000 neurons and 15 million synapses, the total rate at which spikes are diff --git a/doc/htmldoc/ref_material/glossary.rst b/doc/htmldoc/ref_material/glossary.rst index e60c782dc3..12ff3381aa 100644 --- a/doc/htmldoc/ref_material/glossary.rst +++ b/doc/htmldoc/ref_material/glossary.rst @@ -41,22 +41,19 @@ Units of measure Nanosiemens (nS). g_L - Leak conductance in Nanosiemens (nS). + Leak conductance in nanosiemens (nS). g_K - Potassium peak conductance in Nanosiemens (nS). + Potassium peak conductance in nanosiemens (nS). g_Na - Sodium peak conductance in Nanosiemens (nS). + Sodium peak conductance in nanosiemens (nS). spike rates - Spikes/second. - - modulation frequencies - Herz (Hz). + The number of spikes that occurred in a certain time interval, usually expressed in terms of spikes per second (spks/s or s^-1). frequency - Frequncy in Hertz (Hz). + Frequency in Hertz (Hz). Note that spike rates are often better expressed in terms of spikes per second (spks/s or s^-1). voltage Millivolts (mV). diff --git a/models/mip_generator.cpp b/models/mip_generator.cpp index 7ff9f6e48d..bf60516e97 100644 --- a/models/mip_generator.cpp +++ b/models/mip_generator.cpp @@ -44,7 +44,7 @@ nest::register_mip_generator( const std::string& name ) * ---------------------------------------------------------------- */ nest::mip_generator::Parameters_::Parameters_() - : rate_( 0.0 ) // Hz + : rate_( 0.0 ) // spks/s , p_copy_( 1.0 ) { } @@ -114,7 +114,7 @@ nest::mip_generator::pre_run_hook() { StimulationDevice::pre_run_hook(); - // rate_ is in Hz, dt in ms, so we have to convert from s to ms + // rate_ is in spks/s, dt in ms, so we have to convert from s to ms poisson_distribution::param_type param( Time::get_resolution().get_ms() * P_.rate_ * 1e-3 ); V_.poisson_dist_.param( param ); } diff --git a/models/mip_generator.h b/models/mip_generator.h index fc85e151a7..ff1eb91ded 100644 --- a/models/mip_generator.h +++ b/models/mip_generator.h @@ -151,7 +151,7 @@ class mip_generator : public StimulationDevice */ struct Parameters_ { - double rate_; //!< process rate in Hz + double rate_; //!< process rate in spks/s double p_copy_; //!< copy probability for each spike in the parent process Parameters_(); //!< Sets default parameter values diff --git a/models/poisson_generator.cpp b/models/poisson_generator.cpp index 82296b00c4..516a886bca 100644 --- a/models/poisson_generator.cpp +++ b/models/poisson_generator.cpp @@ -48,7 +48,7 @@ nest::register_poisson_generator( const std::string& name ) * ---------------------------------------------------------------- */ nest::poisson_generator::Parameters_::Parameters_() - : rate_( 0.0 ) // Hz + : rate_( 0.0 ) // spks/s { } @@ -112,7 +112,7 @@ nest::poisson_generator::pre_run_hook() { StimulationDevice::pre_run_hook(); - // rate_ is in Hz, dt in ms, so we have to convert from s to ms + // rate_ is in spks/s, dt in ms, so we have to convert from s to ms poisson_distribution::param_type param( Time::get_resolution().get_ms() * P_.rate_ * 1e-3 ); V_.poisson_dist_.param( param ); } diff --git a/models/poisson_generator_ps.cpp b/models/poisson_generator_ps.cpp index 8f587de1a3..7a913d15bc 100644 --- a/models/poisson_generator_ps.cpp +++ b/models/poisson_generator_ps.cpp @@ -51,7 +51,7 @@ nest::register_poisson_generator_ps( const std::string& name ) * ---------------------------------------------------------------- */ nest::poisson_generator_ps::Parameters_::Parameters_() - : rate_( 0.0 ) // Hz + : rate_( 0.0 ) // spks/s , dead_time_( 0.0 ) // ms , num_targets_( 0 ) { diff --git a/models/poisson_generator_ps.h b/models/poisson_generator_ps.h index 075c16a23b..4718c4f055 100644 --- a/models/poisson_generator_ps.h +++ b/models/poisson_generator_ps.h @@ -148,7 +148,7 @@ class poisson_generator_ps : public StimulationDevice */ struct Parameters_ { - double rate_; //!< process rate [Hz] + double rate_; //!< process rate [spks/s] double dead_time_; //!< dead time [ms] /** diff --git a/models/sinusoidal_poisson_generator.cpp b/models/sinusoidal_poisson_generator.cpp index 5c8560deaf..6a24cfae5f 100644 --- a/models/sinusoidal_poisson_generator.cpp +++ b/models/sinusoidal_poisson_generator.cpp @@ -281,7 +281,7 @@ nest::sinusoidal_poisson_generator::update( Time const& origin, const long from, kernel().event_delivery_manager.send( *this, se, lag ); } } - // store rate in Hz + // store rate in spks/s B_.logger_.record_data( origin.get_steps() + lag ); } } diff --git a/models/step_rate_generator.h b/models/step_rate_generator.h index c3f3219319..4853c15f7f 100644 --- a/models/step_rate_generator.h +++ b/models/step_rate_generator.h @@ -53,7 +53,7 @@ The ``rate_generator`` provides a piecewise constant rate input to the connected rate unit(s). Please note that this input is handled in the same way as input from any other rate unit, that is, it is processed by the input function of the receiving rate unit. The amplitude of the rate is changed -at the specified times. The unit of the rate is Hz. +at the specified times. The unit of the rate is spks/s. If ``allow_offgrid_times`` is false, times will be rounded to the nearest grid point if they are less than tic/2 from the grid point, otherwise diff --git a/nestkernel/growth_curve.h b/nestkernel/growth_curve.h index 10a350224e..9abb289681 100644 --- a/nestkernel/growth_curve.h +++ b/nestkernel/growth_curve.h @@ -104,7 +104,7 @@ class GrowthCurve * rate that the neuron should achieve. For example, an * eps = 0.05 [Ca2+] with tau_Ca = 10000.0 and beta_Ca = * 0.001 for a synaptic element means a desired firing - * rate of 5Hz. + * rate of 5 spks/s. * * References: * [1] Butz, Markus, Florentin Wörgötter, and Arjen van Ooyen. @@ -184,7 +184,7 @@ class GrowthCurveLinear : public GrowthCurve * firing rate that the neuron should achieve. For * example, an eps = 0.05 [Ca2+] with tau_Ca = 10000.0 * and beta_Ca = 0.001 for a synaptic element means a - * desired firing rate of 5Hz. + * desired firing rate of 5 spks/s. * * nu double - Growth rate in elements/ms. The growth rate nu is * defined in the SynapticElement class. Can be negative. @@ -261,7 +261,7 @@ class GrowthCurveGaussian : public GrowthCurve * firing rate that the neuron should achieve. For * example, an eps = 0.05 [Ca2+] with tau_Ca = 10000.0 * and beta_Ca = 0.001 for a synaptic element means a - * desired firing rate of 5Hz. + * desired firing rate of 5 spks/s. * * nu double - Growth rate in elements/ms. The growth rate nu is * defined in the SynapticElement class. Can be negative. diff --git a/nestkernel/structural_plasticity_node.h b/nestkernel/structural_plasticity_node.h index 55c0847488..ffaf0c9f67 100644 --- a/nestkernel/structural_plasticity_node.h +++ b/nestkernel/structural_plasticity_node.h @@ -130,7 +130,7 @@ class StructuralPlasticityNode : public Node * * Intracellular calcium concentration has a linear factor to mean * electrical activity of 10^2, this means, for example, that a [Ca2+] of - * 0.2 is equivalent to a mean activity of 20 Hz. + * 0.2 is equivalent to a mean activity of 20 spks/s. */ double Ca_minus_; diff --git a/pynest/examples/astrocytes/astrocyte_interaction.py b/pynest/examples/astrocytes/astrocyte_interaction.py index 4be19b1371..dd5963c86c 100644 --- a/pynest/examples/astrocytes/astrocyte_interaction.py +++ b/pynest/examples/astrocytes/astrocyte_interaction.py @@ -134,7 +134,7 @@ axes[1].plot(data_astro["times"], data_astro["IP3"]) axes[2].plot(data_post["times"], data_post["I_SIC"]) axes[3].plot(data_astro["times"], data_astro["Ca_astro"]) -axes[0].set_title(f"Presynaptic neuron\n(Poisson rate = {poisson_rate_neuro} Hz)") +axes[0].set_title(f"Presynaptic neuron\n(Poisson rate = {poisson_rate_neuro} spks/s)") axes[0].set_ylabel("Membrane potential (mV)") axes[2].set_title("Postsynaptic neuron") axes[2].set_ylabel("Slow inward current (pA)") diff --git a/pynest/examples/balancedneuron.py b/pynest/examples/balancedneuron.py index d815a07c06..7d51da5536 100644 --- a/pynest/examples/balancedneuron.py +++ b/pynest/examples/balancedneuron.py @@ -123,13 +123,13 @@ def output_rate(guess): - print("Inhibitory rate estimate: %5.2f Hz" % guess) + print("Inhibitory rate estimate: %5.2f spks/s" % guess) rate = float(abs(n_in * guess)) noise[1].rate = rate spikerecorder.n_events = 0 nest.Simulate(t_sim) out = spikerecorder.n_events * 1000.0 / t_sim - print(" -> Neuron rate: %6.2f Hz (goal: %4.2f Hz)" % (out, r_ex)) + print(" -> Neuron rate: %6.2f spks/s (goal: %4.2f spks/s)" % (out, r_ex)) return out @@ -143,13 +143,13 @@ def output_rate(guess): # During simulation, the ``spike_recorder`` counts the spikes of the target # neuron and the total number is read out at the end of the simulation # period. The return value of ``output_rate()`` is the firing rate of the -# target neuron in Hz. +# target neuron in spks/s. # # Second, the scipy function ``bisect`` is used to determine the optimal # firing rate of the neurons of the inhibitory population. in_rate = bisect(lambda x: output_rate(x) - r_ex, lower, upper, xtol=prec) -print("Optimal rate for the inhibitory population: %.2f Hz" % in_rate) +print("Optimal rate for the inhibitory population: %.2f spks/s" % in_rate) ############################################################################### # The function ``bisect`` takes four arguments: first a function whose diff --git a/pynest/examples/brunel_alpha_nest.py b/pynest/examples/brunel_alpha_nest.py index cae0a6ca1e..5c2217d139 100755 --- a/pynest/examples/brunel_alpha_nest.py +++ b/pynest/examples/brunel_alpha_nest.py @@ -154,7 +154,7 @@ def ComputePSPnorm(tauMem, CMem, tauSyn): # Definition of threshold rate, which is the external rate needed to fix the # membrane potential around its threshold, the external firing rate and the # rate of the poisson generator which is multiplied by the in-degree CE and -# converted to Hz by multiplication by 1000. +# converted to spks/s by multiplication by 1000. nu_th = (theta * CMem) / (J_ex * CE * np.exp(1) * tauMem * tauSyn) nu_ex = eta * nu_th @@ -281,7 +281,7 @@ def ComputePSPnorm(tauMem, CMem, tauSyn): # Calculation of the average firing rate of the excitatory and the inhibitory # neurons by dividing the total number of recorded spikes by the number of # neurons recorded from and the simulation time. The multiplication by 1000.0 -# converts the unit 1/ms to 1/s=Hz. +# converts the unit 1/ms to 1/s. rate_ex = events_ex / simtime * 1000.0 / N_rec rate_in = events_in / simtime * 1000.0 / N_rec @@ -310,8 +310,8 @@ def ComputePSPnorm(tauMem, CMem, tauSyn): print(f"Number of synapses: {num_synapses}") print(f" Excitatory : {num_synapses_ex}") print(f" Inhibitory : {num_synapses_in}") -print(f"Excitatory rate : {rate_ex:.2f} Hz") -print(f"Inhibitory rate : {rate_in:.2f} Hz") +print(f"Excitatory rate : {rate_ex:.2f} spks/s") +print(f"Inhibitory rate : {rate_in:.2f} spks/s") print(f"Building time : {build_time:.2f} s") print(f"Simulation time : {sim_time:.2f} s") diff --git a/pynest/examples/brunel_delta_nest.py b/pynest/examples/brunel_delta_nest.py index 6d8d27bd69..a572aa1486 100755 --- a/pynest/examples/brunel_delta_nest.py +++ b/pynest/examples/brunel_delta_nest.py @@ -233,7 +233,7 @@ # Calculation of the average firing rate of the excitatory and the inhibitory # neurons by dividing the total number of recorded spikes by the number of # neurons recorded from and the simulation time. The multiplication by 1000.0 -# converts the unit 1/ms to 1/s=Hz. +# converts the unit 1/ms to 1/s. rate_ex = events_ex / simtime * 1000.0 / N_rec rate_in = events_in / simtime * 1000.0 / N_rec @@ -262,8 +262,8 @@ print(f"Number of synapses: {num_synapses}") print(f" Excitatory : {num_synapses_ex}") print(f" Inhibitory : {num_synapses_in}") -print(f"Excitatory rate : {rate_ex:.2f} Hz") -print(f"Inhibitory rate : {rate_in:.2f} Hz") +print(f"Excitatory rate : {rate_ex:.2f} spks/s") +print(f"Inhibitory rate : {rate_in:.2f} spks/s") print(f"Building time : {build_time:.2f} s") print(f"Simulation time : {sim_time:.2f} s") diff --git a/pynest/examples/brunel_exp_multisynapse_nest.py b/pynest/examples/brunel_exp_multisynapse_nest.py index bcd5eec8ca..815ca783f5 100644 --- a/pynest/examples/brunel_exp_multisynapse_nest.py +++ b/pynest/examples/brunel_exp_multisynapse_nest.py @@ -130,7 +130,7 @@ # Definition of threshold rate, which is the external rate needed to fix the # membrane potential around its threshold, the external firing rate and the # rate of the poisson generator which is multiplied by the in-degree CE and -# converted to Hz by multiplication by 1000. +# converted to spks/s by multiplication by 1000. nu_th = theta / (J * CE * tauMem) nu_ex = eta * nu_th @@ -265,7 +265,7 @@ # Calculation of the average firing rate of the excitatory and the inhibitory # neurons by dividing the total number of recorded spikes by the number of # neurons recorded from and the simulation time. The multiplication by 1000.0 -# converts the unit 1/ms to 1/s=Hz. +# converts the unit 1/ms to 1/s. rate_ex = events_ex / simtime * 1000.0 / N_rec rate_in = events_in / simtime * 1000.0 / N_rec @@ -294,8 +294,8 @@ print(f"Number of synapses: {num_synapses}") print(f" Excitatory : {num_synapses_ex}") print(f" Inhibitory : {num_synapses_in}") -print(f"Excitatory rate : {rate_ex:.2f} Hz") -print(f"Inhibitory rate : {rate_in:.2f} Hz") +print(f"Excitatory rate : {rate_ex:.2f} spks/s") +print(f"Inhibitory rate : {rate_in:.2f} spks/s") print(f"Building time : {build_time:.2f} s") print(f"Simulation time : {sim_time:.2f} s") diff --git a/pynest/examples/brunel_siegert_nest.py b/pynest/examples/brunel_siegert_nest.py index eb82703fb1..f6f0a22dc4 100644 --- a/pynest/examples/brunel_siegert_nest.py +++ b/pynest/examples/brunel_siegert_nest.py @@ -202,5 +202,5 @@ rates_ex = data["rate"][numpy.where(data["senders"] == siegert_ex.global_id)] rates_in = data["rate"][numpy.where(data["senders"] == siegert_in.global_id)] times = data["times"][numpy.where(data["senders"] == siegert_in.global_id)] -print(f"Excitatory rate : {rates_ex[-1]:.2f} Hz") -print(f"Inhibitory rate : {rates_in[-1]:.2f} Hz") +print(f"Excitatory rate : {rates_ex[-1]:.2f} spks/s") +print(f"Inhibitory rate : {rates_in[-1]:.2f} spks/s") diff --git a/pynest/examples/gap_junctions_inhibitory_network.py b/pynest/examples/gap_junctions_inhibitory_network.py index 18a0d0d9a0..8c68754f31 100644 --- a/pynest/examples/gap_junctions_inhibitory_network.py +++ b/pynest/examples/gap_junctions_inhibitory_network.py @@ -143,11 +143,11 @@ spikes = events["senders"] n_spikes = sr.n_events -hz_rate = (1000.0 * n_spikes / simtime) / n_neuron +spike_rate = (1000.0 * n_spikes / simtime) / n_neuron plt.figure(1) plt.plot(times, spikes, "o") -plt.title(f"Average spike rate (Hz): {hz_rate:.2f}") +plt.title(f"Average spike rate: {spike_rate:.2f} spks/s") plt.xlabel("time (ms)") plt.ylabel("neuron no") plt.show() diff --git a/pynest/examples/gif_pop_psc_exp.py b/pynest/examples/gif_pop_psc_exp.py index 6867ff4206..f1b091bac2 100644 --- a/pynest/examples/gif_pop_psc_exp.py +++ b/pynest/examples/gif_pop_psc_exp.py @@ -226,12 +226,12 @@ plt.figure(1) plt.clf() plt.subplot(2, 1, 1) -plt.plot(t, A_N * 1000) # plot population activities (in Hz) -plt.ylabel(r"$A_N$ [Hz]") +plt.plot(t, A_N * 1000) # plot population activities (in spks/s) +plt.ylabel(r"$A_N$ [spks/s]") plt.title("Population activities (mesoscopic sim.)") plt.subplot(2, 1, 2) plt.plot(t, Abar * 1000) # plot instantaneous population rates (in Hz) -plt.ylabel(r"$\bar A$ [Hz]") +plt.ylabel(r"$\bar A$ [spks/s]") plt.xlabel("time [ms]") ############################################################################### @@ -334,19 +334,19 @@ ############################################################################### # Let's retrieve the data of the spike recorder and plot the activity of the -# excitatory population (in Hz): +# excitatory population (in spks/s): for i in range(len(nest_pops)): data_sr = nest_sr[i].get("events", "times") * dt - t0 bins = np.concatenate((t, np.array([t[-1] + dt_rec]))) A = np.histogram(data_sr, bins=bins)[0] / float(N[i]) / dt_rec - A_N[:, i] = A * 1000 # in Hz + A_N[:, i] = A * 1000 # in spks/s t = np.arange(dt, t_end + dt, dt_rec) plt.figure(2) plt.plot(t, A_N[:, 0]) plt.xlabel("time [ms]") -plt.ylabel("population activity [Hz]") +plt.ylabel("population activity [spks/s]") plt.title("Population activities (microscopic sim.)") ############################################################################### diff --git a/pynest/examples/gif_population.py b/pynest/examples/gif_population.py index 9f73dbccdb..bd005e710a 100644 --- a/pynest/examples/gif_population.py +++ b/pynest/examples/gif_population.py @@ -95,7 +95,7 @@ # GIF neurons population. N_noise = 50 # size of Poisson group -rate_noise = 10.0 # firing rate of Poisson neurons (Hz) +rate_noise = 10.0 # firing rate of Poisson neurons (spks/s) w_noise = 20.0 # synaptic weights from Poisson to population neurons (pA) ############################################################################### diff --git a/pynest/examples/one_neuron_with_noise.py b/pynest/examples/one_neuron_with_noise.py index df2d7f009d..f90ddb07b1 100755 --- a/pynest/examples/one_neuron_with_noise.py +++ b/pynest/examples/one_neuron_with_noise.py @@ -56,9 +56,9 @@ ############################################################################### # Third, the Poisson generator is configured using ``SetStatus``, which expects # a list of node handles and a list of parameter dictionaries. We set the -# Poisson generators to 8,000 Hz and 15,000 Hz, respectively. Note that we do -# not need to set parameters for the neuron and the voltmeter, since they have -# satisfactory defaults. +# Poisson generators to 8,000 spks/s and 15,000 spks/s, respectively. Note that +# we do not need to set parameters for the neuron and the voltmeter, since they +# have satisfactory defaults. noise[0].rate = 80000.0 noise[1].rate = 15000.0 diff --git a/pynest/examples/pong/networks.py b/pynest/examples/pong/networks.py index 4081888d6f..db5aa188b9 100644 --- a/pynest/examples/pong/networks.py +++ b/pynest/examples/pong/networks.py @@ -259,7 +259,7 @@ class PongNetDopa(PongNet): # Synaptic delay for the direct connection between striatum and # dopaminergic neurons d_dir = 200 - # Rate (Hz) for the background poisson generators + # Rate (spks/s) for the background poisson generators poisson_rate = 15 def __init__(self, apply_noise=True, num_neurons=20): diff --git a/pynest/examples/urbanczik_synapse_example.py b/pynest/examples/urbanczik_synapse_example.py index be5ec7f791..8c09e03e2b 100644 --- a/pynest/examples/urbanczik_synapse_example.py +++ b/pynest/examples/urbanczik_synapse_example.py @@ -217,7 +217,7 @@ def h(U, nrn_params): # poisson generators. The recorded spike times are then given to spike # generators. n_pg = 200 # number of poisson generators -p_rate = 10.0 # rate in Hz +p_rate = 10.0 # rate in spks/s pgs = nest.Create("poisson_generator", n=n_pg, params={"rate": p_rate}) diff --git a/testsuite/pytests/test_jonke_synapse.py b/testsuite/pytests/test_jonke_synapse.py index 2b96fc7871..2fc3fd324d 100644 --- a/testsuite/pytests/test_jonke_synapse.py +++ b/testsuite/pytests/test_jonke_synapse.py @@ -38,8 +38,8 @@ class TestJonkeSynapse: """ resolution = 0.1 # [ms] - presynaptic_firing_rate = 20.0 # [Hz] - postsynaptic_firing_rate = 20.0 # [Hz] + presynaptic_firing_rate = 20.0 # [spks/s] + postsynaptic_firing_rate = 20.0 # [spks/s] simulation_duration = 1e4 # [ms] hardcoded_trains_length = 15.0 # [ms] synapse_parameters = { diff --git a/testsuite/pytests/test_stdp_nn_synapses.py b/testsuite/pytests/test_stdp_nn_synapses.py index 8313bf6ac3..317206cc13 100644 --- a/testsuite/pytests/test_stdp_nn_synapses.py +++ b/testsuite/pytests/test_stdp_nn_synapses.py @@ -48,8 +48,8 @@ class TestSTDPNNSynapses: @pytest.fixture(autouse=True) def setUp(self): self.resolution = 0.1 # [ms] - self.presynaptic_firing_rate = 20.0 # [Hz] - self.postsynaptic_firing_rate = 20.0 # [Hz] + self.presynaptic_firing_rate = 20.0 # [spks/s] + self.postsynaptic_firing_rate = 20.0 # [spks/s] self.simulation_duration = 1e4 # [ms] self.synapse_parameters = { "receptor_type": 1, diff --git a/testsuite/pytests/test_tsodyks2_synapse.py b/testsuite/pytests/test_tsodyks2_synapse.py index f5746c7041..fdc8803586 100644 --- a/testsuite/pytests/test_tsodyks2_synapse.py +++ b/testsuite/pytests/test_tsodyks2_synapse.py @@ -35,7 +35,7 @@ class Tsodyks2SynapseTest(unittest.TestCase): def setUp(self): self.resolution = 0.1 # [ms] - self.presynaptic_firing_rate = 20.0 # [Hz] + self.presynaptic_firing_rate = 20.0 # [spks/s] self.simulation_duration = 1e3 # [ms] self.hardcoded_trains_length = 15.0 # [ms] self.synapse_parameters = { From 5b159717642e24d35c66a19a1a370fed06f04460 Mon Sep 17 00:00:00 2001 From: "C.A.P. Linssen" Date: Mon, 9 Sep 2024 10:31:38 +0200 Subject: [PATCH 3/5] change to f-strings --- pynest/examples/balancedneuron.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pynest/examples/balancedneuron.py b/pynest/examples/balancedneuron.py index 7d51da5536..a76cecc587 100644 --- a/pynest/examples/balancedneuron.py +++ b/pynest/examples/balancedneuron.py @@ -123,13 +123,13 @@ def output_rate(guess): - print("Inhibitory rate estimate: %5.2f spks/s" % guess) + print(f"Inhibitory rate estimate: {guess:5.2f} spks/s") rate = float(abs(n_in * guess)) noise[1].rate = rate spikerecorder.n_events = 0 nest.Simulate(t_sim) out = spikerecorder.n_events * 1000.0 / t_sim - print(" -> Neuron rate: %6.2f spks/s (goal: %4.2f spks/s)" % (out, r_ex)) + print(f" -> Neuron rate: {out:6.2f} spks/s (goal: {r_ex:4.2f} spks/s)") return out @@ -149,7 +149,7 @@ def output_rate(guess): # firing rate of the neurons of the inhibitory population. in_rate = bisect(lambda x: output_rate(x) - r_ex, lower, upper, xtol=prec) -print("Optimal rate for the inhibitory population: %.2f spks/s" % in_rate) +print(f"Optimal rate for the inhibitory population: {in_rate:.2f} spks/s") ############################################################################### # The function ``bisect`` takes four arguments: first a function whose From db41c5d549017dc019a273896558f64e3e2bf262 Mon Sep 17 00:00:00 2001 From: "C.A.P. Linssen" Date: Mon, 9 Dec 2024 11:26:55 +0100 Subject: [PATCH 4/5] fix spike rate physical units from Hz to spks/s --- pynest/examples/brunel_delta_nest.py | 2 +- pynest/examples/sudoku/sudoku_net.py | 2 +- testsuite/pytests/test_poisson_generator_campbell_alpha.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pynest/examples/brunel_delta_nest.py b/pynest/examples/brunel_delta_nest.py index a572aa1486..863a15f79a 100755 --- a/pynest/examples/brunel_delta_nest.py +++ b/pynest/examples/brunel_delta_nest.py @@ -106,7 +106,7 @@ # Definition of threshold rate, which is the external rate needed to fix the # membrane potential around its threshold, the external firing rate and the # rate of the poisson generator which is multiplied by the in-degree CE and -# converted to Hz by multiplication by 1000. +# converted to spks/s by multiplication by 1000. nu_th = theta / (J * CE * tauMem) nu_ex = eta * nu_th diff --git a/pynest/examples/sudoku/sudoku_net.py b/pynest/examples/sudoku/sudoku_net.py index b709010fae..06bb28f05e 100644 --- a/pynest/examples/sudoku/sudoku_net.py +++ b/pynest/examples/sudoku/sudoku_net.py @@ -232,6 +232,6 @@ def set_noise_rate(self, rate): Parameters ---------- rate : float - average spike frequency in Hz + average spike rate in spks/s """ self.noise.rate = rate diff --git a/testsuite/pytests/test_poisson_generator_campbell_alpha.py b/testsuite/pytests/test_poisson_generator_campbell_alpha.py index 1c3e427b09..12aca85afa 100644 --- a/testsuite/pytests/test_poisson_generator_campbell_alpha.py +++ b/testsuite/pytests/test_poisson_generator_campbell_alpha.py @@ -46,7 +46,7 @@ def test_poisson_generator_alpha(): tolerance = 0.05 V_m_target = 20.0 J = 0.01 - # solve for rate, convert to Hz, drop C_m as it is 1. + # solve for rate, convert to spks/s, drop C_m as it is 1. rate = 1000.0 * V_m_target / (J * neuron_params["tau_m"] * np.exp(1) * neuron_params["tau_syn_ex"]) poisson = nest.Create("poisson_generator") From fc1e4fdbb3b9faf5e876accaa88688a5dc6efc49 Mon Sep 17 00:00:00 2001 From: clinssen Date: Mon, 9 Dec 2024 14:46:16 +0100 Subject: [PATCH 5/5] fix spike rate physical units Co-authored-by: Hans Ekkehard Plesser --- pynest/examples/one_neuron_with_noise.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pynest/examples/one_neuron_with_noise.py b/pynest/examples/one_neuron_with_noise.py index f90ddb07b1..44e5954611 100755 --- a/pynest/examples/one_neuron_with_noise.py +++ b/pynest/examples/one_neuron_with_noise.py @@ -56,7 +56,7 @@ ############################################################################### # Third, the Poisson generator is configured using ``SetStatus``, which expects # a list of node handles and a list of parameter dictionaries. We set the -# Poisson generators to 8,000 spks/s and 15,000 spks/s, respectively. Note that +# Poisson generators to 80,000 spks/s and 15,000 spks/s, respectively. Note that # we do not need to set parameters for the neuron and the voltmeter, since they # have satisfactory defaults.