Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix raster plot physical units in label #3136

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/htmldoc/faqs/qa-precise-spike-times.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 5 additions & 8 deletions doc/htmldoc/ref_material/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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).
jessica-mitchell marked this conversation as resolved.
Show resolved Hide resolved

voltage
Millivolts (mV).
Expand Down
4 changes: 2 additions & 2 deletions models/mip_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
}
Expand Down Expand Up @@ -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 );
}
Expand Down
2 changes: 1 addition & 1 deletion models/mip_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions models/poisson_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
}

Expand Down Expand Up @@ -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 );
}
Expand Down
2 changes: 1 addition & 1 deletion models/poisson_generator_ps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down
2 changes: 1 addition & 1 deletion models/poisson_generator_ps.h
Original file line number Diff line number Diff line change
Expand Up @@ -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]

/**
Expand Down
2 changes: 1 addition & 1 deletion models/sinusoidal_poisson_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}
Expand Down
2 changes: 1 addition & 1 deletion models/step_rate_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions nestkernel/growth_curve.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion nestkernel/structural_plasticity_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;

Expand Down
2 changes: 1 addition & 1 deletion pynest/examples/astrocytes/astrocyte_interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down
8 changes: 4 additions & 4 deletions pynest/examples/balancedneuron.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update to use Python format strings here and in other places touched by this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

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


Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions pynest/examples/brunel_alpha_nest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")

Expand Down
6 changes: 3 additions & 3 deletions pynest/examples/brunel_delta_nest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")

Expand Down
8 changes: 4 additions & 4 deletions pynest/examples/brunel_exp_multisynapse_nest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")

Expand Down
4 changes: 2 additions & 2 deletions pynest/examples/brunel_siegert_nest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
4 changes: 2 additions & 2 deletions pynest/examples/gap_junctions_inhibitory_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
12 changes: 6 additions & 6 deletions pynest/examples/gif_pop_psc_exp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]")

###############################################################################
Expand Down Expand Up @@ -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.)")

###############################################################################
Expand Down
2 changes: 1 addition & 1 deletion pynest/examples/gif_population.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

###############################################################################
Expand Down
6 changes: 3 additions & 3 deletions pynest/examples/one_neuron_with_noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pynest/examples/pong/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion pynest/examples/urbanczik_synapse_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down
2 changes: 1 addition & 1 deletion pynest/nest/raster_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be some inconsistency in using () and [] around units. @jessica-mitchell Do we have a policy on this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No we don't; it seems from a quick look into the notation that both parentheses and square brackets are simply style choices - so my opinion is that whatever the majority of cases show that we do that. What do you think @heplesser

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would suggest to tackle this elsewhere/create a separate issue for this.

plt.xlabel(xlabel)
plt.xlim(xlim)
plt.axes(ax1)
Expand Down
4 changes: 2 additions & 2 deletions testsuite/pytests/test_jonke_synapse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Loading
Loading