Almost all of the GUI tools are implemented in hoc (the Print & File Window Manager is an
exception, perhaps the only exception), and you get all of that hoc code when you install
NEURON--it's in
nrn/share/nrn/lib/hoc for UNIX/Linux/OS X
and
c:\nrnxx\lib\hoc for MSWin.
So any time you want to discover how things work, just examine the appropriate file.
"How do I figure out what file to look in?"
The files have suggestive names. Alternatively, if there is a particular variable or procedure
that you want to find, you can do a text search with grep or some other tool (hint to MSWin
users: grep.exe is located in c:\nrnxx\bin !).
"How does z axis filtering work in the import3d tool?"
c:\nrnxx\lib\hoc contains import3d.hoc
This just xopens a bunch of hoc files in
c:\nrnxx\lib\hoc/import3d
I wanted to find the code that makes the xpanel that includes the string
3 point filter
because this would tell me what happens when one clicks on that checkbox.
So this file
import3d_gui.hoc
seemed most promising.
Bingo! Opening that file in a text editor and searching for
filter
found this line of code
xcheckbox("3 point filter of all z values (no undo)", &dummy_, "edit3()"
which tells me that the filiter is probably implemented by proc edit3().
Sure enough, in that very same file there is a proc edit3(), and that proc contains this
block of code:
Code: Select all
for i=0, swc.sections.count-1 {
sec = swc.sections.object(i)
sec.raw.setrow(2, sec.raw.getrow(2).medfltr)
}
So is medfltr just the Vector class's medfltr (median filter), or is it something else? If the
latter, there would have to be a proc medfltr() somewhere. So search all fhe files in
c:\nrnxx\lib\hoc
for occurrences of medfltr and . . . lucky us, medfltr appears only once, and we don't
have to try to decipher what some proc medfltr() does. It's almost certainly just the
Vector class's medfltr.
How could we confirm this hypothesis? This
sec.raw.setrow(2, sec.raw.getrow(2).medfltr)
suggests that sec.raw is a Matrix. We could verify this by reading our way through the
code that sets up the swc object, or we could be smart and change the above cited
for loop to
Code: Select all
for i=0, swc.sections.count-1 {
sec = swc.sections.object(i)
sec.raw.setrow(2, sec.raw.getrow(2).medfltr)
if (i==0) print sec.raw // diagnostic test
}
Then when we click on the z filter checkbox, the name of the object class of which
sec.raw is an instance will be printed in NEURON's xterm. If we discover that sec.raw
is a Matrix, the z axis filter is just a median filter.
As the authors of one of my favorite math books would say,
"This is left to the reader as an exercise."