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

Document how to record population averages in a memory efficient way #1504

Merged
merged 3 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
24 changes: 24 additions & 0 deletions docs_sphinx/user/recording.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 `Synapses` class' :ref:`summed variable syntax
<summed_variables>`::

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=True)
2 changes: 2 additions & 0 deletions docs_sphinx/user/synapses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading