Keeping the maximum voltage in a space plot

The basics of how to develop, test, and use models.
Post Reply
ecmun
Posts: 1
Joined: Tue Oct 20, 2009 4:34 pm

Keeping the maximum voltage in a space plot

Post 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"?
ted
Site Admin
Posts: 6305
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Keeping the maximum voltage in a space plot

Post 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
        }
}
Post Reply