I have the following code that plots the "M" function in IntFire1 as an example that I want to ensure is following best practices and to clarify:

Code: Select all

```
from neuron import h
import numpy as np
import matplotlib.pyplot as plt
h.load_file("stdrun.hoc")
h('proc advance() {nrnpython("myadvance()")}')
t_idx = 0
def myadvance():
global t_idx, t_vec, m_vec
t_vec[t_idx] = h.t
m_vec[t_idx] = cell.M()
t_idx += 1
h.fadvance()
cell = h.IntFire1()
ns = h.NetStim(cell)
ns.number = 2
ns.start = 15
ns.interval = 10
nc = h.NetCon(ns, cell)
nc.weight[0] = .5
nc.delay = 0
h.init()
h.tstop = 40
t_vec = np.zeros(int(np.ceil(h.tstop/h.dt)))
m_vec = np.zeros_like(t_vec)
h.run()
plt.figure(figsize=(8,4))
plt.plot(t_vec, m_vec)
```

- Is this the best way?

Is there a way to pass variables to**myadvance()**without them being global?

I am defining t_idx, which is really the simulation step counter. Is there such a counter in Hoc?