Saving the integration of Neuron at certain time

When Python is the interpreter, what is a good
design for the interface to the basic NEURON
concepts.

Moderator: hines

Post Reply
mattions
Posts: 65
Joined: Tue Jul 15, 2008 11:21 am
Location: EMBL-EBI Cambridge UK

Saving the integration of Neuron at certain time

Post 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.
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Saving the integration of Neuron at certain time

Post 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
mattions
Posts: 65
Joined: Tue Jul 15, 2008 11:21 am
Location: EMBL-EBI Cambridge UK

Re: Saving the integration of Neuron at certain time

Post by mattions »

Hi Ted,

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

Pretty powerful method :)
Post Reply