antitheft159 commited on
Commit
e3b83da
·
verified ·
1 Parent(s): 280fff6

Upload 812_252_159.py

Browse files
Files changed (1) hide show
  1. 812_252_159.py +42 -0
812_252_159.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """812.252.159
3
+
4
+ Automatically generated by Colab.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/1JQ1VUztuM-aosrS_rLUYibn-AjdUT4Ql
8
+ """
9
+
10
+ import numpy as np
11
+ import matplotlib.pyplot as plt
12
+
13
+ # Parameters
14
+ tau_m = 20 # Membrane time constant (ms)
15
+ R_m = 1 # Membrane resistance (MΩ)
16
+ V_rest = -65 # Resting membrane potential (mV)
17
+ V_th = -50 # Spike threshold (mV)
18
+ V_reset = -65 # Reset potential (mV)
19
+ I = 1.5 # Input current (nA)
20
+ dt = 0.1 # Time step (ms)
21
+ t = np.arange(0, 100, dt) # Time vector
22
+
23
+ # Initialize membrane potential
24
+ V_m = np.zeros(len(t))
25
+ V_m[0] = V_rest
26
+
27
+ # Simulate the neuron
28
+ for i in range(1, len(t)):
29
+ dV = (-(V_m[i-1] - V_rest) + R_m * I) / tau_m
30
+ V_m[i] = V_m[i-1] + dV * dt
31
+
32
+ # Check for spike
33
+ if V_m[i] >= V_th:
34
+ V_m[i] = 20 # Spike to 20 mV
35
+ V_m[i+1] = V_reset # Reset potential
36
+
37
+ # Plot the results
38
+ plt.plot(t, V_m)
39
+ plt.title('.159 Neuron Simulation')
40
+ plt.xlabel('Time (ms)')
41
+ plt.ylabel('Membrane Potential (mV)')
42
+ plt.show()