|
6 | 6 | class HodgkinHuxley(): |
7 | 7 | """Full Hodgkin-Huxley Model implemented in Python""" |
8 | 8 |
|
9 | | - C_m = 1.0 |
10 | | - """membrane capacitance, in uF/cm^2""" |
11 | | - |
12 | | - g_Na = 120.0 |
13 | | - """Sodium (Na) maximum conductances, in mS/cm^2""" |
14 | | - |
15 | | - g_K = 36.0 |
16 | | - """Postassium (K) maximum conductances, in mS/cm^2""" |
17 | | - |
18 | | - g_L = 0.3 |
19 | | - """Leak maximum conductances, in mS/cm^2""" |
20 | | - |
21 | | - E_Na = 50.0 |
22 | | - """Sodium (Na) Nernst reversal potentials, in mV""" |
23 | | - |
24 | | - E_K = -77.0 |
25 | | - """Postassium (K) Nernst reversal potentials, in mV""" |
26 | | - |
27 | | - E_L = -54.387 |
28 | | - """Leak Nernst reversal potentials, in mV""" |
29 | | - |
30 | | - t = np.arange(0.0, 450.0, 0.01) |
31 | | - """ The time to integrate over """ |
| 9 | + """ __init__ uses optional arguments """ |
| 10 | + """ when no argument is passed default values are used """ |
| 11 | + |
| 12 | + def __init__(self, C_m=1, g_Na=120, g_K=36, g_L=0.3, E_Na=50, E_K=-77, E_L=-54.387, t_0=0, t_n=450, delta_t=0.01): |
| 13 | + |
| 14 | + self.C_m = C_m |
| 15 | + """ membrane capacitance, in uF/cm^2 """ |
| 16 | + |
| 17 | + self.g_Na = g_Na |
| 18 | + """ Sodium (Na) maximum conductances, in mS/cm^2 """ |
| 19 | + |
| 20 | + self.g_K = g_K |
| 21 | + """ Postassium (K) maximum conductances, in mS/cm^2 """ |
| 22 | + |
| 23 | + self.g_L = g_L |
| 24 | + """ Leak maximum conductances, in mS/cm^2 """ |
| 25 | + |
| 26 | + self.E_Na = E_Na |
| 27 | + """ Sodium (Na) Nernst reversal potentials, in mV """ |
| 28 | + |
| 29 | + self.E_K = E_K |
| 30 | + """ Postassium (K) Nernst reversal potentials, in mV """ |
| 31 | + |
| 32 | + self.E_L = E_L |
| 33 | + """ Leak Nernst reversal potentials, in mV """ |
| 34 | + |
| 35 | + self.t = np.arange(t_0, t_n, delta_t) |
| 36 | + """ The time to integrate over """ |
32 | 37 |
|
33 | 38 | def alpha_m(self, V): |
34 | 39 | """Channel gating kinetics. Functions of membrane voltage""" |
@@ -131,32 +136,34 @@ def Main(self): |
131 | 136 | ik = self.I_K(V, n) |
132 | 137 | il = self.I_L(V) |
133 | 138 |
|
134 | | - plt.figure() |
135 | | - |
| 139 | + plt.figure(figsize=[15,10]) |
| 140 | + |
136 | 141 | ax1 = plt.subplot(4,1,1) |
137 | | - plt.title('Hodgkin-Huxley Neuron') |
| 142 | + plt.xlim([np.min(self.t),np.max(self.t)]) #for all subplots |
| 143 | + plt.title('Hodgkin-Huxley Neuron', fontsize = 20) |
138 | 144 | plt.plot(self.t, V, 'k') |
139 | | - plt.ylabel('V (mV)') |
| 145 | + plt.ylabel('V (mV)', fontsize = 15) |
| 146 | + |
140 | 147 |
|
141 | 148 | plt.subplot(4,1,2, sharex = ax1) |
142 | 149 | plt.plot(self.t, ina, 'c', label='$I_{Na}$') |
143 | 150 | plt.plot(self.t, ik, 'y', label='$I_{K}$') |
144 | 151 | plt.plot(self.t, il, 'm', label='$I_{L}$') |
145 | | - plt.ylabel('Current') |
146 | | - plt.legend() |
| 152 | + plt.ylabel('Current', fontsize = 15) |
| 153 | + plt.legend(bbox_to_anchor=(1.1, 0.5),loc='center right', fontsize = 15, borderaxespad=0) |
147 | 154 |
|
148 | 155 | plt.subplot(4,1,3, sharex = ax1) |
149 | 156 | plt.plot(self.t, m, 'r', label='m') |
150 | 157 | plt.plot(self.t, h, 'g', label='h') |
151 | 158 | plt.plot(self.t, n, 'b', label='n') |
152 | | - plt.ylabel('Gating Value') |
153 | | - plt.legend() |
| 159 | + plt.ylabel('Gating Value', fontsize = 15) |
| 160 | + plt.legend(bbox_to_anchor=(1.1, 0.5),loc='center right', fontsize = 15, borderaxespad=0) |
154 | 161 |
|
155 | 162 | plt.subplot(4,1,4, sharex = ax1) |
156 | 163 | i_inj_values = [self.I_inj(t) for t in self.t] |
157 | 164 | plt.plot(self.t, i_inj_values, 'k') |
158 | | - plt.xlabel('t (ms)') |
159 | | - plt.ylabel('$I_{inj}$ ($\\mu{A}/cm^2$)') |
| 165 | + plt.xlabel('t (ms)', fontsize = 15) |
| 166 | + plt.ylabel('$I_{inj}$ ($\\mu{A}/cm^2$)', fontsize = 15) |
160 | 167 | plt.ylim(-1, 40) |
161 | 168 |
|
162 | 169 | plt.tight_layout() |
|
0 commit comments