nmodl
nmodl copied to clipboard
Support (/ Fix) code generation with Artificial cells for NEURON simulator
Overview of the issue
When testing the ringtest model with NMODL as transpiler for NEURON, I see that the spikes are not generated.
Expected result/behavior
Spike results between nmodl and nocmodl transpiler should be the same
Setup
- NEURON Version: master
- NMODL Version: master
- Installation method: typical CMake
cmake .. -DNRN_ENABLE_INTERVIEWS=OFF -DNRN_ENABLE_MPI=OFF -DNRN_ENABLE_RX3D=OFF -DNRN_ENABLE_CORENEURON=ON -DCMAKE_INSTALL_PREFIX=$(pwd)/install
Minimal working example
Model Repisotiry
git clone https://github.com/neuronsimulator/ringtest.git
cd ringtest
I applied below patch so that it's easy to test nocmodl and nmodl:
$ git diff
diff --git a/ring.py b/ring.py
index f2071ff..6301f10 100644
--- a/ring.py
+++ b/ring.py
@@ -102,8 +102,11 @@ class Ring(object):
if not settings.pc.gid_exists(self.gidstart):
return
-
- self.stim = h.NetStim()
+ import os
+ if os.getenv("NETSTIM_NMODL") == '1':
+ self.stim = h.NetStimNMODL()
+ else:
+ self.stim = h.NetStim()
In order to test like the above, I created a copy of netstim.mod:
cp nrn/src/nrnoc/netstim.mod mod/netstim_nmodl.mod
sed -i '' 's/NetStim/NetStimNMODL/g' mod/netstim_nmodl.mod
Build mod files:
<nrn-install>/bin/nrnivmodl -nmodl <nrn-install>/bin/nmodl mod/
Check the spikes between nocmodl and nmodl:
$ ./arm64/special -python ringtest.py
NEURON -- VERSION 9.0a-299-g314d42222+ pramodk/docs-enh (314d42222+) 2024-07-16
...
0.000982046s wrote 688 spikes
vs
$ NETSTIM_NMODL=1 ./arm64/special -python ringtest.py
...
0.000211954s wrote 0 spikes
i.e. 688 spikes ve 0
Preliminary Investigation
Yesterday I was quickly looking through the generated code and I noticed the following. Maybe separate issues for each of these might be better (?):
- [x] RANDOM construct is not handled
- e.g. stream allocation in
nrn_alloc()is missing - [ ] VERBATIM block contents is not printed (not the main cause)
- [x] ARTIFICIAL_CELL should have a call to
artcell_net_send()instead ofnet_send() - [x]
mechname_reg()missing call toadd_nrn_has_net_event(mech_type)
(I might be missing a few other aspects, which I will add here if I see/remember but you can easily see these as stimulus is not working)