I'm loading an existing hoc file into python and would like to list the available state variables in each compartment. For example, the soma has a variable 'v' in each location (available through h.soma(0.5).v). Is there a programmatic way to do so?
Thanks!
Finding available variables in each section
Moderator: hines
-
- Posts: 41
- Joined: Sun Aug 08, 2010 11:09 am
Re: Finding available variables in each section
Hi Hines :
I have the same question ! Although it has been asked by another post by mattioni, which the indirect way is "loop and check" whether a variable exists, but ...
Is there any direct way, like <$ dir(soma)> function which automatically lists all the range variables accessible from a Section or a Segment ?
ideally, it shall be
when you call <$ dir(soma)>, it lists : .v .ek .ena
when you call <$ dir(soma(0.5))>, it lists : .v .gk .gna
Thanks !
I have the same question ! Although it has been asked by another post by mattioni, which the indirect way is "loop and check" whether a variable exists, but ...
Is there any direct way, like <$ dir(soma)> function which automatically lists all the range variables accessible from a Section or a Segment ?
ideally, it shall be
when you call <$ dir(soma)>, it lists : .v .ek .ena
when you call <$ dir(soma(0.5))>, it lists : .v .gk .gna
Thanks !
Re: Finding available variables in each section
you can try:
for sec in h.allsec():
for seg in sec:
for mech in seg:
for n in dir(mech):
if n.endswith(mech.name()):
print sec, seg, mech, n
for sec in h.allsec():
for seg in sec:
for mech in seg:
for n in dir(mech):
if n.endswith(mech.name()):
print sec, seg, mech, n
Re: Finding available variables in each section
looks like I need to show it in code since all the indentation was removed above
Code: Select all
for sec in h.allsec():
for seg in sec:
for mech in seg:
for n in dir(mech):
if n.endswith(mech.name()):
print sec, seg, mech, n
-
- Posts: 41
- Joined: Sun Aug 08, 2010 11:09 am
Re: Finding available variables in each section
Thanks Hines ! The 'n' print is what I want :-)