MulRunFitter & Python

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

Moderator: hines

Post Reply
Robert Claar
Posts: 25
Joined: Tue Jun 23, 2020 8:52 am

MulRunFitter & Python

Post by Robert Claar »

I have been scouring the forum for a way to use MulRunFitter programmatically in python. I found one post linking a model on modelDB that had a statement in their python code

Code: Select all

mrf = h.MulRunFitter[0]
but when I import h from neuron and list its methods and attributes I do not see MulRunFitter listed. I have also tried to import the gui and see if I could access it that way. Is there currently a way to work with the Multiple Run Fitter through my own code in python or do I need to seek other non-NEURON methods of optimization? I just need to optimize 4 parameters in some MOD files so my simulation outputs match some data I have so my problem is fairly simple. I found similar posts on the forum but still could not figure it out. Any help is appreciated!
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: MulRunFitter & Python

Post by ted »

I found one post linking a model on modelDB that had a statement
I suspect that one or more other statements must be executed before one tries to create an instance of the MulRunFitter class. Examine the source code for that entry in ModelDB (BTW, which entry is it?) and look for something similar to
h.load_file("mulfit.hoc" . . .
Robert Claar
Posts: 25
Joined: Tue Jun 23, 2020 8:52 am

Re: MulRunFitter & Python

Post by Robert Claar »

Yup, you are right. I was too narrowly focused. Running

Code: Select all

h.load_file("mulfit.hoc")
along with my other imports allowed me to call

Code: Select all

h.MulRunFitter
Thanks!
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: MulRunFitter & Python

Post by ted »

One might well ask
"How did ted make such an informed guess?"

I now draw back the curtain of secrecy (faint of heart, pass not this line!)

I executed
nrngui
then created an instance of the Multiple Run Fitter by clicking on
NEURON Main Menu / Tools / Fitting / Multiple Run Fitter

(of course this is doable from inside Python--just
from neuron import h, gui
which will give you a NEURON Main Menu toolbar)

Then I saved a session file by clicking on
NEURON Main Menu / File / Save Session
which brought up a "file viewer/loader" tool

I made sure that the top edit field of this tool contained the string
./foo.ses
and then I clicked on the Save button.

Finally, I examined the plain text file foo.ses, where I saw, a few lines down from the top, these statements:

Code: Select all

//Begin MulRunFitter[0]
{
load_file("mulfit.hoc", "MulRunFitter")
}
{
ocbox_ = new MulRunFitter(1)
}
Everything after that was pure guesswork.
Post Reply