Page 1 of 1

MulRunFitter & Python

Posted: Sat Sep 09, 2023 1:03 pm
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!

Re: MulRunFitter & Python

Posted: Mon Sep 11, 2023 10:46 am
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" . . .

Re: MulRunFitter & Python

Posted: Tue Sep 12, 2023 11:47 am
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!

Re: MulRunFitter & Python

Posted: Tue Sep 12, 2023 3:26 pm
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.