forked from jwohlwend/SimExm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenConfig.py
170 lines (132 loc) · 4.4 KB
/
genConfig.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
setnumber = 2
channelCounts = [3, 4, 5, 6]
cellCounts = [5, 9, 13]
baseline_noises = [0, 4000, 8000]
protein_noises = [0, 0.1, 0.2]
protein_densities = [1e-6, 1e-7, 1e-8]
expansion_factor = 1.0
cellCount = cellCounts[0]
baseline_noise = baseline_noises[0]
protein_noise = protein_noises[0]
protein_density = protein_densities[0]
gene_copies = 20
fluorophores = ['ATTO488', 'ATTO550', 'ATTO700', 'Alexa790', 'ATTO490LS', 'ATTO647N']
laser_wavelength = [488, 550, 700, 790, 490, 650]
laser_filter = [[475, 550], [550, 630], [630, 720], [720, 900], [450, 550], [600, 700]]
def writeConfigFiles(setnumber, cellCount, channelCount, baseline_noise, protein_noise, protein_density, expansion_factor,
gene_copies, fluorophores, laser_wavelength, laser_filter):
path = "input/set%s/%scells_%sch" % (setnumber, cellCount, channelCount)
groundtruth = """#Ground truth parameters
[groundtruth]
image_path = %s
offset = 49, 0, 0
bounds = 100, 200, 200
format = 'tiff'
gt_cells = 'splitted'
isotropic = False
voxel_dim = 500, 400, 400
gene_copies = %s
[[regions]]
#No additional regions
""" % (path, gene_copies)
layersHeader = """#Labeling parameters
[labeling]
"""
layers = []
for i in range(channelCount):
layer = """
[[layer%s]]
fluorophore = %s
region = 'membrane'
labeling_density = 0.1
protein_density = %s
protein_noise = %s
antibody_amp = 5.0
single_neuron = False
""" % (i+1, fluorophores[i], protein_density, protein_noise)
layers.append(layer)
expansion = """
#Expansion parameters
[expansion]
factor = %s
""" % (expansion_factor)
optics = """
#Optics parameters
[optics]
type = 'confocal'
numerical_aperture = 1.15
refractory_index = 1.33
focal_plane_depth = 500
objective_back_aperture = 1.0
exposure_time = 0.1
objective_efficiency = 0.8
detector_efficiency = 0.6
objective_factor = 40.0
pixel_size = 13500
pinhole_radius = 50.0
baseline_noise = %s
[[channels]]
""" % (baseline_noise)
channels = []
for i in range(channelCount):
channel = """
[[[channel_%s]]]
laser_wavelength = %s
laser_power = 50.0
laser_percentage = 0.25
laser_filter = %s
""" % (i+1, laser_wavelength[i], str(laser_filter[i])[1:-1])
channels.append(channel)
output = """
[output]
name = "set%s/%scells_%sch_%sbn_%spn_%spd_%sef"
path = "output"
format = "tiff"
sim_channels = "merged"
gt_cells = "splitted"
gt_region = "membrane"
""" % (setnumber, cellCount, channelCount, baseline_noise, protein_noise, protein_density, expansion_factor)
filename = "config/bb_%scells_%sch_%sbn_%spn_%spd_%sef.ini" % (cellCount, channelCount, baseline_noise, protein_noise, protein_density, expansion_factor)
# Write config file
file = open(filename, "w")
file.write(groundtruth)
file.write(layersHeader)
for i in range(channelCount):
file.write(layers[i])
file.write(expansion)
file.write(optics)
for i in range(channelCount):
file.write(channels[i])
file.write(output)
file.close()
expansion_factor = 1.0
baseline_noise = baseline_noises[0]
protein_noise = protein_noises[0]
protein_density = protein_densities[0]
for ch in range(len(channelCounts)):
channelCount = channelCounts[ch]
for cC in range(len(cellCounts)):
cellCount = cellCounts[cC]
writeConfigFiles(setnumber, cellCount, channelCount, baseline_noise, protein_noise, protein_density, expansion_factor,
gene_copies, fluorophores, laser_wavelength, laser_filter)
cellCount = cellCounts[1]
for ch in range(len(channelCounts)):
channelCount = channelCounts[ch]
for bn in range(1,len(baseline_noises)):
baseline_noise = baseline_noises[bn]
writeConfigFiles(setnumber, cellCount, channelCount, baseline_noise, protein_noise, protein_density, expansion_factor,
gene_copies, fluorophores, laser_wavelength, laser_filter)
baseline_noise = baseline_noises[0]
for ch in range(len(channelCounts)):
channelCount = channelCounts[ch]
for pn in range(1,len(protein_noises)):
protein_noise = protein_noises[pn]
writeConfigFiles(setnumber, cellCount, channelCount, baseline_noise, protein_noise, protein_density, expansion_factor,
gene_copies, fluorophores, laser_wavelength, laser_filter)
protein_noise = protein_noises[0]
for ch in range(len(channelCounts)):
channelCount = channelCounts[ch]
for pd in range(1,len(protein_densities)):
protein_density = protein_densities[pd]
writeConfigFiles(setnumber, cellCount, channelCount, baseline_noise, protein_noise, protein_density, expansion_factor,
gene_copies, fluorophores, laser_wavelength, laser_filter)