Particularly useful chunks of hoc and/or NMODL code. May be pedestrian or stunningly brilliant, may make you gasp or bring tears to your eyes, but always makes you think "I wish I had written that; I'm sure going to steal it."
2 posts • Page 1 of 1
I am trying to generate many shape plots with different focuses and magnifications and save them by a python script. I managed to make the plots using .view, but discovered that .printfile only saves only the first view. Is there any way around this?
- Site Admin
- Posts: 5567
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
Good question. Here's Michael Hines's answer:
and here's a hoc example that assumes that some windows already exist, including two different views of a Shape:The printfile methods for Graph, etc should be extended to allow an optional second arg that specifies the view number.
With some difficulty, one can use the PWFM to iterate over all the printable windows, and, based on the window title returned by pwfm.name(i) decide whether to add to the print list with pwfm.paper_place() and then print with pwmf.printfile, eg partially
Code: Select all
>>> from neuron import h >>> s = h.Section() # now start some graph and shapeplots with views. >>> pwfm = h.PWManager >>> a = [pwfm.name(i) for i in range(int(pwfm.count()))] >>> a ['NEURON Main Menu', 'Print & File Window Manager', 'Graph NewView x -0.5 : 5.5 y -92 : 52', 'Graph NewView x 1.11022 : 1.80032 y -19.5399 : 19.1054', 'Graph NewView x 3.79393 : 5.05911 y -67.1566 : -0.217262', 'Shape NewView x -281.1 : 381.1 y -331.1 : 331.1', 'Shape NewView x -182.879 : 73.7631 y -98.5293 : 176.067'] >>>
I should mention that you don't have to create an instance of the PWManager class--it automatically exists if you are using NEURON's standard run system.
Code: Select all
oc>objref pwfm oc>pwfm = PWManager oc>pwfm.count() 10 oc>for i=0,pwfm.count()-1 print i, pwfm.name(i) 0 NEURON Main Menu 1 Print & File Window Manager 2 Temperature 3 VariableTimeStep 4 RunControl 5 NEURON Demonstrations 6 PointProcessManager 7 Shape NewView x -619.845 : 653.847 y -334.027 : 937.633 8 Graph x -0.5 : 5.5 y -92 : 52 9 Shape NewView x -288.3 : 351.593 y -300 : 338.949 oc>