Skip to content

Commit

Permalink
On --debug install a hook for NGV to show neuro-glial "spikes" (#137)
Browse files Browse the repository at this point in the history
## Context
We want to improve the ability to debug NGV simulations.

## Scope
In the process of debugging, installing a hook to display "spikes" to
astrocytes was a game changer.
We add that to neurodamus, and activate it on `--debug`

## Testing
We get output like 
```
[gid=32589] Got Ustate netcon event. Spiking via v-gid: 41910603
[gid= 1881] Got Ustate netcon event. Spiking via v-gid:  2426894
```
during simulation time, which clearly show which target cells generate
signals to astrocytes over which virtual gid.

## Review
* [x] PR description is complete
* [x] Coding style (imports, function length, New functions, classes or
files) are good
* [NA] Unit/Scientific test added
* [NA] Updated Readme, in-code, developer documentation
  • Loading branch information
ferdonline authored Mar 6, 2024
1 parent 12634ef commit d08d5dc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion neurodamus/ngv.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from .connection_manager import ConnectionManagerBase
from .core import EngineBase
from .core import NeurodamusCore as Nd, MPI
from .core.configuration import GlobalConfig
from .core.configuration import GlobalConfig, LogLevel
from .io.sonata_config import ConnectionTypes
from .io.synapse_reader import SynapseParameters, SonataReader
from .utils import bin_search
Expand Down Expand Up @@ -395,6 +395,9 @@ def _create_synapse_ustate_endpoints(self, base_manager):
syn_gid_base = 1_000_000 # Below 1M is reserved for cell ids
total_created = 0

def ustate_event_handler(tgid, syn_gid):
return lambda: print(f"[gid={tgid}] Ustate netcon event. Spiking via v-gid:", syn_gid)

for conn in base_manager.all_connections():
syn_objs = conn.synapses
tgid_syn_offset = syn_gid_base + conn.synapses_offset
Expand All @@ -406,6 +409,9 @@ def _create_synapse_ustate_endpoints(self, base_manager):
pc.set_gid2node(synapse_gid, MPI.rank)
netcon = Nd.NetCon(syn_objs[param_i]._ref_Ustate, None, 0, 0, 1.1, sec=sec)
pc.cell(synapse_gid, netcon)
if GlobalConfig.verbosity >= LogLevel.DEBUG:
netcon.record(ustate_event_handler(conn.tgid, synapse_gid))

conn._netcons.append(netcon)
total_created += 1

Expand Down

0 comments on commit d08d5dc

Please sign in to comment.