-
Notifications
You must be signed in to change notification settings - Fork 6
/
ranparm.py
52 lines (44 loc) · 1.43 KB
/
ranparm.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
# proportionally randomize all range parameters, weights, delays ...
# exception is HalfGap.g which must be symetric
from neuron import h
pc = h.ParallelContext()
def cellran(gid, nclist):
r = h.Random()
r.Random123(gid)
r.uniform(1.0, 1.1)
cell = pc.gid2cell(gid)
for sec in cell.all:
sec.L *= r.repick()
for seg in sec:
seg.diam *= r.repick()
seg.cm *= r.repick()
#print 'diam ', seg.diam, 'cm ', seg.cm
#mechanism variables
for mech in seg:
ms = h.MechanismStandard(mech.name(), 1)
for i in range(int(ms.count())):
varname = h.ref("")
sz = ms.name(varname, i)
n = varname[0]
x = seg.__getattribute__(n)
setattr(seg, n, x * r.repick())
#print n, seg.__getattribute__(n)
#point process parameters
for p in seg.point_processes():
n = p.hname()
n = n[:n.index('[')]
if n == 'HalfGap':
continue
ms = h.MechanismStandard(n, 1)
for i in range(int(ms.count())):
varname = h.ref("")
ms.name(varname, i)
x = p.__getattribute__(varname[0])
setattr(p, varname[0], x * r.repick())
#print varname[0], p.__getattribute__(varname[0])
#netcons targeting the cell
for nc in nclist:
if nc.postcell() == cell:
nc.weight[0] *= r.repick()
nc.delay *= r.repick()
pc.threshold(gid, pc.threshold(gid) + r.uniform(-9, 0))