It seemed like all I would need to do is use "h.xvalue" to update constants, and then have my own initialization procedure so that the model would be reset before each run, using the updated parameters. Each of these (updating parameters, and running my own initialization) work on their own but there is some disconnect where my model is not correctly updating.
I wrote “myinit()” in Python and implement it using
Code: Select all
initnew = h.FInitializeHandler(0,myinit)
As a detail, I have done this as a Python class when using action procedures in Python, and otherwise not as a class.
I include a print statement within “myinit” so I can see that a given value is at least updated in Python after changing it within my xpanel. If I print that value directly in terminal though, it is clear that it is not actually updated - I believe this means that it is not updated in hoc.
Here is an example:
For an IClamp in the soma, I have a parameter called "somastim_amp" which defines the hoc "IClamp.amp" parameter. If I increase "somastim_amp" from 0 to 1 nA using the xpanel, and print "somastim_amp" in terminal, it will indeed report a value of 1 nA (this is a Python variable). Within "myinit()", the update implementation looks like:
Code: Select all
stimIC = h.IClamp(.5, sec = soma)
stimIC.amp = somastim_amp
print "stimIC.amp = “, stimIC.amp, " and somastim_amp = “, somastim_amp
I also tried using action procedures in Python in the manner indicated in the same above link. This ran fine but still didn't solve the problem.
What ultimately worked was to write hoc procedures for the update action procedures instead of in Python. So, following the same example, I have a short hoc procedure that reads:
Code: Select all
proc update_stim_amp() {
nrnpython("stimIC.amp = somastim_amp")
}
This is a very longwinded post to just ask if there is a simpler, less clunky way to do this than what I am already doing. Am I just missing a step that ensures my "myinit" procedure gets run through hoc too? Thanks!