Page 1 of 1

output windows in python

Posted: Thu Jun 11, 2009 11:09 pm
by ramcdougal
I have recently decided to learn the Python interface for Neuron. I decided the best way to learn would be to convert some of my old scripts from hoc to python. I came so close to being successful on my own, but I haven't been able to figure out how to control shape plots without invoking the hoc interpreter.

For example, right now I have

Code: Select all

# ready shape plot
h('{objectvar sw}')
h('{sw=new PlotShape(0)}')
shapeWindow=h.sw
shapeWindow.size(-380.24,488.164,-624.858,170.347)
shapeWindow.variable('ip3i_wf')
shapeWindow.view(-380.24, -624.858, 868.404, 1595.205, 0, 0, 584.64, 535.36)
shapeWindow.exec_menu('Shape Plot')
# necessary to make flushPlot() update shapeWindow
h.fast_flush_list.append(shapeWindow)
shapeWindow.scale(0,.002)
Instead of the first three (non-comment) lines, I tried to use "shapeWindow=h.newshapeplot()" That almost works: it opens the shape plot, but shapeWindow is 0.0 instead of a HocObject (and hence I can't use it to set the size, variable, etc...) What is the right way to do this?

Also, I'd appreciate any words of wisdom anyone has about the parameters for size and view. I use these values because they work; I have no idea what they mean. Thanks!

Re: output windows in python

Posted: Fri Jun 12, 2009 5:06 am
by ramcdougal
I have a partial solution to my own question. I can open a shape plot and resize, etc... it entirely* in python by

Code: Select all

# ready shape plot
h.newshapeplot()
shapeWindow=h.fast_flush_list.object(h.fast_flush_list.count()-1)
shapeWindow.size(-380.24,488.164,-624.858,170.347)
shapeWindow.variable('cai')
shapeWindow.view(-380.24, -624.858, 868.404, 1595.205, 0, 0, 584.64, 535.36)
shapeWindow.exec_menu('Shape Plot')
shapeWindow.scale(0,.002)
This works because newshapeplot adds the window to the fast_flush_list, so all I have to do is extract the last element from the list. This feels like a hack. Is there a better way?


* For certain definitions of "entirely." In particular, I've always been assuming a "from neuron import gui" which I imagine reads stdrun.hoc.

Re: output windows in python

Posted: Fri Jun 12, 2009 9:25 am
by hines
This feels like a hack. Is there a better way?
Not really. The stdrun.hoc file was written prior to the existence of obfunc definititions that return
an object. Apart from changing stdrun.hoc you could write a
def newshapeplot():
that wraps the old hoc version or re-implements the three substantive lines of the original.
The size args are defined in
http://www.neuron.yale.edu/neuron/stati ... .html#size
and the view args are defined in
http://www.neuron.yale.edu/neuron/stati ... .html#view