-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathreconstruct_sim_simulated_timelapse.py
81 lines (70 loc) · 3.02 KB
/
reconstruct_sim_simulated_timelapse.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
"""
Reconstruct time-lapse SIM images of simulated microtubules.
"""
import datetime
import numpy as np
from pathlib import Path
import tifffile
from mcsim.analysis.sim_reconstruction import SimImageSet
# load images (images can be downloaded from Zenodo repository as described in README)
root_dir = Path(r"data")
tstamp = datetime.datetime.now().strftime('%Y_%m_%d_%H;%M;%S')
save_dir = root_dir / f"{tstamp:s}_sim_reconstruction_timelapse"
# load data
imgs = tifffile.imread(root_dir / "synthetic_microtubules.tiff")
# repeat image to simulate time-lapse
imgs = np.tile(imgs[None, ...], [61, 1, 1, 1, 1])
# physical parameters
na = 1.3 # numerical aperture
dxy = 0.065 # um
wavelength = 0.488 # um
# ###########################################
# initialize data
# ###########################################
imgset = SimImageSet.initialize({"pixel_size": dxy,
"na": na,
"wavelength": wavelength},
imgs,
otf=None,
wiener_parameter=0.3,
frq_estimation_mode="band-correlation",
# frq_guess=frqs_gt, # todo: can add frequency guesses for more reliable fitting
phase_estimation_mode="wicker-iterative",
phases_guess=np.array([[0, 2*np.pi / 3, 4 * np.pi / 3],
[0, 2*np.pi / 3, 4 * np.pi / 3],
[0, 2*np.pi / 3, 4 * np.pi / 3]]),
combine_bands_mode="fairSIM",
fmax_exclude_band0=0.4,
normalize_histograms=False,
background=100,
gain=2,
use_gpu=False)
# ###########################################
# run reconstruction
# this includes parameter estimation
# ###########################################
imgset.reconstruct(slices=(slice(0, 1),), # determine SIM parameters from first time-point
compute_widefield=True,
compute_os=False,
compute_deconvolved=False,
compute_mcnr=True,
# frq_search_bounds=(0, 0.95)
)
# ###########################################
# print parameters
# ###########################################
imgset.print_parameters()
# ###########################################
# save reconstruction results
# ###########################################
imgset.save_imgs(save_dir,
format="tiff", # format="zarr",
save_raw_data=False,
save_patterns=False)
# ###########################################
# save diagnostic plots
# ###########################################
imgset.plot_figs(save_dir,
diagnostics_only=True,
figsize=(20, 10),
imgs_dpi=300)