forked from cnr-ibf-pa/olfactory-bulb-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bulbdef_llb.py
115 lines (92 loc) · 3.24 KB
/
bulbdef_llb.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
# Olfactory Bulb space and boundary surfaces
import params_llb
#all_dict = {
# "bulb_center" : (50.0, 1275.0, 0.0),
# "bulb_axis" : (2100.0, 2800.0, 2100.0),
# "glom_axis" : (2400.0, 3100.0, 2400.0),
# "gran_bnd_up" : (1400.0, 2100.0, 1400.0),
# "gran_bnd_dw" : (600.0, 1300.0, 600.0),
# "mid_tufted_dw" : (1875.0, 2500.0, 1875.0),
# "glom_radius" : 50.0,
# "gran_voxel" : 18,
# "gran_radius" : 5.0,
#}
# granules parameters
# This value changes the number of granules that will be generated
# the GCL volume is approximately 1910088333.383 (um^3)
# so the number of granules filling the GCL is volume/(grid_dim^3)
#gran_voxel = 18
#gran_radius = 5.0
#gran_connect_radius = 60.0
#gran_type_slope = 10.0
# load glomeruli positions
#glom_coord = []
#with open('./realgloms.txt', 'r') as f:
# l = f.readline()
# while l:
# tk = l.split()
# p = ()
# for _tk in tk:
# p += (float(_tk), )
# glom_coord.append(p)
# l = f.readline()
#glom_coord = glom_coord[:127]
# cell numbers
#Ngloms = len(glom_coord) # glomeruli
# mitral
#gid_mitral_begin = 0
#Nmitral_per_glom = 5 # mitral per glomerolus
#Nmitral = Ngloms * Nmitral_per_glom
# middle tufted
#gid_mtufted_begin = gid_mitral_begin+Nmitral
#Nmtufted_per_glom = 2*Nmitral_per_glom # twice than mitral!
#Nmtufted = Ngloms * Nmtufted_per_glom
#aid_granule_begin = gid_mtufted_begin + Nmtufted
import granules
granules.init(params_llb.bulbCenter, params_llb.granAxisUp, params_llb.granAxisDw, params_llb.gran_voxel, params_llb.gid_granule_begin)
#granules.init()
#Ngranule = len(granules.ggid2pos)
#gid_blanes_begin = gid_granule_begin+Ngranule
#NBlanes_per_glom = 3
#NBlanes = Ngloms*NBlanes_per_glom
#gid_mbs_begin = gid_blanes_begin+NBlanes
#gid_bc2gc_begin = gid_mbs_begin+Nmtufted*NBlanes
# reciprocal synapse
#gid_mgrs_begin = gid_bc2gc_begin+NBlanes*Ngranule
#if gid_mgrs_begin % 2 != 0:
# gid_mgrs_begin += 1
def gid_is_mitral(gid):
return gid >= params_llb.gid_mitral_begin and gid < params_llb.gid_mitral_begin+params_llb.Nmitral
def gid_is_mtufted(gid):
return gid >= params_llb.gid_mtufted_begin and gid < params_llb.gid_mtufted_begin+params_llb.Nmtufted
def gid_is_granule(gid):
return gid >= params_llb.gid_granule_begin and gid < params_llb.gid_granule_begin+params_llb.Ngranule
def gid_is_blanes(gid):
return gid >= params_llb.gid_blanes_begin and gid < params_llb.gid_blanes_begin+params_llb.NBlanes
''' useful only for mitral and tufted cells'''
def cellid2glomid(cgid):
if cgid < params_llb.Nmitral:
return cgid/params_llb.Nmitral_per_glom
elif cgid < params_llb.gid_mtufted_begin+params_llb.Nmtufted:
return (cgid-params_llb.gid_mtufted_begin)/params_llb.Nmtufted_per_glom
return None
''' reciprocal synapses id to cells '''
def rs2cell_gid(gid):
gid -= params_llb.gid_mgrs_begin
if gid % 2:
gid -= 1
example.py
gidtarget = int(gid / (2*params_llb.Ngloms))
gidsrc = gid % (2*params_llb.Ngloms)
return gidsrc, gidtarget
''' cell id to rs '''
def cell2rs_gid(gidsrc, gidtarget):
if gidsrc > gidtarget: # ggid and m/t gid inverted
aux = gidsrc
gidsrc = gidtarget
gidtarget = aux
print('auu')
slot = -1
else:
slot = 0
return gid_mgrs_begin + slot + 2 * (gidtarget * Ngloms + cellid2glomid(gidsrc))