output windows in python

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

Moderator: hines

Post Reply
ramcdougal
Posts: 155
Joined: Fri Nov 28, 2008 3:38 pm
Location: Yale School of Medicine

output windows in python

Post by ramcdougal » Thu Jun 11, 2009 11:09 pm

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!

ramcdougal
Posts: 155
Joined: Fri Nov 28, 2008 3:38 pm
Location: Yale School of Medicine

Re: output windows in python

Post by ramcdougal » Fri Jun 12, 2009 5:06 am

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.

hines
Site Admin
Posts: 1577
Joined: Wed May 18, 2005 3:32 pm

Re: output windows in python

Post by hines » Fri Jun 12, 2009 9:25 am

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

Post Reply