Shape plot does not reload properly

Using the graphical user interface to build and exercise models. Includes customizing the GUI by writing a little bit of hoc.
Post Reply
sgratiy
Posts: 41
Joined: Tue Mar 30, 2010 5:33 pm

Shape plot does not reload properly

Post by sgratiy » Thu Apr 05, 2012 6:38 pm

I created the Shape plot of transmembrane voltage with specified custom variable scale and the specified "shape style". Then, I saved the session into the .ses file. However, upon reloading this .ses file the specified custom variable scale and the shape style are lost. The scale reverts back to [-80 40] and shape style to "centroid" . It is very frustrating to have to reset the variable scale every time I reload my code which I have to do ofter during debugging/developing. Is this the NEURON bug or am I doing something wrong?

Thanks

ted
Site Admin
Posts: 5306
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Shape plot does not reload properly

Post by ted » Fri Apr 06, 2012 2:08 pm

You're not doing anything wrong; that's just how this particular tool works. I don't like it either. To make it do what you want, you have to write some hoc code. Here's an example.

Conceptual model cell:

Code: Select all

axon  soma  dendrite
-------o-------
axon: 500 um long, 1 um diam
soma: 20x20 um
dendrite: 500 um long, 2 um diam
All have Ra 160 ohm cm, cm 1 uf/cm2, and hh, but all ionic conductances in dend are reduced to 1/10 of normal hh values (so resting potential is -65 everywhere).

I implemented this model with the CellBuilder (d_lambda = 0.1), and used other GUI tools to set up the instrumentation. Here's init.hoc:

Code: Select all

load_file("nrngui.hoc")

load_file("cell.ses") // model cell with 500x1 axon, 20x20 um soma, and 500x2 um dend
  // all with Ra = 160 ohm cm, cm = 1 uf/cm2,
  // and hh, but all conductances in dend reduced to 1/10 of normal
load_file("rig.ses") // RunControl with Tstop 8 ms
  // PointProcessManager as IClamp that delivers 0.1 ms x 3 nA starting at 1 ms
  // Movie Run, graph of soma.v(0.5) vs. t, space plot of v
load_file("shapeplot.hoc") // uses PlotShape to show v in false colors

// movierun() // uncomment this line after everything works properly
I used the Print & File Window Manager to select which GUI windows ended up in rig.ses, ensuring that the CellBuilder and the "shape plot" ended up in separate ses files.

In my first implementation, shapeplot.hoc was just a copy of the ses file for the shape plot. Of course, this merely brought up a plain old shape plot, with no color scale--during a simulation, this thing just sat there on the screen and did nothing.

So I wrote a new shapeplot.hoc that borrowed some things from the ses file, and here it is:
objref ps
ps = new PlotShape(0)
ps.size(-458.854,479.354,-469.104,469.104)
ps.variable("v")
ps.view(-458.854, -469.104, 938.208, 938.208, 592, 105, 200.64, 200.32)
fast_flush_list.append(ps)
What it borrowed were the arguments to the .size() and .vew() statements--these ensured that my PlotShape (a "shape plot" that can be used to generate false color plots of a range variable) would be drawn in the desired location on my screen, and that the model cell would be in the center of its canvas at an appropriate size--and the fast_flush_list.append() statement (which makes sure that the PlotShape is updated at each fadvance()).

But there still wasn't a color scale, and this plot didn't seem to do anything.

I knew that clicking on the "Shape Plot" item in its menu would bring up the color scale, but I didn't want to have to do that. So instead I tried executing
ps.exec_menu("Shape Plot")
and that did the trick.

So I revised shapeplot.hoc by adding
ps.exec_menu("Shape Plot") // v depicted via colormap
as the last statement in the file, and that worked.

But I wanted to see the different diameters. If I tried the PlotShape's "Show Diam", the axon simply vanished (too thin to appear in the PlotShape window!). I could have fixed this simply by zooming into the vicinity of the soma until I liked what I saw, then using the PFWM to save a new ses file, and finally copying the args from this ses file into shapeplot.hoc, but that would have given me a window that showed only the most proximal parts of axon and dendrite--the largest part of those sections would have extended way outside the PlotShape's view port.

So I used
forall ps.len_scale(0.05)
(documented in the Programmer's Reference of the PlotShape and Shape classes) to make all sections appear shorter, and then zoomed in on the shortened cell until it looked OK. Then I saved the modified PlotShape window to a ses file, and copied the args from this ses file into shapeplot.hoc

And it worked. Here's the final shapeplot.hoc

Code: Select all

objref ps
ps = new PlotShape(0)
// ps.size(-458.854,479.354,-469.104,469.104)
ps.size(-23.8933,24.1733,-24.4108,23.5808)
ps.variable("v")
// ps.view(-458.854, -469.104, 938.208, 938.208, 592, 105, 200.64, 200.32)
ps.view(-23.8933, -24.4108, 48.0667, 47.9917, 592, 105, 200.64, 200.32)
fast_flush_list.append(ps)
forall ps.len_scale(0.05) // so that even the thinnest section is clearly visible
  // revised .size & .view args are for this len_scale
ps.exec_menu("Show Diam")
ps.exec_menu("Shape Plot") // v depicted via colormap
// to use a different scale with this colormap
// ps.scale(low, high)
Here's the zip file that contains init.hoc, cell.ses, rig.ses, and shapeplot.hoc.
http://www.neuron.yale.edu/ftp/ted/neur ... _scale.zip
To see the final result in action, double click on init.hoc (or execute
nrngui init.hoc
from the command line).

sgratiy
Posts: 41
Joined: Tue Mar 30, 2010 5:33 pm

Re: Shape plot does not reload properly

Post by sgratiy » Mon Apr 09, 2012 5:03 pm

Ted, thanks for such a detailed response. I have looked at your code and used the .exec_menu("Show Diam") and .exec_menu("Shape Plot") commands to "activate" the desired Shape Plot features. It works! Perhaps, the next version of NEURON should include .exec_menu statements when saving Shape Plots into the session file.

I have another related question. I cannot seem to understand how to specify a custom colormap. I do not understand the 4 argument syntax of the colormap as shown in the Programmers Reference "s.colormap(index, red, green, blue)". What does "index" mean? And what exactly do the numbers for colors mean? For instance, I want to create the "blue-black-red" colormap, such that negative membrane currents are shown in red, positive in blue and very small or zero currents were shown in black. Could you please advice which arguments should I put into the .colormap or recommend me some guide for improving my understanding?

Thanks

sgratiy
Posts: 41
Joined: Tue Mar 30, 2010 5:33 pm

Re: Shape plot does not reload properly

Post by sgratiy » Tue Apr 10, 2012 7:55 pm

Since I did not get the reply to the last question, I figured that I must have asked for something too obvious. So I did figure out the colormap thing on my own. In case someone else needs to specify a custom colormap, you can use similar definition immediately after psh_v = new PlotShape(0)

Code: Select all

psh_v.colormap(11)
psh_v.colormap( 0 , 255 , 255 , 0 ) 
psh_v.colormap( 1 , 255 , 153 , 0 ) 
psh_v.colormap( 2 , 255 , 51 , 0 ) 
psh_v.colormap( 3 , 204 , 0 , 0 ) 
psh_v.colormap( 4 , 102 , 0 , 0 ) 
psh_v.colormap( 5 , 0 , 0 , 0 ) 
psh_v.colormap( 6 , 0 , 0 , 102 ) 
psh_v.colormap( 7 , 0 , 0 , 204 ) 
psh_v.colormap( 8 , 0 , 51 , 255 ) 
psh_v.colormap( 9 , 0 , 153 , 255 ) 
psh_v.colormap( 10 , 0 , 255 , 255 ) 


ted
Site Admin
Posts: 5306
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Shape plot does not reload properly

Post by ted » Wed Apr 11, 2012 4:00 pm

Thanks, other users will find that helpful.

(Now if I can just wait long enough, and be real quiet, maybe he'll answer all of the other questions that are posted on the Forum . . . )

Post Reply