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

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

merged 3 commits into from
Feb 13, 2024

Conversation

paulbrodersen
Copy link
Contributor

Hi, following our discussion here, I added a small section to the documentation that outlines how to continuously record population averages in a memory efficient way (so I can find the information next time I need it).

The section is based on the example given by @mstimberg here.

group = NeuronGroup(..., 'dv/dt = ...', ...)

# 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
vm_averager = Synapses(group, average_vm, 'average_vm_post = v_pre/N_pre : volt (summed)')
vm_averager.connect()
# Monitor recording the average membrane potential
vm_mon = StateMonitor(vm_container, 'average_vm', record=0)

I made the following changes:

  1. I indicated that the units of the variable and the variable average need to match: group = NeuronGroup(..., 'dv/dt = ... : volt', ...)
  2. I corrected a typo: vm_averager = Synapses(group, vm_container, ...)
  3. I set record=True to match the examples in the same section.

Copy link
Member

@mstimberg mstimberg left a comment

Choose a reason for hiding this comment

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

Looks great to me, many thanks for this contribution! I changed a minor detail: if I am not mistaken, the memory usage in your example would be even worse since each value is a double, i.e. takes 8 bytes. So recording 1000 × 100 × 10000 (neurons × duration × timesteps per second) values would take up ~ 8 Gigabytes 😬

@paulbrodersen
Copy link
Contributor Author

Apparently, I hadn't had enough coffee this morning, because I thought a float64 would only need 8 bits not 8 bytes...
Thanks for the correction!

@mstimberg mstimberg merged commit c5b8719 into brian-team:master Feb 13, 2024
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants