Control a simulation step by step

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

Moderator: hines

Post Reply
camilhamdane
Posts: 7
Joined: Mon Aug 05, 2019 7:37 am

Control a simulation step by step

Post by camilhamdane » Wed Aug 28, 2019 1:29 pm

Hello there,

I am currently trying to simulate a population of cells in two different language, NEURON and NEST. The thing is that I want to have a simulation that is running for a rather large period of time, where I can control every input that happens every millisecond. As the input for the NEURON cells comes from the NEST part of the program, it is mandatory to be able to control each step.

Code: Select all

for step in total_amount_of_steps
	stimulate in NEST
	stimulate in NEURON
	go to next step
instead of doing

Code: Select all

for each step in total_time
	h.tstop = dt
	stimulate in NEST
	stimulate in NEURON
	h.run()
here it is not possible to keep the values of the last step for the new one, and also I have only a sequence of really short steps...
I've gone through the py_doc but I didn't really understand what I should use in order to achieve what I want to do...

Thank you for your precious time,
Camil

ramcdougal
Posts: 154
Joined: Fri Nov 28, 2008 3:38 pm
Location: Yale School of Medicine

Re: Control a simulation step by step

Post by ramcdougal » Thu Aug 29, 2019 9:50 am

Calling h.fadvance() advances the simulation by one timestep.

When using fixed-step integration, the time step size is controllable by setting h.dt; by default it is 1/40 ms.

When controlling a simulation in this way, before beginning your advances, you must explicitly initialize the simulation with e.g. h.finitialize(-65) (where -65 can be replaced with whatever initial membrane potential).

You may also be interested in h.continuerun(tstop) which advances the simulation until time tstop, however many internal time steps that takes. Again, using this requires explicitly initializing the simulation at the beginning as it preserves state unlike h.run which implicitly reinitializes every time it is called. Also note that like h.run, h.continuerun is only available after loading the standard run system. This can be done in many ways, e.g. by importing gui, or by h.load_file('stdrun.hoc')

camilhamdane
Posts: 7
Joined: Mon Aug 05, 2019 7:37 am

Re: Control a simulation step by step

Post by camilhamdane » Thu Aug 29, 2019 12:11 pm

Thank you very much for your clear, quick and concise response :)

Post Reply