Rset or reboot neuron without exist in python

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

Moderator: hines

Post Reply
anandhupresannan
Posts: 11
Joined: Tue Feb 26, 2019 10:13 am

Rset or reboot neuron without exist in python

Post by anandhupresannan »

Hai,

I am working on a multi-compartmental model which is done in python with the help of neuron package. Currently the model is working. But I have a problem after the first run if I run the model again without existing the model, its showing different output. The model providing the correct output only in the first run. Is there any methods or functions which is available to reset or restart the neuron without existing.

Thank you
ted
Site Admin
Posts: 6287
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Rset or reboot neuron without exist in python

Post by ted »

Something persists after the end of one simulation, and that something affects the next simulation. This happens when initialization is inadequate, so that, when you launch a second simulation, the value of one or more variables that were affected by the previous simulation are not first restored to what they were before the start of the first simulation. The affected variables might be among the biological properties of the model itself (e.g. a gating state, in which case a mod file with an incorrect INITIAL block would be a likely cause) or they could be variables that control stimuli applied to the model (for example, an index or "seed" that controls values generated by a pseudorandom number generator used to emulate current noise or stochastic variation of a gating state).

This is a serious problem that needs to be fixed before you try to do serious work with your model. If simulation results are to be useful for gaining insight to a system, there must be a close match between your conceptual model (your idea of what equations the computer is solving) and the computational model (the equations that the computer is actually solving). The first step in verifying such a match is demonstrating that a computational model generates exactly the same result from one run to the next. If it doesn't, you can't determine which result is the "correct" one; indeed, both runs may be incorrect. In none of these cases is it possible to establish that there is a close match between conceptual and computational model.

The way to proceed is to replace your existing model with a much simpler model that generates reproducible results. Then add complexities to it, one at a time, testing after each new complication to make sure that simulation results are reproducible.
RobinDS
Posts: 22
Joined: Mon Nov 04, 2019 12:17 pm

Re: Rset or reboot neuron without exist in python

Post by RobinDS »

So is there a method to fully reset the simulator?
ted
Site Admin
Posts: 6287
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Rset or reboot neuron without exist in python

Post by ted »

So is there a method to fully reset the simulator?
Yes. It's called finitialize(), and it takes care of everything that is built into NEURON. But if you write some code that adds new state variables, it's up to you to make sure that those new state variables are properly initialized. See my previous reply, to which I would add this comment: user-written mod files are a common source of initialization problems.
RobinDS
Posts: 22
Joined: Mon Nov 04, 2019 12:17 pm

Re: Rset or reboot neuron without exist in python

Post by RobinDS »

What would be the steps to check mod whether mod files have a correct INITIAL block?

Could you provide some steps like this?

* Scan over the entire mod file and look for all "state variables" (lines starting with _____ inside of a _____ block)
* Make sure that every "state variable" is ______ in the INITIAL block

Could it be that simple to spot and reset state variables or would I have to actually reverse-engineer the whole mod file to find out what's what?
RobinDS
Posts: 22
Joined: Mon Nov 04, 2019 12:17 pm

Re: Rset or reboot neuron without exist in python

Post by RobinDS »

Quick question, it doesn't seem to remove Sections? Isn't there a method to truly really reload the NEURON module as if it was freshly imported? Would you recommend importlib's reload?
ramcdougal
Posts: 267
Joined: Fri Nov 28, 2008 3:38 pm
Location: Yale School of Public Health

Re: Rset or reboot neuron without exist in python

Post by ramcdougal »

h.finitialize() resets a model (if the mod files, etc were setup right) but it does not reset the simulator.

importlib.reload will have no useful effect. It will not cause Sections to disappear, it will not reset the temperature, etc. It's basically only useful for modules that are themselves written in Python.

There are edge cases (generally having to do with global variables like h.celsius or possibly the rxd module), but:

Generally speaking to have a model exist temporarily, all you have to do is have a single function that creates and simulates the model and returns whatever answer. The sections and associated mechanisms will be local variables and thus automatically garbage collected when the function finishes.

If you want to allow code to do anything and be guaranteed to be in the same state, you can run the simulation in a child process. Python's multiprocessing module provides this capability for almost free; for a NEURON example, see e.g. here.
Post Reply