Page 1 of 1
Retrieve _ref_ range variables?
Posted: Thu Mar 11, 2010 6:03 pm
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
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.
Re: Retrieve _ref_ range variables?
Posted: Fri Mar 12, 2010 11:48 am
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.
Re: Retrieve _ref_ range variables?
Posted: Fri Mar 12, 2010 2:11 pm
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.
Re: Retrieve _ref_ range variables?
Posted: Sat Mar 13, 2010 4:15 pm
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