-
Notifications
You must be signed in to change notification settings - Fork 1
/
HodgkinHuxley.py
527 lines (467 loc) · 20.2 KB
/
HodgkinHuxley.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
0# -*- coding: utf-8 -*-
"""
Created on Mon Feb 17 23:20:51 2020
@author: Sikander
HODGKIN AL, HUXLEY AF. A quantitative description of membrane current and its
application to conduction and excitation in nerve. J Physiol.
1952;117(4):500–544. doi:10.1113/jphysiol.1952.sp004764
C.A.S. Batista, R.L. Viana, S.R. Lopes, A.M. Batista,
Dynamic range in small-world networks of Hodgkin–Huxley neurons with chemical synapses,
Physica A: Statistical Mechanics and its Applications,
Volume 410,2014, Pages 628-640, ISSN 0378-4371,
https://doi.org/10.1016/j.physa.2014.05.069.
https://neuronaldynamics.epfl.ch/online/Ch2.S2.html#Ch2.F3:
-The equilibrium functions x0 for gating variable x=m,n,h given by
x0(V) = a_x(V)/[a_x(V) + B_x(V)]
-Graphically shown in Fig 2.3 and equation shown in boc with title Example: Time Constants, Transition Rates, and Channel Kinetics
-Stimulating current: "In order to explore a more realistic input scenario,
we stimulate the Hodgkin-Huxley model by a time-dependent input current I(t) that is generated by the following procedure.
Every 2 ms, a random number is drawn from a Gaussian distribution with zero mean and standard deviation σ=34μA/cm2.
To get a continuous input current, a linear interpolation was used between the target values."
https://neuronaldynamics.epfl.ch/online/Ch3.S1.html:
-Synapse model
Inhibitory neurons:
-https://www.cell.com/current-biology/pdf/S0960-9822(09)00796-9.pdf: 15% of mammalian coritcal neurons are inhibitory
-https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4405698/; %age measure in mammals is 10-30%, optimal is 30%
-https://www.ncbi.nlm.nih.gov/pubmed/19965761: GABAergic (inhibitory) neurons have "widespread axonal arborizations" i.e. have high out-degree
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4816789/:
-we determined the synaptic conductance per synaptic contact to be 0.77 ± 0.4 nS
https://en.wikipedia.org/wiki/Axon:
-Most individual axons are microscopic in diameter (typically about one micrometer (µm) across).
"""
import random
import math
import numpy as np
import matplotlib.pyplot as plt
import networkx as nx
from scipy.signal import find_peaks
import sys
import pickle as pkl
from mpl_toolkits.mplot3d import Axes3D
from scipy.spatial.distance import cdist
from scipy.optimize import curve_fit
from scipy.integrate import odeint
num = 1#sys.argv[1]
##################################################
dt = 0.001
#MODEL CONSTANTS
Cm = 1.0 #uF/cm^3 : Mean = 0.91, Range = 0.8-1.5
VNa = 55#-115 #mV : Mean = -109, Range = -95 to -119
VK = -77#-72#12 # mV : Mean = 11. Range = 9-14
VL = -65#-49#10.613 # mV : Mean = -11, Range = -4 to -22
gNa = 40#120 #mS/cm^2 : Mean = 80/160, Range = 65-90/120-260
gK = 35#36 #mS/cm^2 : Mean = 34, Range = 26-49
gL = 0.3 #mS/cm^2 : DEfault = 0.3, Range = 0-3, 0-26, 13-50
gC = 0.04 #mS/cm^2 : Default = 0.06, Range = 0-0.33
tau_r = 0.5 #ms : characteristic rise time
tau_d = 8 #ms : characteristic decay time, Default=8
alpha = 6.25 #ms^-1
tau_syn = 100 #ms
Vsyn = 20 #mV
V0 = -20 #mV
Esyn = -75 #mV: use for inhibitory neurons
def alpha_n(Vi):
#return 0.01*(Vi + 50)/(1 - np.exp(-0.1*(Vi + 50)))
return 0.02*(Vi - 25)/(1 - np.exp(-(Vi - 25)/9))
def beta_n(Vi):
#return 0.125*np.exp((Vi+60)/80)
return -0.002*(Vi - 25)/(1 - np.exp((Vi - 25)/9))
def alpha_m(Vi):
#return 0.1*(Vi + 35)/(1 - np.exp(-0.1*(Vi + 35)))
return 0.182*(Vi + 35)/(1 - np.exp(-(Vi + 35)/9))
def beta_m(Vi):
#return 4*np.exp((Vi + 60)/18)
return -0.124*(Vi + 35)/(1 - np.exp((Vi + 35)/9))
def alpha_h(Vi):
#return 0.07*np.exp((Vi + 60)/20)
return 0.25*np.exp(-(Vi + 90)/12)
def beta_h(Vi):
#return 1/(1 + np.exp(-0.1*(Vi +30)))
return 0.25*np.exp((Vi + 62)/6)/np.exp((Vi + 90)/12)
def x0(V, gating): #The equilibrium functions x0 for gating variable x=m,n,h
if gating=='n':
return alpha_n(V)/(alpha_n(V) + beta_n(V))
elif gating=='m':
return alpha_m(V)/(alpha_m(V) + beta_m(V))
elif gating=='h':
return alpha_h(V)/(alpha_h(V) + beta_h(V))
def F(Vpre, theta=0):
return 1/(1 + np.exp(-(Vpre - theta)/2))
def show_x0():
Vi = np.arange(-100,100,0.1)
n0 = x0(Vi, 'n')
m0 = x0(Vi, 'm')
h0 = x0(Vi, 'h')
plt.figure()
plt.plot(Vi, n0, label='n0')
plt.plot(Vi, m0, label='m0')
plt.plot(Vi, h0, label='h0')
plt.axvline(x=-63, color='r', linestyle='--', label='Resting potential')
plt.title("Equilibrium functions of the gating variable")
plt.xlabel("Membrane voltage (mV)")
plt.legend()
plt.show()
def is_square(integer):
root = math.sqrt(integer)
return integer == int(root + 0.5) ** 2
def linear_fit(x, a, b):
return a*x + b
def adjmat(size, p=1, q=1, r=2, dim=2, inhib=0.15, show=True): #CHANGE SO THAT HIGHEST OUT-DEGREE NEURONS ARE INHIBITORY
directed_sw = nx.navigable_small_world_graph(size, p, q, r, dim) #A navigable small-world graph is a directed grid with additional long-range connections that are chosen randomly.
#nx.draw_circular(directed_sw)
aspl = nx.average_shortest_path_length(directed_sw)
acc = nx.average_clustering(directed_sw)
print("Average shortest path length: " + str(aspl))
print("Average clustering coefficient: " + str(acc))
aij = nx.to_numpy_matrix(directed_sw)
#ADDING INHIBTORY NEURONS
if dim == 1:
ind = [j for j in range(size)]
inh = random.sample(ind, k=math.ceil(inhib * size)) #CHANGE SO THAT HIGHEST OUT-DEGREE NEURONS ARE INHIBITORY
elif dim == 2:
ind = [j for j in range(size**2)]
inh = random.sample(ind, k=math.ceil(inhib * size**2)) #CHANGE SO THAT HIGHEST OUT-DEGREE NEURONS ARE INHIBITORY
for i in inh:
aij[i, :] *= -1
if show:
# plt.figure()
plt.matshow(aij)
plt.show()
return aij, aspl, acc #Returns the graph adjacency matrix as a NumPy matrix.
def run(state, t, a, size):
V, n, m, h, r = state
# V = net.V
# n = net.n
# m = net.m
# h = net.h
# r = net.r
INa = gNa*(m**3)*h*(V - VNa)
IK = gK*(n**4)*(V - VK)
IL = gL*(V - VL)
Isyn = gC*(Vsyn - V)*r*a
Isyn = np.asarray(Isyn)
Isyn = Isyn.reshape((size,))
drdt = (1/tau_r - 1/tau_d)*(1 - r)/(1 + np.exp(-V + V0)) - r/tau_d
dVdt = (-INa -IK -IL + Isyn + np.random.normal(0, 3.3))/Cm
dndt = -(alpha_n(V) + beta_n(V))*n + alpha_n(V)
dmdt = -(alpha_m(V) + beta_m(V))*m + alpha_m(V)
dhdt = -(alpha_h(V) + beta_h(V))*h + alpha_h(V)
return dVdt, dndt, dmdt, dhdt, drdt
class HodgkinHuxley():
def __init__(self, size, time):
self.size = size
self.time = time
self.V = np.zeros(size) #Membrane voltage
self.n = np.zeros(size) #K activation var.
self.m = np.zeros(size) #NA activation var.
self.h = np.zeros(size) #Na inactivation var.
self.r = np.zeros(size) #Fraction of bond receptors with presynaptic neurons
self.s = np.zeros(size) #Gating variable represents fraction of docked synaptic neurotransmitters
self.a = np.zeros((size,size)) #Synaptic adjacency matrix
self.Input = np.zeros((size, int(time/dt))) #External input currentn
self.output = np.zeros((size, int(time/dt)))
self.rt = np.zeros((size, int(time/dt)))
self.st = np.zeros((size, int(time/dt)))
self.It = np.zeros((size, int(time/dt)))
self.nt = np.zeros((size, int(time/dt)))
self.mt = np.zeros((size, int(time/dt)))
self.ht = np.zeros((size, int(time/dt)))
def initializeRand(self, gating=False):
self.V = 100*np.random.rand(self.size) - 80 # -63*np.ones(self.size)
if gating:
self.n = np.random.rand(self.size)
self.m = np.random.rand(self.size)
self.h = np.random.rand(self.size)
else:
self.n = x0(self.V, 'n')
self.m = x0(self.V, 'm')
self.h = x0(self.V, 'h')
def initializeEquil(self):
self.V = -63*np.ones(self.size)
self.n = x0(self.V, 'n')
self.m = x0(self.V, 'm')
self.h = x0(self.V, 'h')
def assign_r(self, r):
self.r = r
self.n = x0(self.V, 'n')
self.m = x0(self.V, 'm')
self.h = x0(self.V, 'h')
def assignAdjMat(self, a):
self.a = a
plt.figure()
plt.matshow(a)
plt.show()
def initializeSWNet(self, p, q, r, dim, inhib, show=True):
self.V = 100*np.random.rand(self.size) - 80 # -63*np.ones(self.size)
self.n = x0(self.V, 'n')
self.m = x0(self.V, 'm')
self.h = x0(self.V, 'h')
self.r = ((1/tau_r - 1/tau_d)/(1 + np.exp(-self.V + V0)))/((1/tau_r - 1/tau_d)/(1 + np.exp(-self.V + V0)) + 1/tau_d) #np.random.rand(self.size)
self.s = np.random.rand(self.size)
if dim == 1:
self.a, aspl, acc = adjmat(self.size, p, q, r, dim, inhib, show)
elif dim == 2:
if is_square(self.size):
self.a, aspl, acc = adjmat(int(math.sqrt(self.size)), p, q, r, dim, inhib, show)
else:
raise Exception("Size must be square number if dim = 2")
else:
raise Exception("dim too high, choose dim < 2")
return aspl, acc
def inputCurrent(self, injection_interval=2, num_neurons=2, show=False):
num_injections = int(int(self.time/dt) / int(injection_interval/dt))
t = np.arange(0, self.time, dt)
ind = [j for j in range(self.size)]
inp_ind = random.sample(ind, k=num_neurons)
for i in range(self.Input.shape[0]):
# if i in inp_ind:
t_inj = np.arange(0, duration, injection_interval)
injections = np.random.normal(0, 3.4, size=num_injections)
interp = np.interp(t, t_inj, injections)
self.Input[i, :] = interp
if show:
plt.figure()
for I_i in self.Input:
plt.plot(t, I_i)
plt.title("Input currents")
plt.xlabel("Time (ms)")
plt.ylabel("Current density (μA/cm^2)")
plt.show()
return inp_ind
def step(self, i):
#RECORD CURRENT STATE
INa = gNa*(self.m**3)*self.h*(self.V - VNa)
IK = gK*(self.n**4)*(self.V - VK)
IL = gL*(self.V - VL)
# dsdt = alpha*F(self.V)*(1 - self.s) - self.s/tau_syn
# self.s = dsdt*dt + self.s
Isyn = gC*(Vsyn - self.V)*self.r*self.a #gC*(self.V - Esyn)*self.r*self.a
# Isyn = gC*(self.V - Esyn)*self.s*self.a
Isyn = np.asarray(Isyn)
Isyn = Isyn.reshape((self.size,))
self.It[:, i] = -INa - IK - IL + Isyn + self.Input[:, i]
self.output[:, i] = self.V
self.rt[:, i] = self.r
# self.st[:, i] = self.s
self.nt[:, i] = self.n
self.mt[:, i] = self.m
self.ht[:, i] = self.h
drdt = (1/tau_r - 1/tau_d)*(1 - self.r)/(1 + np.exp(-self.V + V0)) - self.r/tau_d
dVdt = (-INa -IK -IL + Isyn + self.Input[:, i])/Cm
dndt = -(alpha_n(self.V) + beta_n(self.V))*self.n + alpha_n(self.V)
dmdt = -(alpha_m(self.V) + beta_m(self.V))*self.m + alpha_m(self.V)
dhdt = -(alpha_h(self.V) + beta_h(self.V))*self.h + alpha_h(self.V)
self.r = drdt*dt + self.r
self.V = dVdt*dt + self.V
self.n = dndt*dt + self.n
self.m = dmdt*dt + self.m
self.h = dhdt*dt + self.h
def simulate(self):
for t in range(int(self.time/dt)):
self.step(t)
def trace(self, indlst, thresh_lst):
t = np.arange(0,self.time,dt)
plt.figure()
plt.subplot(411)
plt.plot(t, self.output[indlst[0],:], color='k')
plt.axhline(y=thresh_lst[indlst[0]], color='r', linestyle='--')
plt.title("Neuron {0}".format(indlst[0]))
plt.xlabel("Time (ms)")
plt.ylabel("Voltage (mV)")
plt.subplot(412)
plt.plot(t, self.output[indlst[1],:], color='k')
plt.axhline(y=thresh_lst[indlst[1]], color='r', linestyle='--')
plt.title("Neuron {0}".format(indlst[1]))
plt.xlabel("Time (ms)")
plt.ylabel("Voltage (mV)")
plt.subplot(413)
plt.plot(t, self.output[indlst[2],:], color='k')
plt.axhline(y=thresh_lst[indlst[2]], color='r', linestyle='--')
plt.title("Neuron {0}".format(indlst[2]))
plt.xlabel("Time (ms)")
plt.ylabel("Voltage (mV)")
plt.subplot(414)
plt.plot(t, self.output[indlst[3],:], color='k')
plt.axhline(y=thresh_lst[indlst[3]], color='r', linestyle='--')
plt.title("Neuron {0}".format(indlst[3]))
plt.xlabel("Time (ms)")
plt.ylabel("Voltage (mV)")
plt.tight_layout()
plt.show()
# if len(indlst) != row*col:
# raise Exception("Number of neurons doesn't match rows and columns")
# fig, ax = plt.subplots(row, col)
# for i in range(len(indlst)):
# ax[i//row, i%col].plot(t, self.output[i,:])
# ax[i//row, i%col].set_title("Neuron {0}".format(i))
# ax[i//row, i%col].set_xlabel("Time (ms)")
# ax[i//row, i%col].set_ylabel("Voltage (mV)")
# plt.tight_layout()
# plt.show()
def show_r(self):
plt.figure()
t = np.arange(0,self.time,dt)
for r in self.rt:
plt.plot(t, r)
plt.title("r_ij(t)")
plt.xlabel("Time (ms)")
plt.show()
# def show_s(self):
# plt.figure()
# t = np.arange(0,self.time,dt)
# for r in self.rt:
# plt.plot(t, r)
# plt.title("s_ij(t)")
# plt.xlabel("Time (ms)")
# plt.show()
def showOutput(self):
#Display spikes as well
plt.figure()
t = np.arange(0,self.time,dt)
for v in self.output:
plt.plot(t, v)
plt.title("V_i(t)")
plt.xlabel("Time (ms)")
plt.ylabel("Voltage (mV)")
plt.show()
def showCurrent(self):
#Display spikes as well
plt.figure()
t = np.arange(0,self.time,dt)
for Ii in self.It:
plt.plot(t[500:], Ii[500:])
plt.title("I_i(t)")
plt.xlabel("Time (ms)")
plt.ylabel("Current (nA)")
plt.show()
def findSpikes(self, hertz=5000, save=False, show=False):
peaks = {}
neuron = 0
threshlst = []
tau_u = []
tau_l = []
delta = 0
for o in self.output:
thresh = np.mean(o) + 2*np.std(o)
threshlst.append(thresh)
pks_ni = find_peaks(o, height=thresh) #Peaks of neuron i
peaks[neuron] = pks_ni[0]
ps = np.array(pks_ni[0])*dt
taus = np.diff(ps)
# print(ps, taus)
tau_u.append(max(taus))
tau_l.append(min(taus))
neuron += 1
delta = 10*math.log10(max(tau_u)/min(tau_l))
print("delta = " + str(delta))
binsize = int(1000/hertz/dt)
samples = int(self.time/dt/binsize)
boolean_output = np.zeros((self.size, samples))
for node in peaks:
for spike in peaks[node]:
boolean_output[node, spike//binsize] = 1
if show:
p = []
for nd in peaks:
pk_times = peaks[nd]*dt
p.append(pk_times)
plt.figure()
# plt.eventplot(p, color=[0,0,0])
for nd in peaks:
plt.scatter(p[nd], [nd]*len(p[nd]), marker='o', color='k', alpha=0.5)
plt.title("Raster Plot")
plt.xlabel("Time (ms)")
plt.ylabel("Neuron")
plt.show()
if save:
plt.savefig("n{0}_t{1}_rasterplot_{2}.png".format(self.size, self.time, num))
np.save('n{0}_t{1}_boolean_output_{2}.npy'.format(self.size, self.time, num), boolean_output)
return peaks, boolean_output, threshlst, delta
def showNeuronStateSpace(self, neuron): #, dim1, dim2, dim3, x, y,
fig = plt.figure()
# ax = fig.add_subplot(111, projection='3d')
# ax.plot3D(dim1[neuron,:], dim2[neuron,:], dim3[neuron,:], c='green')
# ax.set_xlabel(x)
# ax.set_ylabel(y)
# ax.set_zlabel(z)
# ax.set_title("Neuron {0} State Space".format(neuron))
plt.suptitle("Neuron {0} State Space".format(neuron), size=24)
ax1 = fig.add_subplot(231, projection='3d')
ax1.plot3D(self.nt[neuron,:], self.mt[neuron,:], self.output[neuron,:], c='green')
ax1.set_xlabel('n')
ax1.set_ylabel('m')
ax1.set_zlabel('V')
ax2 = fig.add_subplot(232, projection='3d')
ax2.plot3D(self.nt[neuron,:], self.ht[neuron,:], self.output[neuron,:], c='brown')
ax2.set_xlabel('n')
ax2.set_ylabel('h')
ax2.set_zlabel('V')
ax3 = fig.add_subplot(233, projection='3d')
ax3.plot3D(self.mt[neuron,:], self.ht[neuron,:], self.output[neuron,:], c='gray')
ax3.set_xlabel('m')
ax3.set_ylabel('h')
ax3.set_zlabel('V')
ax4 = fig.add_subplot(234, projection='3d')
ax4.plot3D(self.nt[neuron,:], self.rt[neuron,:], self.output[neuron,:], c='blue')
ax4.set_xlabel('n')
ax4.set_ylabel('r')
ax4.set_zlabel('V')
ax5 = fig.add_subplot(235, projection='3d')
ax5.plot3D(self.mt[neuron,:], self.rt[neuron,:], self.output[neuron,:], c='orange')
ax5.set_xlabel('m')
ax5.set_ylabel('r')
ax5.set_zlabel('V')
ax6 = fig.add_subplot(236, projection='3d')
ax6.plot3D(self.ht[neuron,:], self.rt[neuron,:], self.output[neuron,:], c='black')
ax6.set_xlabel('h')
ax6.set_ylabel('r')
ax6.set_zlabel('V')
def corr_dim(self, neuron, max_ep, show=False): #Correlation dimension of a neuron - https://en.wikipedia.org/wiki/Correlation_dimension
ep_range = np.arange(np.e, max_ep, max_ep/100)
# t = np.arange(0,self.time,dt)
state_vec = np.zeros((self.time, 5))
for i in range(int(self.time/dt) - 1):
if i%1000 == 0:
state_vec[int(i/1000),0] = self.output[neuron,i]
state_vec[int(i/1000),1] = 100*self.nt[neuron,i]
state_vec[int(i/1000),2] = 100*self.mt[neuron,i]
state_vec[int(i/1000),3] = 100*self.ht[neuron,i]
state_vec[int(i/1000),4] = 100*self.rt[neuron,i]
cnt_lst = []
for epsilon in ep_range:
dist = cdist(state_vec, state_vec)
# print(len(np.where(dist < epsilon)))
cnt = len(dist[dist < epsilon])
cnt_lst.append(cnt)
cnts = np.array(cnt_lst)/self.time**2
popt, pcov = curve_fit(linear_fit, np.log(ep_range), np.log(np.array(cnts)))
if show:
plt.figure()
plt.scatter(np.log(ep_range), np.log(np.array(cnts)))
# C = np.polyfit(np.log(ep_range), np.log(np.array(cnt_lst)), 1)
# Cline = C[0]*np.log(ep_range) + C[1]
print(popt)
plt.plot(np.log(ep_range), linear_fit(np.log(ep_range), *popt), '--', color='r')
plt.title("Correlation dimension (log-log), \u03BD = {0}".format(round(popt[0], 4)))
plt.xlabel("log(\u03B5)")
plt.ylabel("log(C(\u03B5))")
netsize = 24#int(sys.argv[2])
duration = 1500#float(sys.argv[3])
inhibitory = 0.3#float(sys.argv[4])
if __name__=='__main__':
hh = HodgkinHuxley(netsize, duration)
aspl, acc = hh.initializeSWNet(p=2, q=1, r=0.5, dim=1, inhib=inhibitory, show=True)
## np.save("n{0}_t{1}_adjmat_{2}.npy".format(hh.size, hh.time, num), hh.a)
## net_stats = {"Fraction inhibitory": inhibitory, "Avg. shortest path length": aspl, "Avg. clestering coeff.": acc}
## pkl.dump(net_stats, open("n{0}_t{1}_netstats_{2}.pkl".format(hh.size, hh.time, num), 'wb'))
#
inp_ind = hh.inputCurrent()
hh.simulate()
# #show_x0()
## hh.showOutput()
## hh.show_r()
## hh.showCurrent()
peaks, out, thresh_lst, delta = hh.findSpikes(hertz=5000, save=False, show=True)
# np.save("n{0}_t{1}_neuron_voltages_{2}.npy".format(hh.size, hh.time, num), hh.output)
# np.save("n{0}_t{1}_peaks_{2}.npy".format(hh.size, hh.time, num), peaks)
# np.save("n{0}_t{1}_thresh_lst_{2}.npy".format(hh.size, hh.time, num), np.array(thresh_lst))