Skip to content

Instantly share code, notes, and snippets.

@Seanny123
Created March 22, 2016 20:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Seanny123/78676146d7745cb2527e to your computer and use it in GitHub Desktop.
Save Seanny123/78676146d7745cb2527e to your computer and use it in GitHub Desktop.
Synthetic Neuron for SYDE552
from scipy.signal import lti
def synthetic_neuron(drive):
"""
Simulates a mock neuron with a time step of 1ms.
Arguments:
drive - input to the neuron (expect zero mean; SD=1)
Returns:
rho - response function (0=non-spike and 1=spike at each time step)
"""
dt = .001
T = dt*len(drive)
time = np.arange(0, T, dt)
lagSteps = int(.02/dt)
drive = np.concatenate((np.zeros(lagSteps), drive[lagSteps:]))
system = scipy.signal.lti([1], [.03**2, 2*.03, 1])
_, L, _ = scipy.signal.lsim(system, drive[:,np.newaxis], time)
rate = np.divide(30, 1 + np.exp(50*(.05-L)))
spikeProb = rate*dt
return np.random.rand(len(spikeProb)) < spikeProb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment