forked from cnr-ibf-pa/olfactory-bulb-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
granules.py
37 lines (27 loc) · 1.07 KB
/
granules.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
ggid2pos = {}
pos2ggid = {}
def init(center, upbnd, dwbnd, d, gid_granule_begin):
# make a list of available granule cells
from misc import Ellipsoid
from math import exp
ggid2pos.clear()
pos2ggid.clear()
up = Ellipsoid(center, upbnd)
dw = Ellipsoid(center, dwbnd)
gindex = 0
for x in range(int((center[0]-upbnd[0]/2)/d)*d-d, int((center[0]+upbnd[0]/2)/d)*d+d+d, d):
for y in range(int((center[1]-upbnd[1]/2)/d)*d-d, int((center[1]+upbnd[1]/2)/d)*d+d+d, d):
for z in range(int((center[2]-upbnd[2]/2)/d)*d-d, int((center[2]+upbnd[2]/2)/d)*d+d+d, d):
p =(x, y, z)
if up.normalRadius(p) < 1.0 and dw.normalRadius(p) >= 1.0: # inside boundaries
ggid = gid_granule_begin+gindex
ggid2pos[ggid] = p
pos2ggid[p] = ggid
gindex += 1
if __name__ == '__main__':
from common import rank
if rank == 0:
import params
with open('../vis/granules.txt', 'w') as fo:
for gid, p in list(params.granules.ggid2pos.items()):
fo.write('%d %d %d %d 0\n'%((gid,)+p))