Created
March 22, 2016 20:13
-
-
Save Seanny123/78676146d7745cb2527e to your computer and use it in GitHub Desktop.
Synthetic Neuron for SYDE552
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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