Page 1 of 1

Plotting M for IntFire4

Posted: Thu May 16, 2019 9:01 pm
by tmazing
Hello!

I was wondering if anyone could let me know how to plot M for IntFire4. Unfortunately, it's not a global or range variable, but a function, so I'm not sure how to plot it with Python. I've tried using:

mvec = h.Vector()
mvec.record(h._ref_M)

with no luck. Thanks!

Re: Plotting M for IntFire4

Posted: Fri May 17, 2019 11:23 pm
by ted
Example (pertains to all IntFire classes):
if1 = h.IntFire1()
The Python name of the function itself will be if1.M, but you want the numerical value returned by the function, so you need if1.M(). Note that if1.M() will not return a reasonable value unless h.finitialize() was called previously. Indeed, executing if1.M() _before_ initialization will trigger a segmentation fault.

Re: Plotting M for IntFire4

Posted: Thu Nov 21, 2019 10:46 pm
by jtg374
So how do we plot M-t using if1.M? any examples? Thanks

Re: Plotting M for IntFire4

Posted: Fri Nov 22, 2019 12:48 pm
by ted
Your first decision is whether to plot M vs. t "on the fly" i.e. while the simulation is executing. If yes, this is most easily done by using NEURON's own plotting features. For example, if your IntFire1 instance was created by this Python statement

if1 = h.IntFire1()

then print will reveal its hoc name, e.g.

print(if1)

would return something like this

IntFire1[0]

and you could create a NEURON graph that will plot if1.M vs. time by executing

g = h.Graph()
g.size(0,h.tstop,0,1) # sets x and y axis ranges
g.addexpr("IntFire1[0].M") # specify hoc name of variable used for y coordinates
h.graphList[2].append(g) # x coordinates are h.t, updated automatically during a run

before you execute h.run() (or h.continuerun() if that's how you're launching simulations). This all assumes that you loaded NEURON's graphical library e.g. by

from neuron import h, gui

before executing any GUI-related statements.


The alternative is to capture the values of M and t during a simulation to a pair of Vectors, using the Vector class's record() method; then after the simulation ends, plot the saved values to a graph. This plot could be generated with either NEURON's own plotting features, or entirely with Python, e.g. using the matplotlib module. Vector.record() is documented in the Programmer's Reference; matplotlib is documented extensively all over the Internet.

Re: Plotting M for IntFire4

Posted: Tue Sep 08, 2020 4:25 am
by Raj
We included plotting code on ModelDB when writing about the IntFire4 mechanism: https://senselab.med.yale.edu/ModelDB/s ... del=115357

Admittedly it is old code, so I am not sure it will run with the latest version of Neuron.