Advertisement
toweber

IF_neuron_constant_input

Sep 19th, 2022
562
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. import os
  2. import ipdb # ipdb.set_trace()
  3. import numpy as np
  4. import matplotlib.pyplot as plt
  5.  
  6. InputCurrent = 1e-9
  7. C = 1e-9 #capacitance
  8. Vth = 0.3
  9. Vreset = 0
  10. tstep = 1e-3
  11. Ileak = 0
  12.  
  13. times = np.arange(0,1,tstep)
  14.  
  15. vmembrane = np.zeros(len(times))
  16. vmembrane[0] = 0
  17.  
  18. vout = np.zeros(len(times))
  19. vout[0] = 0
  20. for i, t in enumerate(times):
  21.     # I = C_M dV/dt + Il
  22.     # dV/dt = I/C
  23.     dV = InputCurrent/C * tstep
  24.     vmembrane[i] = vmembrane[i-1] + dV
  25.     if vmembrane[i] > Vth:
  26.         vmembrane[i] = 0
  27.         vout[i] = 1
  28.     else:
  29.         vout[i] = 0
  30.  
  31. fig, axs = plt.subplots(2)
  32. fig.suptitle('Integrate and Fire (IF) Spiking Neuron')
  33.  
  34. axs[0].plot(times,vmembrane)
  35. plt.xlabel("Time (s)")
  36.  
  37. axs[1].plot(times,vout,'r')
  38.  
  39. plt.xlabel("Time (s)")
  40. plt.ylabel("Output Voltage (V)")
  41.  
  42. plt.plot
  43. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement