Interviews graphing in Python
Posted: Thu Sep 29, 2016 11:29 pm
Hello,
I'm getting back into Neuron after a few years' hiatus...this time teaching myself Python in the process. I'm generally picking things up well, but I'm banging my head against graphing variables using the IV interface from python. I apologize--I wouldn't have created a forum topic if I'd had any luck looking for examples that address my problem.
My current test model is a small intfire network. I do think this could be part of my problem (one example--I've noticed that I get an error using h.Vector.record(h._ref_t) if I have only created ARTIFICIAL_CELL objects with no proper Sections to be found). However, I don't think it explains everything that I'm seeing.
So, in my hoc template called intfire, I create a public objref called "s" and assign it to a new IntFire1 object. I created an array of these templates (objref cell[4]). I then graph the intfire object state in IV by creating a new state graph, right-clicking-> "plot what", and entering cell[0].s.m. In hoc, it works just fine and all is well.
In python, I'm doing everything basically the same except for the pythonish invocation of the model (which seems to be OK), but the terminal complains when I try to plot the same variable, claiming that "cell" is not an array object. I also get complaints along the lines of "oc_restore_code tobj_count = X when it should be X-1". I tried the same thing from the terminal:
g = h.Graph()
g.addvar("cell[0].s.m")
But still an error. I also tried assigning "x = cell[0].s._ref_m", but plotting x doesn't work. However, that syntax does work with h.Vector.record(). I gather I'm missing something crucial...my guess is that I'm asking IV functions to handle Python variables, which it finds unsatisfactory. Am I stuck using matplotlib for graphing? I gather I should learn it eventually, but IV is very convenient for quick model design & debugging.
Thanks in advance,
John
I'm getting back into Neuron after a few years' hiatus...this time teaching myself Python in the process. I'm generally picking things up well, but I'm banging my head against graphing variables using the IV interface from python. I apologize--I wouldn't have created a forum topic if I'd had any luck looking for examples that address my problem.
My current test model is a small intfire network. I do think this could be part of my problem (one example--I've noticed that I get an error using h.Vector.record(h._ref_t) if I have only created ARTIFICIAL_CELL objects with no proper Sections to be found). However, I don't think it explains everything that I'm seeing.
So, in my hoc template called intfire, I create a public objref called "s" and assign it to a new IntFire1 object. I created an array of these templates (objref cell[4]). I then graph the intfire object state in IV by creating a new state graph, right-clicking-> "plot what", and entering cell[0].s.m. In hoc, it works just fine and all is well.
In python, I'm doing everything basically the same except for the pythonish invocation of the model (which seems to be OK), but the terminal complains when I try to plot the same variable, claiming that "cell" is not an array object. I also get complaints along the lines of "oc_restore_code tobj_count = X when it should be X-1". I tried the same thing from the terminal:
g = h.Graph()
g.addvar("cell[0].s.m")
But still an error. I also tried assigning "x = cell[0].s._ref_m", but plotting x doesn't work. However, that syntax does work with h.Vector.record(). I gather I'm missing something crucial...my guess is that I'm asking IV functions to handle Python variables, which it finds unsatisfactory. Am I stuck using matplotlib for graphing? I gather I should learn it eventually, but IV is very convenient for quick model design & debugging.
Thanks in advance,
John