How to iterate over all states of all mechanisms in a sec?

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."
Post Reply
hhshih
Posts: 5
Joined: Fri Nov 02, 2012 11:05 am

How to iterate over all states of all mechanisms in a sec?

Post by hhshih »

Does any one know how to iterate over all states of all mechanisms in a section?

I want to do this because I'm trying to record all states with vectors.
I can record the state if the mechanism's and state's names are known.

However, since the sets of mechanisms differ from cell to cell and from section to section,
it would be much better if we can know the names of mechanisms in currently accessed section.

Thanks!
ted
Site Admin
Posts: 6286
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: How to iterate over all states of all mechanisms in a se

Post by ted »

hhshih wrote:Does any one know how to iterate over all states of all mechanisms in a section?

I want to do this because I'm trying to record all states with vectors.
I can record the state if the mechanism's and state's names are known.
They are known, by you, during the course of model setup. Just pair each insert statement with corresponding Vector.record() statements. An alternative strategy is to use subsets (SectionLists) to keep track of which sections have which mechanisms during model setup, then after model setup is completed, iterate over each SectionList and execute the appropriate Vector.record() statements. A third strategy would be not to intrude on model setup at all, but instead after setup is complete do

Code: Select all

forall {
  if (ismembrane("foo")) {
    . . . statements that set up Vector recording of foo's states
  }
  if (ismembrane("bar")) {
    . . . statements that set up Vector recording of bar's states
  }
  . . . etc . . .
}
Be sure to read about ismembrane() in the Programmer's Reference.

Hints:
1. It is pointless to record density mechanism states at a section's 0 or 1 locations, because only internal nodes (i.e. nodes at segment centers) have their own states.
2. You're going to end up with a lot of Vectors. Make it easy on yourself by managing them with Lists; there's probably a note about this in the Forum's "Hot tips" area--if not, ask for an example.
hhshih
Posts: 5
Joined: Fri Nov 02, 2012 11:05 am

Re: How to iterate over all states of all mechanisms in a se

Post by hhshih »

Thanks!
Post Reply