The true test is whether it runs without bugs. Somehow, the most pernicious errors are those that one writes oneself. I have the hardest time spotting my own bugs, but when examining someone else's code I can identify gross errors most of the time, and discover subtle errors much of the time. NEURON, however, will discover them all sooner or later.
So the question to you is, have you tested it, and does it work? Have you used an IClamp to force v above thresh while gnam was already 0, and does this delay the gnam reactivation time appropriately?
A further note: even though this code may work properly under all circumstances, it still invites a future error. Check out this excerpt:
Code: Select all
if (gnam > 0) { : conductance is on, so turn it off
gnam = 0
net_send(toff, 1) : to turn it back on
}
if (gnam==0) { : it's already off, so delay the recovery time
net_move(t + toff)
}
Originally I had written the entire NET_RECEIVE block using "
if ( ) { . . . } else if ( ) { . . . }" chains. However, this tends to be less readable, at least to me, so in posting to the Forum I broke it into separate
if clauses.
Consider what happens when these statements are executed. The first
if statement will set gnam to 0 and launch a self-event with flag 1 that returns at time t+toff. The second
if statement will then call net_move to move this self event to t+toff. No harm done because the flag 1 event return time is unaltered, but (1) it wastes run time, and more importantly, (2) it is vulnerable to future error. Suppose at some future date you decide that a threshold crossing that occurs while gnam is already 0 should move the reactivation time to
t+t2 where
t2 != toff. Since the 2nd
if statement's
net_move(t + t2)
is always executed, even the first threshold crossing will turn gnam off for t2 instead of toff ms. Not what you wanted at all.
So it's best to change
Code: Select all
}
if (gnam==0) { : it's already off, so delay the recovery time
to
Code: Select all
} else if (gnam==0) { : it's already off, so delay the recovery time