Page 1 of 1

Handle graphics

Posted: Fri Feb 17, 2006 9:08 pm
by kelvin
https://www.neuron.yale.edu/phpBB2/viewtopic.php?t=293

On that topic thread above I learned that in NEURON (or I guess more correctly InterViews) as in Matlab there are ways of peeking into the low level objects that make up a graphic. In Matlab they call this "handle graphics", and for all I know this term is ubiquitous. Here is the piece of advice that got me thinking.
1 is easy. Use hoc code or the GUI to set up your shape plot, and run a simulation to
make sure that what you're seeing is what you want to record.
Then type
allobjects()
at the oc> prompt, and look for a mention of RangeVarPlot. You should see
RangeVarPlot[0] with 1 refs
So when a Shape/Space Plot is set up, a new object appears called RangeVarPlot[0], and by using the 'dot' notation I can address different properties of the object. I took a look here https://www.neuron.yale.edu/neuron/stat ... rence.html and found that if I want to I could pluck the x and y values on the plot and stick them in some new vectors that I could then manipulate.

The first thing I would like to learn is how I could change the color scaling in a Shape/Shape Plot. So if I use the pyramidal neuron in neurondemo, make the default Shape Plot into a Shape/Shape Plot and hit Init & Run, I am treated to a lovely display of colors.

But I'm picky and I don't want to use all the color bandwidth on voltages above spike threshold, I'd rather just make all voltages >-30 bright yellow and use the rest of the scale to watch subthreshold changes in voltage in more detail.

1) How do I figure out which objects listed by oc>allobjects() are associated with a particular graph?
2) What does the term "with 1 refs" or "with 2 refs" mean exactly? If this information is already in a written form somewhere, just point me to it and I will do some homework.
3) How could I retrieve all the voltage data used in the Shape/Shape Plot and use some logarithmic scaling (for example) to change the color mapping?

I could go on and on, but I guess I will leave it there for now.
Kelvin

Re: Handle graphics

Posted: Sat Feb 18, 2006 9:30 pm
by ted
Good questions, Kelvin. Keep 'em coming. We're building up a wish list for stuff to
include in the 2nd edition of The NEURON Book.
The first thing I would like to learn is how I could change the color scaling in a Shape/Shape Plot. So if I use the pyramidal neuron in neurondemo, make the default Shape Plot into a Shape/Shape Plot and hit Init & Run, I am treated to a lovely display of colors.

But I'm picky and I don't want to use all the color bandwidth on voltages above spike threshold, I'd rather just make all voltages >-30 bright yellow and use the rest of the scale to watch subthreshold changes in voltage in more detail.
I agree totally. Searching the Forum for
color scale
turned up this hit
https://www.neuron.yale.edu/phpBB2/view ... lour+scale
Nice touch that phpBB's search works for either UK or US spelling, at least in this
instance.
1) How do I figure out which objects listed by oc>allobjects() are associated with a particular graph?
Haven't seen a case in which it was necessary to do such a thing. Anyway, it's moot
as far as color scale is concerned.
2) What does the term "with 1 refs" or "with 2 refs" mean exactly? If this information is already in a written form somewhere, just point me to it and I will do some homework.
To quote from chapter 13 of The NEURON Book,
The object model in hoc

The object model used by hoc manipulates references to objects, never the objects
themselves.

. . .

Creating and destroying an object

You create an object with the new keyword. Thus
objref g
g = new Graph()
uses the Graph template to create one Graph object that we can refer to as g.
We'll talk about where the templates come from later. Executing these two
statements will create one graph window on the screen.

Several object references can refer to the same object. Continuing with the present
example,
objref h
h = g
does not create a second graph but merely associates h with the same Graph object
as g. The "reference count" of an object is the number of object references that point
to it. We would say that this Graph object has a reference count of 2.

If an object is no longer referenced, i.e. when its reference count is 0, it is destroyed
and the memory that held its data becomes available for any other purpose. In this
example, we can break the association between g and the Graph object by redeclaring g
objref g
so that g once again points to the NULLobject. However, the graph will persist on our
screen because it is still referenced by h. To get rid of the graph we have to break this
final reference, e.g. with the statement
h = g
3) How could I retrieve all the voltage data used in the Shape/Shape Plot and use some logarithmic scaling (for example) to change the color mapping?
I'd try a different approach. For shape plots of v, I'd design a color map that spanned
the range of (? subthreshold) potentials that was of interest, then use the PlotShape's
scale() method to set the "low" value to the most negative v that I wanted to see, and
the "high" value to the most depolarized value that I wanted to resolve.

For variables that span a very wide range, e.g. cai, I'd consider writing a mod file that
creates a new density mechanism with suffix logconc (or some other suffix that is
mnemonic and doesn't conflict with an existing keyword). The NEURON block of this
mod file would assert
READ cai
RANGE pca
and the ASSIGNED block would declare
pca (1)
The BREAKPOINT block would have a single statement:
pca = log10(cai)
Then I could insert logconc into all sections that have a ca accumulation mechanism,
and I'd be able to create space plots that display pca_logconc. I haven't tried this, so
I may have left something out or made a syntax error, but something like it should work.

In any case, let me know what you did, and how it worked out.