Page 1 of 1

Keeping the maximum voltage in a space plot

Posted: Wed Oct 28, 2009 6:50 pm
by ecmun
I remember learning how to keep the maximum voltage as well as the voltage in a space plot when I first learned NEURON. How do you do it? Do you have to program it with a RangeVarPlot or is there an option similar to "KeepLines"?

Re: Keeping the maximum voltage in a space plot

Posted: Thu Oct 29, 2009 2:06 am
by ted
I remember learning how to . . .
Isn't it interesting that the context is retained long after the content has become (relatively) inaccessible.

The trick is to create a mod file that tests for extrema in an AFTER SOLVE block, and stores them in range variables. Here's a mod file for a distributed mechanism that will capture the max and min values of v, and the times of these extrema, in all nodes of all sections into which it has been inserted. The same strategy will work for any other range variable.

Code: Select all

NEURON {
        SUFFIX extr     : for "extrema"
        RANGE vmax, vmin, tmax, tmin
}

ASSIGNED {
        v (millivolt)
        vmin (millivolt)
        tmin (ms)
        vmax (millivolt)
        tmax (ms)
}

INITIAL {
        vmin = v
        tmin = t
        vmax = v
        tmax = t
}

AFTER SOLVE {
        if (v < vmin) {
                vmin = v
                tmin = t
        }
        if (v > vmax) {
                vmax = v
                tmax = t
        }
}