## Plotting M for IntFire4

Anything that doesn't fit elsewhere.
tmazing
Posts: 5
Joined: Wed Feb 06, 2019 7:39 pm

### Plotting M for IntFire4

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!
ted
Posts: 5935
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

### Re: Plotting M for IntFire4

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.
jtg374
Posts: 4
Joined: Tue Jun 25, 2019 5:55 am

### Re: Plotting M for IntFire4

So how do we plot M-t using if1.M? any examples? Thanks
ted
Posts: 5935
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

### Re: Plotting M for IntFire4

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.
Raj
Posts: 220
Joined: Thu Jun 09, 2005 1:09 pm
Location: Hanze University of Applied Sciences
Contact:

### Re: Plotting M for IntFire4

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.