sgratiy wrote:I have some issues with saving this window into a session file for reuse.
So don't reuse the session file. Use hoc statements to create the Graph. This gives you complete control over the name of the objref that refers to the Graph. It also gives you complete control over the location, size, axis scaling, and line colors used in the Graph.
I would be tempted to put the code that creates the Graph, plus the code for the custom proc advance(), into a hoc file with a special name something like csd.hoc. Then I would put a load_file("csd.hoc") statement in the "instrumentation" section of my main program file. If I didn't like the location on the screen where the Graph is drawn, I'd move it to where I want it, then use the Print & File Window Manager to save the Graph to a session file all by itself, and finally I'd read the ses file to discover the correct screen coordinates to use in the .view() statement in csd.hoc. Likewise, if I needed to change the size, axis scaling, or line color, I'd run the program, make the changes to the Graph, save to a ses file, and examine that file to discover the Graph method(s) to call, and the parameter values to use, in csd.hoc.
got two references: 'g' and 'save_window' pointing to window objects. To fix that I had to include a statement ' g=save_window_' and remove the statement 'g =new Graph()' to prevent interpreter from creating an extra window. This does not look like a good way of programming to me
so don't do it. Each tool has its most appropriate use. ses files are perfect for saving and recreating about 90% of the graphs that I use, but I find that the remaining 10% require customizations. For that 10% I may start with a ses file, but then I steal reusable code from the ses file to make my customizations.
The problem is that all object references to windows in .ses file are called 'save_window_'
because it's computer-generated code. The first two things I do to the code I steal from a ses file is
(1) ignore the ses file's "boilerplate" (stuff that NEURON puts there to help with the automatic recreation of objects saved from the GUI), and
(2) identify those statements that I need to reuse, and replace the computer-generated "generic" names in those statements (like save_window_) with the variable or objref names that I want to use. For example, see
How to use hoc to plot a variable vs. time
http://www.neuron.yale.edu/phpBB/viewto ... f=30&t=552
On top of all that, I was not able to save 'Color/Brush' properties for this window. I would change the line color, but upon reload of the session, the line color turns gray.
So after you change the color, save the Graph to a ses file, examine the statements in that file, and discover* the statement that is responsible for making the line red. Then go back to your hoc code and change it accordingly.
*--of course, the statement is documented somewhere in the Programmer's Reference, but often it is much easier to change a Graph and see what happens to the ses file. That tells me the name of the method, and which argument in the method call, and makes it easier for me to read the documentation.
is possible plot a user defined vector via GUI without writing a custom advance() procedure
"All things are possible through programming" but some strategies and implementations are more idiomatic than others. Let me know if you have questions about anything I have written here.
Code: Select all
double csddouble[Nzpos+1] // double array of CSDs
. . .
for fi = 0, Nzpos { csddouble[fi] = csddouble[fi] + wmat[fi][j]*i_membrane(l)*area(l)
. . .
for fi = 0, Nzpos { csdvec.x[fi] = csddouble[fi]} // pack csd array of doubles into a vector
I'm still not sure what the statement
for fi = 0, Nzpos { csddouble[fi] = csddouble[fi] + wmat[fi][j]*i_membrane(l)*area(l)
is doing, and what makes this multiply nested loop an improvement over the use of transfer resistances (are you generating a 2 dimensional map of extracellular potentials? doesn't seem likely, because csddouble is one dimensional), but presumably you know what you're doing.
That aside, I'd expect this code to execute more quickly if you did everything with Vectors (and maybe a Matrix, or even just an array of Vectors, for wmat). That would eliminate the "packing" step, and the Vector multiplication would occur at compiled code speed.