diff --git a/examples/article_figures/figS_NPC_quantification.py b/examples/article_figures/figS_NPC_quantification.py index 75a87a24..4301db95 100644 --- a/examples/article_figures/figS_NPC_quantification.py +++ b/examples/article_figures/figS_NPC_quantification.py @@ -17,7 +17,7 @@ probe_template = "GFP_w_nanobody" probe_target_type = "Sequence" probe_target_value = "ELAVGSL" # Sequence in the C-terminal of Nup96 -modalities = ["STED_Thev2016", ] +modalities = ["STED", ] # fetch experimental image from URL STED_example = "https://ftp.ebi.ac.uk/biostudies/fire/S-BIAD/S-BIAD0-99/S-BIAD8/Files/Library/Gallery%20Fig%201/STED/GFP_Gallery-STED_181026_1.tif" @@ -36,7 +36,6 @@ probe_target_type=probe_target_type, probe_target_value=probe_target_value, multimodal=modalities, - STED_Thev2016={"exp_time": 0.0002}, clear_experiment=True, run_simulation=False, random_seed=random_seed @@ -66,7 +65,19 @@ min_distance=min_distance) # Run simulation -experiment.set_modality_acq(modality_name="STED_Thev2016", exp_time=0.0002) +## Modality parameter of pixelsize_nm is set to match Thevathasan et al. 2019. +## All other parameters are estimations to emulate Thevathasan et al. 2019 STED modality +experiment.update_modality( + modality_name="STED", + lateral_resolution_nm=15, + axial_resolution_nm=20, + psf_voxel_nm=5, + depth_of_field_nm=100, + pixelsize_nm=15) +experiment.set_modality_acq( + modality_name="STED", + exp_time=0.0002) +experiment.imager.modalities["STED"]["detector"]["noise_model"]["binomial"]["p"] = 0.7 images, noiselsess = experiment.run_simulation() # Analyse images: fit circles @@ -79,13 +90,13 @@ maxRadius_round = np.ceil(MAX_radius_px).astype('int64') minDist = minRadius_round -if images["STED_Thev2016"]["ch0"][0].min() < 0: - images["STED_Thev2016"]["ch0"][0] += -images["STED_Thev2016"]["ch0"][0].min() +if images["STED"]["ch0"][0].min() < 0: + images["STED"]["ch0"][0] += -images["STED"]["ch0"][0].min() #### Simulated Data HCparams = dict(dp=1, minDist=maxRadius_round, param1=10, param2=7, minRadius=minRadius_round, maxRadius=maxRadius_round) -circles_sim, img_blurred_sim, c_params_sim = metrics.get_circles(images["STED_Thev2016"]["ch0"][0].astype(np.uint8), **HCparams) +circles_sim, img_blurred_sim, c_params_sim = metrics.get_circles(images["STED"]["ch0"][0].astype(np.uint8), **HCparams) radii_simulated= [] for (x, y, r) in circles_sim[0]: radii_simulated.append((r*pixelsize)) @@ -103,7 +114,7 @@ fig, axs = plt.subplots(1, 3) axs[0].imshow(experimental_img_processed, cmap="grey") axs[0].set_title("Modified from Thevathasan et al. 2019. Nature Methods.") -axs[1].imshow(images["STED_Thev2016"]["ch0"][0], cmap="grey") +axs[1].imshow(images["STED"]["ch0"][0], cmap="grey") axs[1].set_title("VLab4Mic simulated image") df = pd.DataFrame({ @@ -115,7 +126,7 @@ length_nm = 1000 nm = 1e-09 -pixelsize = (experiment.imaging_modalities["STED_Thev2016"]["detector"]["scale"] / nm) * experiment.imaging_modalities["STED_Thev2016"]["detector"]["pixelsize"] +pixelsize = (experiment.imaging_modalities["STED"]["detector"]["scale"] / nm) * experiment.imaging_modalities["STED"]["detector"]["pixelsize"] pixelsize = np.ceil(pixelsize) length_px = length_nm / pixelsize hight_px = length_px / 10 diff --git a/examples/real_vs_simulation.py b/examples/real_vs_simulation.py index 460a2ee0..b640de4d 100644 --- a/examples/real_vs_simulation.py +++ b/examples/real_vs_simulation.py @@ -7,13 +7,13 @@ import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1.anchored_artists import AnchoredSizeBar import matplotlib.font_manager as fm - +random_seed = 24 # parameters for simulation structure = "7R5K" probe_template = "GFP_w_nanobody" probe_target_type = "Sequence" probe_target_value = "ELAVGSL" # Sequence in the C-terminal of Nup96 -modalities = ["STED_Thev2016", ] +modalities = ["STED", ] # fetch experimental image from URL STED_example = "https://ftp.ebi.ac.uk/biostudies/fire/S-BIAD/S-BIAD0-99/S-BIAD8/Files/Library/Gallery%20Fig%201/STED/GFP_Gallery-STED_181026_1.tif" @@ -44,9 +44,10 @@ probe_target_type=probe_target_type, probe_target_value=probe_target_value, multimodal=modalities, - STED_Thev2016={"exp_time": 0.0004}, + STED={"exp_time": 0.0004}, clear_experiment=True, run_simulation=False, + random_seed=random_seed ) # Use experimental image for positioning @@ -60,6 +61,19 @@ min_distance=min_distance) # Run simulation +## Modality parameter of pixelsize_nm is set to match Thevathasan et al. 2019. +## All other parameters are estimations to emulate Thevathasan et al. 2019 STED modality +experiment.update_modality( + modality_name="STED", + lateral_resolution_nm=15, + axial_resolution_nm=20, + psf_voxel_nm=5, + depth_of_field_nm=100, + pixelsize_nm=15) +experiment.set_modality_acq( + modality_name="STED", + exp_time=0.0004) +experiment.imager.modalities["STED"]["detector"]["noise_model"]["binomial"]["p"] = 0.7 images, noiselsess = experiment.run_simulation() # Plot experimental vs simulated image @@ -70,7 +84,7 @@ fig, axs = plt.subplots(1, 2) axs[0].imshow(experimental_img_processed, cmap="grey") axs[0].set_title("Modified from Thevathasan et al. 2019. Nature Methods.") -axs[1].imshow(images["STED_Thev2016"]["ch0"][0], cmap="grey") +axs[1].imshow(images["STED"]["ch0"][0], cmap="grey") axs[1].set_title("VLab4Mic simulated image") fontprops = fm.FontProperties(size=20) diff --git a/src/vlab4mic/configs/modalities/AiryScan_Thev2016.yaml b/src/vlab4mic/configs/modalities/AiryScan_Thev2016.yaml deleted file mode 100644 index 8e080407..00000000 --- a/src/vlab4mic/configs/modalities/AiryScan_Thev2016.yaml +++ /dev/null @@ -1,29 +0,0 @@ -name: AiryScan_Thev2016 -scale: 1.0e-09 -PSF: - source: generate - resolution: # in nanometers, as standard deviations - X: 61 - Y: 61 - Z: 230 - voxelsize: 10 -depth: 1000 # in nanometers -detector: - FOV_size: # in nanometers. Default unless changed - X: 1000 - Y: 1000 - pixelsize: 40 # in nanometers - noise: - binomial: 0.9 - gaussian: - mean: 0 - standard_dev: 3 - gain: 1 - baselevel: - mean: 0 - standard_dev: 1 - ADU: 1 - - - # no value is only poisson noise. Expected order of values - # p (binomial), mean, standard deviation (gaussian), gain (gamma), mean, standard deviation (abaselevel), adu (conversion factor) \ No newline at end of file diff --git a/src/vlab4mic/configs/modalities/Confocal_Thev2016.yaml b/src/vlab4mic/configs/modalities/Confocal_Thev2016.yaml deleted file mode 100644 index 54d5093d..00000000 --- a/src/vlab4mic/configs/modalities/Confocal_Thev2016.yaml +++ /dev/null @@ -1,29 +0,0 @@ -name: Confocal_Thev2016 -scale: 1.0e-09 -PSF: - source: generate - resolution: # in nanometers, as standard deviations - X: 94 - Y: 94 - Z: 331 - voxelsize: 10 -depth: 1000 # in nanometers -detector: - FOV_size: # in nanometers. Default unless changed - X: 1000 - Y: 1000 - pixelsize: 70 # in nanometers - noise: - binomial: 1 - gaussian: - mean: 0 - standard_dev: 1 - gain: 1 - baselevel: - mean: 0 - standard_dev: 1 - ADU: 1 - - - # no value is only poisson noise. Expected order of values - # p (binomial), mean, standard deviation (gaussian), gain (gamma), mean, standard deviation (abaselevel), adu (conversion factor) \ No newline at end of file diff --git a/src/vlab4mic/configs/modalities/STED_Thev2016.yaml b/src/vlab4mic/configs/modalities/STED_Thev2016.yaml deleted file mode 100644 index c790b117..00000000 --- a/src/vlab4mic/configs/modalities/STED_Thev2016.yaml +++ /dev/null @@ -1,29 +0,0 @@ -name: STED_Thev2016 -scale: 1.0e-09 -PSF: - source: generate - resolution: # in nanometers, as standard deviations - X: 15 - Y: 15 - Z: 20 - voxelsize: 5 -depth: 100 # in nanometers -detector: - FOV_size: # in nanometers. Default unless changed - X: 1000 - Y: 1000 - pixelsize: 15 # in nanometers - noise: - binomial: 0.7 - gaussian: - mean: 0 - standard_dev: 1 - gain: 1 - baselevel: - mean: 0 - standard_dev: 1 - ADU: 1 - - - # no value is only poisson noise. Expected order of values - # p (binomial), mean, standard deviation (gaussian), gain (gamma), mean, standard deviation (abaselevel), adu (conversion factor) \ No newline at end of file diff --git a/src/vlab4mic/configs/modalities/STORM_Thev2016.yaml b/src/vlab4mic/configs/modalities/STORM_Thev2016.yaml deleted file mode 100644 index 2b3aafc2..00000000 --- a/src/vlab4mic/configs/modalities/STORM_Thev2016.yaml +++ /dev/null @@ -1,29 +0,0 @@ -name: STORM_Thev2016 -scale: 1.0e-09 -PSF: - source: generate - resolution: # in nanometers, as standard deviations - X: 8 - Y: 8 - Z: 8 - voxelsize: 5 -depth: 100 # in nanometers -detector: - FOV_size: # in nanometers. Default unless changed - X: 1000 - Y: 1000 - pixelsize: 5 # in nanometers - noise: - binomial: 0.8 - gaussian: - mean: 0 - standard_dev: 0 - gain: 1 - baselevel: - mean: 0 - standard_dev: 0 - ADU: 1 - - - # no value is only poisson noise. Expected order of values - # p (binomial), mean, standard deviation (gaussian), gain (gamma), mean, standard deviation (abaselevel), adu (conversion factor) \ No newline at end of file diff --git a/src/vlab4mic/configs/modalities/Widefield_Thev2016.yaml b/src/vlab4mic/configs/modalities/Widefield_Thev2016.yaml deleted file mode 100644 index a49c9d1b..00000000 --- a/src/vlab4mic/configs/modalities/Widefield_Thev2016.yaml +++ /dev/null @@ -1,29 +0,0 @@ -name: Widefield_Thev2016 -scale: 1.0e-09 -PSF: - source: generate - resolution: # in nanometers, as standard deviations - X: 94 - Y: 94 - Z: 331 - voxelsize: 10 -depth: 1000 # in nanometers -detector: - FOV_size: # in nanometers. Default unless changed - X: 1000 - Y: 1000 - pixelsize: 100 # in nanometers - noise: - binomial: 0.9 - gaussian: - mean: 0 - standard_dev: 1 - gain: 1 - baselevel: - mean: 400 - standard_dev: 1 - ADU: 1 - - - # no value is only poisson noise. Expected order of values - # p (binomial), mean, standard deviation (gaussian), gain (gamma), mean, standard deviation (abaselevel), adu (conversion factor) \ No newline at end of file