Page 1 of 1

Saving the integration of Neuron at certain time

Posted: Wed Nov 23, 2011 12:27 pm
by mattions
Hello everyone.

Is it possible to save the status of the integration, or to get the integrator to go back in time and restart from a certain time?
What I would like to do is to advance neuron till a certain time (let's say t=4) and then have the possibility to go back to t=3 and restart again from there.
I'm trying to set up two different objects to do that, but no joy so far.

Consider this code:

Code: Select all

from neuron import h
h.load_file("stdrun.hoc")
h.finitialize()
h_status_at_time = {}
while h.t < h.tStop:
    h.fadvance()
    h_tmp_t = h.save_status(h.t) # Does this method exist?
    h_status_at_time[h.t] = h_tmp_t

# Restart the simulation from my_time
h_from_my_time = h_status_at_time[my_time]

while h_from_my_time.t < h_from_my_time.tStop:
    h.fadvance()
Is there a way to do that? I've tried copying the h object but It seems it doesn't work.

Code: Select all

from neuron import h
from copy import deepcopy
h2 = deepcopy(h)

h.load_file("stdrun.hoc")
h2.load_file("stdrun.hoc")

print h == h2 # print False

print h.tStop # print 5
print h2.tStop # print 5

h2.tStop = 6
print h2.tStop # print 6

#but
print h.tStop # print 6 as well!!
The object are different, but changing one does change also the copy. Do you have any hints how to do this?

Thanks.

Re: Saving the integration of Neuron at certain time

Posted: Wed Nov 23, 2011 2:12 pm
by ted
See documentation of the SaveState class in the Programmer's Reference. Examples of custom initialization that use SaveState are provided in chapter 8 of The NEURON Book. For another example of how to use SaveState see
viewtopic.php?f=8&t=2048

Re: Saving the integration of Neuron at certain time

Posted: Thu Nov 24, 2011 11:05 am
by mattions
Hi Ted,

it does exactly what I need.
Thank you a lot!

Pretty powerful method :)