This patch might not be as useful as I thought. Here's the basic outline of what I was attempting:
1. Create neuron geometry (without extracellular fields, iclamps, or synapses)
2. Run the simulation to a steady state
3. Save the state in memory
4. Destroy the neuron geometry
5. Create neuron geometry (without extracellular fields, iclamps, or synapses)
6. Restore the state saved in step 3
7. Add the synapses, extracellular fields, or iclamps (depending on the simulation)
8. Run the simulation and save results
9. destroy the neuron geometry
10. go to step 5 unless finished.
Neuron would complain at step 6 (the restore step) because the original sections didn't exist and the restore wasn't from a file. I thought this was a silly requirement given the later checks on each section. Unfortunately perhaps it wasn't so silly. The above works for extracellular fields and iclamps, but I can't get it to work for ExpSyn. If I do it as above the synapse never fires (because the vecplay never delivers the NetCon event). If I set it up before the save and again (the same way) before the restore I get a core dump.
Code: Select all
(gdb) bt
#0 0x00007f5f6b4a18d1 in element () from x86_64/.libs/libnrnmech.so
#1 0x00007f5f6b4a17d6 in _net_receive () from x86_64/.libs/libnrnmech.so
#2 0x00007f5f6e34edcb in SelfEvent::call_net_receive(NetCvode*) () from /home/jedlund/GitReps/ComsolSpine/ComsolSpineVirtEnv/x86_64/lib/libnrniv.so.0
#3 0x00007f5f6e34ed28 in SelfEvent::deliver(double, NetCvode*, NrnThread*) () from /home/jedlund/GitReps/ComsolSpine/ComsolSpineVirtEnv/x86_64/lib/libnrniv.so.0
#4 0x00007f5f6e34ad1f in NetCvode::deliver_event(double, NrnThread*) () from /home/jedlund/GitReps/ComsolSpine/ComsolSpineVirtEnv/x86_64/lib/libnrniv.so.0
I'm going to have to figure out a better way to do this. This there any way to setup a synapse (using vecplay on a NetCon object) in the middle of a simulation? I know that vector play needs to be setup before neuron.h.finitialize(self.v_init). Is there a way around that?
The code is about 400 lines long (with tests) (I can post it or email it if desired). Below is just the section where I setup the synapse. Note that there is only a single passive section in the test model.
Code: Select all
def SetupSynapse(self, syn_weight, syn_x, syn_time_ms):
print "SetupSynapse"
self.synInfo = {}
if syn_weight is not None and syn_x is not None and syn_time_ms is not None:
secIndex = 0
synTime_ms = self.init_ms + syn_time_ms
# Now we know secIndex and segx.
synObj = neuron.h.ExpSyn(self.allSections[secIndex](syn_x))
synObj.e = 100
synObj.tau = 1
self.synInfo['synObj'] = synObj
self.synInfo['vecStim'] = neuron.h.VecStim() # Requires the vecevent.mod file compiled and loaded.
self.synInfo['spikeTimeVec'] = neuron.h.Vector([synTime_ms])
self.synInfo['vecStim'].play(self.synInfo['spikeTimeVec'])
threshold = 10 # The default
delay = 0 # Instead of 1ms.
weight = 0 # The default
self.synInfo['netCon'] = neuron.h.NetCon(self.synInfo['vecStim'], self.synInfo["synObj"], threshold, delay, weight, sec=self.allSections[secIndex])
self.synInfo['netCon'].weight[0] = syn_weight
pass
pass
Thanks.