From 1152f8d117a80436f1e275f459f4f8ef313ea2a1 Mon Sep 17 00:00:00 2001 From: Paul Brodersen Date: Tue, 13 Feb 2024 11:48:49 +0000 Subject: [PATCH 1/3] Document how to continuously record population averages --- docs_sphinx/user/recording.rst | 24 ++++++++++++++++++++++++ docs_sphinx/user/synapses.rst | 2 ++ 2 files changed, 26 insertions(+) diff --git a/docs_sphinx/user/recording.rst b/docs_sphinx/user/recording.rst index 7190505f6..a4ca1ed4a 100644 --- a/docs_sphinx/user/recording.rst +++ b/docs_sphinx/user/recording.rst @@ -265,3 +265,27 @@ twice, and is therefore slightly less efficient. There's one additional caveat: you'll have to manually include ``and not_refractory`` in your ``events`` definition if your neuron uses refractoriness. This is done automatically for the ``threshold`` condition, but not for any user-defined events. + +Recording population averages +----------------------------- + +Continuous recordings from large groups over long simulation times can +fill up the working memory quickly: recording a single variable from +1000 neurons for 100 seconds at the default time resolution results in +a 1 gigabyte array. While this issue can be ameliorated using the +above approaches, the downstream data analysis is often based on +population averages. These can be recorded efficiently using a dummy +group and the `Synapse` class' :ref:`summed variable syntax +`:: + + group = NeuronGroup(..., 'dv/dt = ... : volt', ...) + + # Dummy group to store the average membrane potential at every time step + vm_container = NeuronGroup(1, 'average_vm : volt') + + # Synapses averaging the membrane potential of all neurons in group + vm_averager = Synapses(group, vm_container, 'average_vm_post = v_pre/N_pre : volt (summed)') + vm_averager.connect() + + # Monitor recording the average membrane potential + vm_monitor = StateMonitor(vm_container, 'average_vm', record=0) diff --git a/docs_sphinx/user/synapses.rst b/docs_sphinx/user/synapses.rst index 207517c1c..139dddeca 100644 --- a/docs_sphinx/user/synapses.rst +++ b/docs_sphinx/user/synapses.rst @@ -439,6 +439,8 @@ incorrect size, i.e. a negative size or a size bigger than the total population size. With ``skip_if_invalid=True``, no error will be raised and a size of 0 or the population size will be used. +.. _summed_variables: + Summed variables ---------------- In many cases, the postsynaptic neuron has a variable that represents a sum of variables over all From 584419b2227d0cd210521e769756140d2ab755d8 Mon Sep 17 00:00:00 2001 From: Paul Brodersen Date: Tue, 13 Feb 2024 12:24:47 +0000 Subject: [PATCH 2/3] Correct documentation of continuously record population averages Set `record=True` to mirror the previous examples. --- docs_sphinx/user/recording.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs_sphinx/user/recording.rst b/docs_sphinx/user/recording.rst index a4ca1ed4a..191936b17 100644 --- a/docs_sphinx/user/recording.rst +++ b/docs_sphinx/user/recording.rst @@ -288,4 +288,4 @@ group and the `Synapse` class' :ref:`summed variable syntax vm_averager.connect() # Monitor recording the average membrane potential - vm_monitor = StateMonitor(vm_container, 'average_vm', record=0) + vm_monitor = StateMonitor(vm_container, 'average_vm', record=True) From b42ee454dc7f750551cfcdd30798757c2d982095 Mon Sep 17 00:00:00 2001 From: Marcel Stimberg Date: Tue, 13 Feb 2024 16:41:02 +0100 Subject: [PATCH 3/3] Fix minor issues in doc for population averages --- docs_sphinx/user/recording.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs_sphinx/user/recording.rst b/docs_sphinx/user/recording.rst index 191936b17..007ec99f1 100644 --- a/docs_sphinx/user/recording.rst +++ b/docs_sphinx/user/recording.rst @@ -272,10 +272,10 @@ Recording population averages Continuous recordings from large groups over long simulation times can fill up the working memory quickly: recording a single variable from 1000 neurons for 100 seconds at the default time resolution results in -a 1 gigabyte array. While this issue can be ameliorated using the +an array of about 8 Gigabytes. While this issue can be ameliorated using the above approaches, the downstream data analysis is often based on population averages. These can be recorded efficiently using a dummy -group and the `Synapse` class' :ref:`summed variable syntax +group and the `Synapses` class' :ref:`summed variable syntax `:: group = NeuronGroup(..., 'dv/dt = ... : volt', ...)