Retrieve _ref_ range variables?

When Python is the interpreter, what is a good
design for the interface to the basic NEURON
concepts.

Moderator: hines

Post Reply
mctavish
Posts: 74
Joined: Tue Mar 14, 2006 6:10 pm
Location: New Haven, CT

Retrieve _ref_ range variables?

Post by mctavish »

I am trying to figure out what the possible range variables are for a hoc object in Python.

I can ask for things like

Code: Select all

soma.v
but this assumes that I know that variable "v" already exists. I want to retrieve the list of possible range variables.

psection at least gives me inserted mechanisms, but it does not tell me all variables that are available as one would get in the "Plot What?" window of a graph, which is what I want.
mattions
Posts: 65
Joined: Tue Jul 15, 2008 11:21 am
Location: EMBL-EBI Cambridge UK

Re: Retrieve _ref_ range variables?

Post by mattions »

Hi there,

the logic I use in Neuronvisio http://mattions.github.com/neuronvisio/ is to check if the section has that variable as attribute:
(Have a look to the following code:

Code: Select all

from neuron import h
soma = h.Section()
if hasattr(soma, 'v'):
    print "Variable v present"
It worked pretty well so far.
mctavish
Posts: 74
Joined: Tue Mar 14, 2006 6:10 pm
Location: New Haven, CT

Re: Retrieve _ref_ range variables?

Post by mctavish »

Thanks Mattions, but that does not really answer my question.

I know I can test for a particular attribute in ways like you suggest, but what I am after is an enumeration of existing parameters. Related to your approach are typical Python functions like dir(), or the inspect module, which are extremely useful, but these approaches (seemingly) do not apply here since these are hoc objects that mask available variables that are normally available in Python objects.
hines
Site Admin
Posts: 1687
Joined: Wed May 18, 2005 3:32 pm

Re: Retrieve _ref_ range variables?

Post by hines »

You can iterate over all available mechanisms with
http://www.neuron.yale.edu/neuron/stati ... htype.html

http://www.neuron.yale.edu/neuron/stati ... hstan.html
is used to enumerate the range variables.

In python,
for mech in soma(.5):
print mech.name()
will give all the density mechanisms inserted in soma
Post Reply