AMS-BP 0.3.0__py3-none-any.whl → 0.4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- AMS_BP/__init__.py +1 -1
- AMS_BP/configio/configmodels.py +32 -18
- AMS_BP/configio/convertconfig.py +508 -632
- AMS_BP/gui/README.md +77 -0
- AMS_BP/gui/__init__.py +0 -0
- AMS_BP/gui/assets/__init__.py +0 -0
- AMS_BP/gui/assets/drawing.svg +107 -0
- AMS_BP/gui/configuration_window.py +333 -0
- AMS_BP/gui/help_docs/__init__.py +0 -0
- AMS_BP/gui/help_docs/cell_help.md +45 -0
- AMS_BP/gui/help_docs/channels_help.md +78 -0
- AMS_BP/gui/help_docs/condensate_help.md +59 -0
- AMS_BP/gui/help_docs/detector_help.md +57 -0
- AMS_BP/gui/help_docs/experiment_help.md +92 -0
- AMS_BP/gui/help_docs/fluorophore_help.md +128 -0
- AMS_BP/gui/help_docs/general_help.md +43 -0
- AMS_BP/gui/help_docs/global_help.md +47 -0
- AMS_BP/gui/help_docs/laser_help.md +76 -0
- AMS_BP/gui/help_docs/molecule_help.md +78 -0
- AMS_BP/gui/help_docs/output_help.md +5 -0
- AMS_BP/gui/help_docs/psf_help.md +51 -0
- AMS_BP/gui/help_window.py +26 -0
- AMS_BP/gui/logging_window.py +93 -0
- AMS_BP/gui/main.py +255 -0
- AMS_BP/gui/sim_worker.py +58 -0
- AMS_BP/gui/template_window_selection.py +100 -0
- AMS_BP/gui/widgets/__init__.py +0 -0
- AMS_BP/gui/widgets/camera_config_widget.py +213 -0
- AMS_BP/gui/widgets/cell_config_widget.py +225 -0
- AMS_BP/gui/widgets/channel_config_widget.py +307 -0
- AMS_BP/gui/widgets/condensate_config_widget.py +341 -0
- AMS_BP/gui/widgets/experiment_config_widget.py +259 -0
- AMS_BP/gui/widgets/flurophore_config_widget.py +513 -0
- AMS_BP/gui/widgets/general_config_widget.py +47 -0
- AMS_BP/gui/widgets/global_config_widget.py +142 -0
- AMS_BP/gui/widgets/laser_config_widget.py +255 -0
- AMS_BP/gui/widgets/molecule_config_widget.py +714 -0
- AMS_BP/gui/widgets/output_config_widget.py +61 -0
- AMS_BP/gui/widgets/psf_config_widget.py +128 -0
- AMS_BP/gui/widgets/utility_widgets/__init__.py +0 -0
- AMS_BP/gui/widgets/utility_widgets/scinotation_widget.py +21 -0
- AMS_BP/gui/widgets/utility_widgets/spectrum_widget.py +115 -0
- AMS_BP/logging/__init__.py +0 -0
- AMS_BP/logging/logutil.py +83 -0
- AMS_BP/logging/setup_run_directory.py +35 -0
- AMS_BP/{run_cell_simulation.py → main_cli.py} +27 -72
- AMS_BP/optics/filters/filters.py +2 -0
- AMS_BP/resources/template_configs/metadata_configs.json +20 -0
- AMS_BP/resources/template_configs/sim_config.toml +408 -0
- AMS_BP/resources/template_configs/twocolor_widefield_timeseries_live.toml +399 -0
- AMS_BP/resources/template_configs/twocolor_widefield_zstack_fixed.toml +406 -0
- AMS_BP/resources/template_configs/twocolor_widefield_zstack_live.toml +408 -0
- AMS_BP/run_sim_util.py +76 -0
- AMS_BP/sim_microscopy.py +2 -2
- {ams_bp-0.3.0.dist-info → ams_bp-0.4.0.dist-info}/METADATA +59 -34
- ams_bp-0.4.0.dist-info/RECORD +103 -0
- ams_bp-0.4.0.dist-info/entry_points.txt +2 -0
- ams_bp-0.3.0.dist-info/RECORD +0 -55
- ams_bp-0.3.0.dist-info/entry_points.txt +0 -2
- {ams_bp-0.3.0.dist-info → ams_bp-0.4.0.dist-info}/WHEEL +0 -0
- {ams_bp-0.3.0.dist-info → ams_bp-0.4.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,408 @@
|
|
1
|
+
version = "0.2"
|
2
|
+
length_unit = "um" # always um.
|
3
|
+
time_unit = "ms" # always ms
|
4
|
+
diffusion_unit = "um^2/s" # always um^2/s
|
5
|
+
|
6
|
+
[Cell_Parameters]
|
7
|
+
cell_type = "RodCell" # any of RectangularCell, SphericalCell, OvoidCell, RodCell, BuddingCell
|
8
|
+
[Cell_Parameters.params] # see docs for parameters for each cell type
|
9
|
+
center = [5, 5, 0]
|
10
|
+
direction = [1, 0, 0]
|
11
|
+
radius = 1.0
|
12
|
+
height = 4.0
|
13
|
+
# bounds = [[3, 7], [3, 9], [-1, 1]]
|
14
|
+
|
15
|
+
[Molecule_Parameters]
|
16
|
+
num_molecules = [
|
17
|
+
5000,
|
18
|
+
5000,
|
19
|
+
] # size of array tells the types of molecules (must be same as num_of_fluorophores below). All of the Molecule_Parameters are of the same first dimension as this.
|
20
|
+
track_type = ["fbm", "fbm"] # "constant", "fbm"
|
21
|
+
diffusion_coefficient = [
|
22
|
+
[
|
23
|
+
0.2,
|
24
|
+
0.4,
|
25
|
+
],
|
26
|
+
[
|
27
|
+
0.2,
|
28
|
+
0.4,
|
29
|
+
],
|
30
|
+
] # um^2/s, size of each index (eg. len(...[0]) is the # of diffusion coefficients the system can explore.
|
31
|
+
|
32
|
+
hurst_exponent = [[0.5], [0.5]]
|
33
|
+
allow_transition_probability = [true, true] # bool
|
34
|
+
transition_matrix_time_step = [
|
35
|
+
20,
|
36
|
+
20,
|
37
|
+
] # ms, the time at which the probabilities in the below are presented.
|
38
|
+
diffusion_transition_matrix = [
|
39
|
+
[
|
40
|
+
[
|
41
|
+
0.992,
|
42
|
+
0.008,
|
43
|
+
],
|
44
|
+
[
|
45
|
+
0.0273,
|
46
|
+
0.9727,
|
47
|
+
],
|
48
|
+
],
|
49
|
+
[
|
50
|
+
[
|
51
|
+
0.992,
|
52
|
+
0.008,
|
53
|
+
],
|
54
|
+
[
|
55
|
+
0.0273,
|
56
|
+
0.9727,
|
57
|
+
],
|
58
|
+
],
|
59
|
+
]
|
60
|
+
hurst_transition_matrix = [[[0.1]], [[0.1]]]
|
61
|
+
state_probability_diffusion = [[0.5, 0.5], [0.5, 0.5]]
|
62
|
+
state_probability_hurst = [[1], [1]]
|
63
|
+
|
64
|
+
|
65
|
+
[Global_Parameters]
|
66
|
+
sample_plane_dim = [10, 10] # um
|
67
|
+
cycle_count = 50 # cycles of exposure_time + interval_time
|
68
|
+
exposure_time = 20 # ms
|
69
|
+
interval_time = 0 # ms
|
70
|
+
oversample_motion_time = 20 # ms
|
71
|
+
|
72
|
+
[Condensate_Parameters]
|
73
|
+
initial_centers = [
|
74
|
+
[
|
75
|
+
[
|
76
|
+
5.5,
|
77
|
+
5,
|
78
|
+
0.05,
|
79
|
+
],
|
80
|
+
[
|
81
|
+
5,
|
82
|
+
5,
|
83
|
+
-0.15,
|
84
|
+
],
|
85
|
+
[
|
86
|
+
4,
|
87
|
+
5,
|
88
|
+
-0.15,
|
89
|
+
],
|
90
|
+
[
|
91
|
+
6,
|
92
|
+
5.5,
|
93
|
+
-0.15,
|
94
|
+
],
|
95
|
+
[
|
96
|
+
6,
|
97
|
+
5.5,
|
98
|
+
-0.15,
|
99
|
+
],
|
100
|
+
],
|
101
|
+
[
|
102
|
+
[
|
103
|
+
4,
|
104
|
+
5,
|
105
|
+
0.05,
|
106
|
+
],
|
107
|
+
[
|
108
|
+
3,
|
109
|
+
5,
|
110
|
+
-0.15,
|
111
|
+
],
|
112
|
+
],
|
113
|
+
] # um. First dimension is the types of molecules as in Molecule Parameters.num_molecules. second dimension is the # of condentates. center = [x,y,z]
|
114
|
+
initial_scale = [[0.26, 0.26, 0.13, 0.13, 0.26], [0.26, 0.26]] # um
|
115
|
+
diffusion_coefficient = [[0, 0, 0, 0, 0], [0, 0]] # um^2/s
|
116
|
+
hurst_exponent = [[0.2, 0.2, 0.2, 0.2, 0.2], [0.2, 0.2]]
|
117
|
+
density_dif = [10, 10] # density of the condensate vs the background.
|
118
|
+
|
119
|
+
[Output_Parameters]
|
120
|
+
output_path = "Output"
|
121
|
+
output_name = "Cell_Movie_001"
|
122
|
+
subsegment_type = "mean" # not implemented yet, use any string
|
123
|
+
subsegment_number = 5 # not implemented yet, use any integer
|
124
|
+
|
125
|
+
|
126
|
+
[fluorophores]
|
127
|
+
num_of_fluorophores = 2
|
128
|
+
fluorophore_names = ["PAmCherry", "EGFP"]
|
129
|
+
|
130
|
+
# PAmCherry name
|
131
|
+
[fluorophores.PAmCherry]
|
132
|
+
name = "PAmCherry"
|
133
|
+
initial_state = "dark" # flurophore will start with this state in the simulation (all of them), must be valid name from ones provided below.
|
134
|
+
|
135
|
+
# States definition
|
136
|
+
[fluorophores.PAmCherry.states.bright]
|
137
|
+
name = "bright"
|
138
|
+
state_type = "fluorescent" # any of fluorescent, dark, bleached
|
139
|
+
quantum_yield = 0.46 # from 0-1
|
140
|
+
extinction_coefficient = 18000 # M^-1 cm^-1
|
141
|
+
fluorescent_lifetime = 0.000000001 # seconds
|
142
|
+
# Spectral data for bright state
|
143
|
+
[fluorophores.PAmCherry.states.bright.excitation_spectrum]
|
144
|
+
wavelengths = [310.0, 311.0, 411.0, 511.0, 611.0, 612.0]
|
145
|
+
intensities = [0.00, 0.047, 0.0043, 0.6, 0.06, 0.00]
|
146
|
+
[fluorophores.PAmCherry.states.bright.emission_spectrum]
|
147
|
+
wavelengths = [530.0, 529.0, 600.0, 650.0, 700.0, 797.0, 799.0]
|
148
|
+
intensities = [0.00, 0.02, 0.98, 0.28, 0.05, 0.003, 0.00]
|
149
|
+
|
150
|
+
[fluorophores.PAmCherry.states.dark]
|
151
|
+
name = "dark"
|
152
|
+
state_type = "dark"
|
153
|
+
|
154
|
+
[fluorophores.PAmCherry.states.triplet]
|
155
|
+
name = "triplet"
|
156
|
+
state_type = "dark"
|
157
|
+
|
158
|
+
[fluorophores.PAmCherry.states.bleached]
|
159
|
+
name = "bleached"
|
160
|
+
state_type = "bleached"
|
161
|
+
|
162
|
+
# State transitions
|
163
|
+
|
164
|
+
[fluorophores.PAmCherry.transitions.dark_to_bright]
|
165
|
+
from_state = "dark"
|
166
|
+
to_state = "bright"
|
167
|
+
photon_dependent = true
|
168
|
+
[fluorophores.PAmCherry.transitions.dark_to_bright.spectrum]
|
169
|
+
wavelengths = [308.0, 309.0, 359.0, 403.0, 440.0, 484.0, 485.0]
|
170
|
+
intensities = [0.00, 0.04, 0.11, 1.0, 0.07, 0.0004, 0.00]
|
171
|
+
extinction_coefficient = 6500 # M^-1 cm^-1
|
172
|
+
quantum_yield = 0.000005 # switching events per photons absorbed
|
173
|
+
|
174
|
+
|
175
|
+
[fluorophores.PAmCherry.transitions.bright_to_bleached]
|
176
|
+
from_state = "bright"
|
177
|
+
to_state = "bleached"
|
178
|
+
photon_dependent = true
|
179
|
+
[fluorophores.PAmCherry.transitions.bright_to_bleached.spectrum]
|
180
|
+
wavelengths = [310.0, 311.0, 411.0, 511.0, 611.0, 612.0]
|
181
|
+
intensities = [0.00, 0.047, 0.0043, 0.6, 0.06, 0.00]
|
182
|
+
extinction_coefficient = 18000 # M^-1 cm^-1
|
183
|
+
quantum_yield = 0.000005 # switching events per photons absorbed
|
184
|
+
|
185
|
+
[fluorophores.PAmCherry.transitions.bright_to_triplet]
|
186
|
+
from_state = "bright"
|
187
|
+
to_state = "triplet"
|
188
|
+
photon_dependent = false
|
189
|
+
base_rate = 1 # 1/s
|
190
|
+
|
191
|
+
[fluorophores.PAmCherry.transitions.triplet_to_dark]
|
192
|
+
from_state = "triplet"
|
193
|
+
to_state = "dark"
|
194
|
+
photon_dependent = false
|
195
|
+
base_rate = 1 # 1/s
|
196
|
+
|
197
|
+
|
198
|
+
# EGFP name
|
199
|
+
[fluorophores.EGFP]
|
200
|
+
name = "EGFP"
|
201
|
+
initial_state = "bright" # flurophore will start with this state in the simulation (all of them), must be valid name from ones provided below.
|
202
|
+
|
203
|
+
# States definition
|
204
|
+
[fluorophores.EGFP.states.bright]
|
205
|
+
name = "bright"
|
206
|
+
state_type = "fluorescent" # any of fluorescent, dark, bleached
|
207
|
+
quantum_yield = 0.6 # from 0-1
|
208
|
+
extinction_coefficient = 55900 # M^-1 cm^-1
|
209
|
+
fluorescent_lifetime = 0.0000000026 # seconds
|
210
|
+
# Spectral data for bright state
|
211
|
+
[fluorophores.EGFP.states.bright.excitation_spectrum]
|
212
|
+
wavelengths = [300.0, 337.0, 488.0, 501.0, 522.0, 540.0]
|
213
|
+
intensities = [0.1, 0.03, 1.00, 0.69, 0.03, 0.00]
|
214
|
+
[fluorophores.EGFP.states.bright.emission_spectrum]
|
215
|
+
wavelengths = [463.0, 494.0, 503.0, 510.0, 528.0, 549.0, 700.0]
|
216
|
+
intensities = [0.00, 0.33, 0.82, 1.00, 0.51, 0.30, 0.00]
|
217
|
+
|
218
|
+
|
219
|
+
[fluorophores.EGFP.states.triplet]
|
220
|
+
name = "triplet"
|
221
|
+
state_type = "dark"
|
222
|
+
|
223
|
+
[fluorophores.EGFP.states.bleached]
|
224
|
+
name = "bleached"
|
225
|
+
state_type = "bleached"
|
226
|
+
|
227
|
+
# State transitions
|
228
|
+
[fluorophores.EGFP.transitions.bright_to_bleached]
|
229
|
+
from_state = "bright"
|
230
|
+
to_state = "bleached"
|
231
|
+
photon_dependent = true
|
232
|
+
[fluorophores.EGFP.transitions.bright_to_bleached.spectrum]
|
233
|
+
wavelengths = [300.0, 337.0, 488.0, 501.0, 522.0, 540.0]
|
234
|
+
intensities = [0.1, 0.03, 1.00, 0.69, 0.03, 0.00]
|
235
|
+
extinction_coefficient = 55900 # M^-1 cm^-1
|
236
|
+
quantum_yield = 0.0000025 # switching events per photons absorbed
|
237
|
+
|
238
|
+
[fluorophores.EGFP.transitions.bright_to_triplet]
|
239
|
+
from_state = "bright"
|
240
|
+
to_state = "triplet"
|
241
|
+
photon_dependent = true
|
242
|
+
[fluorophores.EGFP.transitions.bright_to_triplet.spectrum]
|
243
|
+
wavelengths = [300.0, 337.0, 488.0, 501.0, 522.0, 540.0]
|
244
|
+
intensities = [0.1, 0.03, 1.00, 0.69, 0.03, 0.00]
|
245
|
+
extinction_coefficient = 55900 # M^-1 cm^-1
|
246
|
+
quantum_yield = 0.0000025 # switching events per photons absorbed
|
247
|
+
|
248
|
+
[fluorophores.EGFP.transitions.triplet_to_bleached]
|
249
|
+
from_state = "triplet"
|
250
|
+
to_state = "bleached"
|
251
|
+
photon_dependent = false
|
252
|
+
base_rate = 1 # 1/s
|
253
|
+
|
254
|
+
|
255
|
+
# PSF Configuration
|
256
|
+
|
257
|
+
[psf]
|
258
|
+
# PSF type: "gaussian"
|
259
|
+
type = "gaussian"
|
260
|
+
|
261
|
+
# If type is "custom", specify the path to the PSF file # not supported currently
|
262
|
+
custom_path = ""
|
263
|
+
|
264
|
+
[psf.parameters]
|
265
|
+
numerical_aperture = 1.4 # typical range: 0.1 - 1.5
|
266
|
+
refractive_index = 1.0 # default is air (1.0)
|
267
|
+
#pinhole_diameter = 1.0 # Do not include for no pinhole else float in um units
|
268
|
+
|
269
|
+
# Multiple Laser Configuration File
|
270
|
+
|
271
|
+
[lasers]
|
272
|
+
active = ["red", "blue"] # List of active lasers provided in setup
|
273
|
+
|
274
|
+
[lasers.red]
|
275
|
+
type = "widefield" # "gaussian" or "hilo" or "widefield"
|
276
|
+
preset = "red_633" # description
|
277
|
+
|
278
|
+
[lasers.red.parameters]
|
279
|
+
power = 50000 # Power in watts
|
280
|
+
wavelength = 600 # Wavelength in nanometers
|
281
|
+
beam_width = 5.0 # 1/e² beam width at waist in microns
|
282
|
+
numerical_aperture = 1.4 # NA of focusing lens
|
283
|
+
refractive_index = 1.518
|
284
|
+
inclination_angle = 67.0 # degrees, only for HiLo
|
285
|
+
|
286
|
+
[lasers.blue]
|
287
|
+
type = "widefield"
|
288
|
+
preset = "blue_405"
|
289
|
+
|
290
|
+
[lasers.blue.parameters]
|
291
|
+
power = 5
|
292
|
+
wavelength = 405
|
293
|
+
beam_width = 5.0
|
294
|
+
numerical_aperture = 1.4
|
295
|
+
refractive_index = 1.518
|
296
|
+
|
297
|
+
|
298
|
+
[channels]
|
299
|
+
num_of_channels = 2
|
300
|
+
channel_names = ["red", "green"]
|
301
|
+
split_efficiency = [
|
302
|
+
1.0,
|
303
|
+
1.0,
|
304
|
+
] # 1.0 is 100% efficiency. Physically represents the efficiency of the channel splitter for each channel. max: 1.0 = equal to the original emission light.
|
305
|
+
# Filter Set Configuration
|
306
|
+
[channels.filters]
|
307
|
+
[channels.filters.red] # .red , .green etc, must be of channel_name.
|
308
|
+
filter_set_name = "Red Filter Set"
|
309
|
+
filter_set_description = "Sample Red filter set configuration"
|
310
|
+
|
311
|
+
[channels.filters.red.excitation]
|
312
|
+
name = "Red-Ex"
|
313
|
+
type = "allow_all"
|
314
|
+
points = 100
|
315
|
+
|
316
|
+
[channels.filters.red.emission]
|
317
|
+
name = "Red-Em"
|
318
|
+
type = "bandpass"
|
319
|
+
center_wavelength = 600 # nm
|
320
|
+
bandwidth = 35 # nm
|
321
|
+
transmission_peak = 0.95
|
322
|
+
points = 1000
|
323
|
+
|
324
|
+
[channels.filters.green]
|
325
|
+
filter_set_name = "Green Filter Set"
|
326
|
+
filter_set_description = "Sample Green filter set configuration"
|
327
|
+
[channels.filters.green.excitation]
|
328
|
+
name = "Green-Ex"
|
329
|
+
type = "allow_all"
|
330
|
+
points = 1000
|
331
|
+
[channels.filters.green.emission]
|
332
|
+
name = "Green-Em"
|
333
|
+
type = "bandpass"
|
334
|
+
center_wavelength = 500 # nm
|
335
|
+
bandwidth = 35 # nm
|
336
|
+
transmission_peak = 0.95
|
337
|
+
points = 1000
|
338
|
+
|
339
|
+
|
340
|
+
# Camera configurations
|
341
|
+
[camera]
|
342
|
+
type = "CMOS"
|
343
|
+
pixel_count = [190, 190] # [width, height], 1200x1200 (x pixel_size)
|
344
|
+
pixel_detector_size = 6.5 # um
|
345
|
+
magnification = 100
|
346
|
+
dark_current = 0.0005 # electrons/pixel/second
|
347
|
+
readout_noise = 1.6 # electrons RMS
|
348
|
+
bit_depth = 16
|
349
|
+
sensitivity = 1.0 # electrons/ADU
|
350
|
+
base_adu = 100 #ADU
|
351
|
+
binning_size = 1 # 1x1 , if 2 then 2x2
|
352
|
+
|
353
|
+
# Quantum efficiency curve (wavelength in nm : efficiency 0-1)
|
354
|
+
# extrapotation for wavelengths not included uses edge values
|
355
|
+
quantum_efficiency = [
|
356
|
+
[
|
357
|
+
399,
|
358
|
+
0.00,
|
359
|
+
],
|
360
|
+
[
|
361
|
+
400,
|
362
|
+
0.80,
|
363
|
+
],
|
364
|
+
[
|
365
|
+
500,
|
366
|
+
0.90,
|
367
|
+
],
|
368
|
+
[
|
369
|
+
600,
|
370
|
+
0.95,
|
371
|
+
],
|
372
|
+
[
|
373
|
+
700,
|
374
|
+
0.90,
|
375
|
+
],
|
376
|
+
[
|
377
|
+
800,
|
378
|
+
0.70,
|
379
|
+
],
|
380
|
+
[
|
381
|
+
900,
|
382
|
+
0.40,
|
383
|
+
],
|
384
|
+
[
|
385
|
+
901,
|
386
|
+
0.00,
|
387
|
+
],
|
388
|
+
]
|
389
|
+
|
390
|
+
|
391
|
+
[experiment]
|
392
|
+
name = "PAmCherry_EGFP_Live_Widefield"
|
393
|
+
description = "Sample experiment configuration"
|
394
|
+
# experiment_type = "time-series" # "time-series" or "z-stack"
|
395
|
+
# z_position = 0.0
|
396
|
+
# laser_names_active = ["red", "blue"]
|
397
|
+
# laser_powers_active = [0.5, 0.05] #W
|
398
|
+
# laser_positions_active = [[5, 5, 0], [5, 5, 0]] # um
|
399
|
+
# xyoffset = [0, 0] # um
|
400
|
+
|
401
|
+
experiment_type = "z-stack" # "time-series" or "z-stack"
|
402
|
+
z_position = [-0.5, -0.4, -0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5]
|
403
|
+
laser_names_active = ["red", "blue"]
|
404
|
+
laser_powers_active = [0.5, 0.05] #W
|
405
|
+
laser_positions_active = [[5, 5, 0], [5, 5, 0]] # um
|
406
|
+
xyoffset = [0, 0] # um
|
407
|
+
exposure_time = 100 # ms, needs to be >= than oversample motion time in GlobalParameters
|
408
|
+
interval_time = 0 # ms, must be == 0 or if >0 then must be >= oversample motion time in GlobalParameters
|
AMS_BP/run_sim_util.py
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
import os
|
2
|
+
import time
|
3
|
+
from contextlib import contextmanager
|
4
|
+
from pathlib import Path
|
5
|
+
|
6
|
+
import rich
|
7
|
+
from rich.progress import Progress, SpinnerColumn, TextColumn
|
8
|
+
|
9
|
+
from .configio.convertconfig import load_config, setup_microscope
|
10
|
+
from .configio.saving import save_config_frames
|
11
|
+
|
12
|
+
|
13
|
+
def run_simulation_from_file(config_file: Path, show_progress: bool = True) -> None:
|
14
|
+
"""
|
15
|
+
Core simulation logic used by both CLI and GUI.
|
16
|
+
"""
|
17
|
+
|
18
|
+
@contextmanager
|
19
|
+
def progress_context():
|
20
|
+
if show_progress:
|
21
|
+
progress = Progress(
|
22
|
+
SpinnerColumn(),
|
23
|
+
TextColumn("[progress.description]{task.description}"),
|
24
|
+
transient=True,
|
25
|
+
)
|
26
|
+
with progress:
|
27
|
+
yield progress
|
28
|
+
else:
|
29
|
+
# Dummy context for GUI
|
30
|
+
class DummyProgress:
|
31
|
+
def add_task(self, description, total=None):
|
32
|
+
return None
|
33
|
+
|
34
|
+
def update(self, task, completed):
|
35
|
+
pass
|
36
|
+
|
37
|
+
yield DummyProgress()
|
38
|
+
|
39
|
+
with progress_context() as progress:
|
40
|
+
start_task_1 = time.time()
|
41
|
+
task_1 = progress.add_task(
|
42
|
+
description="Processing request to run the simulation ...", total=10
|
43
|
+
)
|
44
|
+
|
45
|
+
if not os.path.isfile(config_file):
|
46
|
+
raise FileNotFoundError("Configuration file not found.")
|
47
|
+
|
48
|
+
loadedconfig = load_config(config_file)
|
49
|
+
|
50
|
+
if "version" in loadedconfig:
|
51
|
+
version = loadedconfig["version"]
|
52
|
+
rich.print(f"Using config version: [bold]{version}[/bold]")
|
53
|
+
|
54
|
+
setup_config = setup_microscope(loadedconfig)
|
55
|
+
microscope = setup_config["microscope"]
|
56
|
+
configEXP = setup_config["experiment_config"]
|
57
|
+
functionEXP = setup_config["experiment_func"]
|
58
|
+
|
59
|
+
progress.update(task_1, completed=10)
|
60
|
+
rich.print(
|
61
|
+
"Prep work done in {:.2f} seconds.".format(time.time() - start_task_1)
|
62
|
+
)
|
63
|
+
|
64
|
+
time_task_2 = time.time()
|
65
|
+
task_2 = progress.add_task(description="Running the simulation ...", total=None)
|
66
|
+
|
67
|
+
frames, metadata = functionEXP(microscope=microscope, config=configEXP)
|
68
|
+
|
69
|
+
save_config_frames(
|
70
|
+
metadata, frames, setup_config["base_config"].OutputParameter
|
71
|
+
)
|
72
|
+
|
73
|
+
progress.update(task_2, completed=None)
|
74
|
+
rich.print(
|
75
|
+
"Simulation completed in {:.2f} seconds.".format(time.time() - time_task_2)
|
76
|
+
)
|
AMS_BP/sim_microscopy.py
CHANGED
@@ -132,8 +132,8 @@ class VirtualMicroscope:
|
|
132
132
|
self._set_laser_positions(laser_positions=laser_position)
|
133
133
|
|
134
134
|
duration_total, exposure_time, interval_time = timeValidator(
|
135
|
-
self.config.
|
136
|
-
self.config.
|
135
|
+
self.config.GlobalParameter.exposure_time,
|
136
|
+
self.config.GlobalParameter.interval_time,
|
137
137
|
self.sample_plane.dt,
|
138
138
|
self.sample_plane.t_end,
|
139
139
|
self._time,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: AMS_BP
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.4.0
|
4
4
|
Summary: Advanced Microscopy Simulations developed for the Weber Lab by Baljyot Singh Parmar
|
5
5
|
Project-URL: Documentation, https://joemans3.github.io/AMS_BP/
|
6
6
|
Project-URL: Source code, https://github.com/joemans3/AMS_BP
|
@@ -11,12 +11,16 @@ Keywords: SMS
|
|
11
11
|
Requires-Python: >=3.12
|
12
12
|
Requires-Dist: boundedfbm>=0.4.0
|
13
13
|
Requires-Dist: jsonschema>=4.23.0
|
14
|
+
Requires-Dist: napari[all]>=0.5.6
|
14
15
|
Requires-Dist: numpy>=1.21.2
|
15
16
|
Requires-Dist: pydantic>=2.9.2
|
17
|
+
Requires-Dist: pyqt6>=6.9.0
|
16
18
|
Requires-Dist: pyvista>=0.44.2
|
17
19
|
Requires-Dist: scikit-image>=0.18.3
|
18
20
|
Requires-Dist: scipy>=1.7.1
|
21
|
+
Requires-Dist: tifffile>=2024.12.12
|
19
22
|
Requires-Dist: tomli>=2.0.2
|
23
|
+
Requires-Dist: tomlkit>=0.13.2
|
20
24
|
Requires-Dist: typer>=0.12.5
|
21
25
|
Description-Content-Type: text/markdown
|
22
26
|
|
@@ -29,11 +33,28 @@ Description-Content-Type: text/markdown
|
|
29
33
|
|
30
34
|
AMS-BP is a powerful simulation tool for advanced fluorescence microscopy experiments. This guide covers both command-line usage and library integration.
|
31
35
|
|
32
|
-
|
36
|
+
## Overview of Simulation Workflow
|
37
|
+
<img align = "left" src="./docs/assets/figures/Fig1_Schema.svg" width="500"/>
|
38
|
+
|
39
|
+
*A ground truth is created, **a**, with $`f_{n}`$ fluorophore types of $`N_{f_{n}}`$ molecules each. If applicable, the motion of these molecules is modelled using a 3D bounded FBM with fluctuating generalized diffusion coefficients and Hurst parameters. Variations are modelled as a Markov Chain and require rate constants as parameters. Different fluorophores can have different motion models. The resolution of the motion models is $`\Delta t`$ and cannot be smaller than 1 ms (for computational efficiency). Given the microscope parameters specific to the experimental procedure to simulate, at every time $`t_{j}`$, the excitation intensity for each channel (**b**) is calculated at each fluorophore's location, **c**. For $`t_{j} \rightarrow t_{j+\Delta t}`$, the photophysical state trajectory of the fluorophore is simulated using the light intensity at the molecule's location as input for any light-dependent transition rates, **d**. For the duration that the shutter is open and light is emitted from the sample, emission filters for each channel are applied before the convolution with PSF models, **e**. The incident photons on the detector are then converted to photoelectrons and finally to digital units using the detector models provided, **f**.*
|
40
|
+
|
41
|
+
## API Reference and Docs
|
42
|
+
Find detailed API references for the library at: [joemans3/github.io/AMS_BP](https://joemans3.github.io/AMS_BP/)
|
43
|
+
> A more detailed example is provided in the jupyter notebook in the examples. For starters refer to the [VisualizingIndividualModules](examples/VisualizingIndividualModules/modules_explained.ipynb). Then head over to the [laser modulation module](examples/VisualizingIndividualModules/laser_modulation.ipynb) which will show how to change the laser power over time in the simulations. Then view an example of a complex experiment setup for [FRAP](examples/QuantitativeExperiments/FRAP/FRAP_methods.ipynb) which is possible by the use of compositions of modules in this simulation library.
|
44
|
+
|
45
|
+
## Examples (Click on the image buttons to be taken to the Jupyter notebooks):
|
46
|
+
|
47
|
+
> !!ATTENTION!! - Please note that you NEED to install the developmental dependencies to run the examples in full. This is mainly for installing the Jupyter notebook extensions, matplotlib and other visualization packages.
|
33
48
|
|
49
|
+
[<img src="./docs/assets/buttons/ButtonFigure_FRAP.svg" width="300" height="120"/>](./examples/QuantitativeExperiments/FRAP/FRAP_methods.ipynb) [<img src="./docs/assets/buttons/ButtonFigure_fPALM_NPC.svg" width="300"/>](./examples/QuantitativeExperiments/FRAP/FRAP_methods.ipynb)
|
50
|
+
|
51
|
+
[<img src="./docs/assets/buttons/ButtonFigure_zstack_twocolor_widefield.svg" width="300"/>](./examples/QuantitativeExperiments/TwoColor/Widefield/widefield_twocolor.ipynb) [<img src="./docs/assets/buttons/ButtonFigure_zstack_twocolor_confocal.svg" width="300"/>](./examples/QuantitativeExperiments/TwoColor/Confocal/confocal_twocolor.ipynb)
|
52
|
+
|
53
|
+
[<img align="middle" src="./docs/assets/buttons/ButtonFigure_sptPALM_mmaple.svg" width="300"/>](./examples/QuantitativeExperiments/PALM/sptPALM/motionmodels_sptmmaple.ipynb)
|
34
54
|
## Table of Contents
|
35
55
|
- [Installation](#installation)
|
36
56
|
- [Command Line Interface](#command-line-interface)
|
57
|
+
- [GUI](#gui)
|
37
58
|
- [Configuration File](#configuration-file)
|
38
59
|
- [Running Experiments](#running-experiments)
|
39
60
|
- [Advanced Usage](#advanced-usage)
|
@@ -74,6 +95,9 @@ run_AMS_BP config [OPTIONS]
|
|
74
95
|
|
75
96
|
# Run a simulation using a configuration file
|
76
97
|
run_AMS_BP runsim CONFIG_FILE
|
98
|
+
|
99
|
+
#start the GUI
|
100
|
+
run_AMS_BP gui
|
77
101
|
```
|
78
102
|
|
79
103
|
### Config Command Options
|
@@ -81,13 +105,40 @@ run_AMS_BP runsim CONFIG_FILE
|
|
81
105
|
- `-o, --output_path PATH`: Specify the output directory for the configuration file
|
82
106
|
- `-r, --recursive_o`: Create output directory if it doesn't exist
|
83
107
|
|
84
|
-
##
|
85
|
-
|
86
|
-
*A ground truth is created, **a**, with $`f_{n}`$ fluorophore types of $`N_{f_{n}}`$ molecules each. If applicable, the motion of these molecules is modelled using a 3D bounded FBM with fluctuating generalized diffusion coefficients and Hurst parameters. Variations are modelled as a Markov Chain and require rate constants as parameters. Different fluorophores can have different motion models. The resolution of the motion models is $`\Delta t`$ and cannot be smaller than 1 ms (for computational efficiency). Given the microscope parameters specific to the experimental procedure to simulate, at every time $`t_{j}`$, the excitation intensity for each channel (**b**) is calculated at each fluorophore's location, **c**. For $`t_{j} \rightarrow t_{j+\Delta t}`$, the photophysical state trajectory of the fluorophore is simulated using the light intensity at the molecule's location as input for any light-dependent transition rates, **d**. For the duration that the shutter is open and light is emitted from the sample, emission filters for each channel are applied before the convolution with PSF models, **e**. The incident photons on the detector are then converted to photoelectrons and finally to digital units using the detector models provided, **f**.*
|
108
|
+
## GUI
|
109
|
+
In addition to the CLI and programmatic API, AMS-BP comes with a graphical interface to guide users through the configuration, simulation, and analysis pipeline.
|
87
110
|
|
111
|
+
### Main GUI Features
|
112
|
+
The GUI provides the following tools from a single interface:
|
88
113
|
|
114
|
+
**Create Configuration File** — Launches the visual configuration builder
|
115
|
+
**Run Simulation from Config** — Select a .toml file and run the simulation with logging and progress tracking
|
116
|
+
**Visualize Microscopy Data (Napari)** — Open TIFF, PNG, ND2, or Zarr image files and view with the Napari viewer
|
117
|
+
**Package Logs for Sharing** — Package run directories (e.g., run_2024_04_20_001) into a .zip file for archival or collaboration
|
89
118
|
|
119
|
+
### Launch the GUI
|
120
|
+
To start the GUI, run:
|
121
|
+
|
122
|
+
```bash
|
123
|
+
|
124
|
+
run_AMS_BP gui
|
125
|
+
```
|
126
|
+
#### Configuration Builder
|
127
|
+
Clicking "Create Configuration File" opens a template selector where you can choose a preconfigured simulation (with preview images), and then visually edit all configuration options through dedicated tabs.
|
90
128
|
|
129
|
+
Each section of the configuration is editable via structured UI forms, with contextual help and validation. Tabs include:
|
130
|
+
|
131
|
+
- Global/Cell/Molecule/Condensate/Fluorophore parameters
|
132
|
+
- Laser and optical configuration
|
133
|
+
- Camera and channel settings
|
134
|
+
- Experiment setup (e.g., z-stack vs time-series)
|
135
|
+
Once ready, click "Preview Configuration TOML" to inspect the final file, and "Save" to export.
|
136
|
+
|
137
|
+
#### Running Simulations from GUI
|
138
|
+
Clicking "Run Simulation from Config" lets you select any .toml configuration file. A real-time log viewer shows progress, and outputs are saved in a structured AMS_runs/run_*/ directory.
|
139
|
+
|
140
|
+
#### Sharing Logs
|
141
|
+
Run into an issue? Use the packge logs button to select the logs corresponding to the simulation you just ran, save them and send them over to us! It will help you diagnose the issue!
|
91
142
|
|
92
143
|
## Configuration File
|
93
144
|
|
@@ -166,35 +217,6 @@ run_AMS_BP config
|
|
166
217
|
run_AMS_BP runsim sim_config.toml
|
167
218
|
```
|
168
219
|
4. View the results in the newly created folder, whose name is defined in the config file.
|
169
|
-
## Advanced Usage
|
170
|
-
|
171
|
-
### Using AMS-BP as a Library
|
172
|
-
|
173
|
-
For programmatic control, you can import and use AMS-BP as a Python library:
|
174
|
-
|
175
|
-
```python
|
176
|
-
from AMS_BP.configio.convertconfig import ConfigLoader
|
177
|
-
|
178
|
-
# Configuration loader intialization
|
179
|
-
config_loader = ConfigLoader(config_path="path/to/config.toml")
|
180
|
-
|
181
|
-
# Setup microscope
|
182
|
-
setup_config = config_loader.setup_microscope()
|
183
|
-
microscope = setup_config["microscope"]
|
184
|
-
config_exp = setup_config["experiment_config"]
|
185
|
-
function_exp = setup_config["experiment_func"]
|
186
|
-
|
187
|
-
# Run simulation
|
188
|
-
frames, metadata = function_exp(microscope=microscope, config=config_exp)
|
189
|
-
|
190
|
-
# Save results
|
191
|
-
from AMS_BP.configio.saving import save_config_frames
|
192
|
-
save_config_frames(metadata, frames, setup_config["base_config"].OutputParameters)
|
193
|
-
```
|
194
|
-
|
195
|
-
## API Reference and Docs
|
196
|
-
Find detailed API references for the library at: [joemans3/github.io/AMS_BP](https://joemans3.github.io/AMS_BP/)
|
197
|
-
> A more detailed example is provided in the jupyter notebook in the examples. For starters refer to the [VisualizingIndividualModules](examples/VisualizingIndividualModules/modules_explained.ipynb). Then head over to the [laser modulation module](examples/VisualizingIndividualModules/laser_modulation.ipynb) which will show how to change the laser power over time in the simulations. Then view an example of a complex experiment setup for [FRAP](examples/QuantitativeExperiments/FRAP_methods.ipynb) which is possible by the use of compositions of modules in this simulation library.
|
198
220
|
|
199
221
|
## High Priority Features
|
200
222
|
~~1. Irregular cell shapes with motion models~~ (supported with release of v0.2.0)
|
@@ -202,3 +224,6 @@ Find detailed API references for the library at: [joemans3/github.io/AMS_BP](htt
|
|
202
224
|
3. STORM workflow examples
|
203
225
|
4. CTRW motion models
|
204
226
|
5. Simpler configurations
|
227
|
+
> **_NOTE:_** Please note that this application DOES NOT currently model the process of stimulated emission, and as such is not suitable for simulating stimulated emission microscopy ([STED](https://en.wikipedia.org/wiki/STED_microscopy))-type experiments. Work in this area is ongoing.
|
228
|
+
|
229
|
+
|