Skip to content

Commit 01fdc11

Browse files
committed
minimal changes to restore simulation gallery for release
1 parent 4d38422 commit 01fdc11

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

gallery/experiments/simulated_abinitio_pipeline.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,9 @@
5454
# ---------------
5555
# Start with the hi-res volume map EMDB-2660 sourced from EMDB,
5656
# https://www.ebi.ac.uk/emdb/EMD-2660, and dowloaded via ASPIRE's downloader utility.
57-
og_v = emdb_2660()
57+
og_v = emdb_2660().astype(np.float64)
5858
logger.info("Original volume map data" f" shape: {og_v.shape} dtype:{og_v.dtype}")
5959

60-
logger.info(f"Downsampling to {(img_size,)*3}")
61-
v = og_v.downsample(img_size)
62-
L = v.resolution
63-
6460

6561
# Then create a filter based on that variance
6662
# This is an example of a custom noise profile
@@ -70,15 +66,15 @@ def noise_function(x, y):
7066
# White
7167
f1 = noise_variance
7268
# Violet-ish
73-
f2 = noise_variance * (x * x + y * y) / L * L
69+
f2 = noise_variance * (x * x + y * y) / img_size * img_size
7470
return (alpha * f1 + beta * f2) / 2.0
7571

7672

7773
custom_noise = CustomNoiseAdder(noise_filter=FunctionFilter(noise_function))
7874

7975
logger.info("Initialize CTF filters.")
8076
# Create some CTF effects
81-
pixel_size = 5 * 65 / img_size # Pixel size of the images (in angstroms)
77+
pixel_size = og_v.pixel_size # Pixel size (in angstroms)
8278
voltage = 200 # Voltage (in KV)
8379
defocus_min = 1.5e4 # Minimum defocus value (in angstroms)
8480
defocus_max = 2.5e4 # Maximum defocus value (in angstroms)
@@ -94,13 +90,16 @@ def noise_function(x, y):
9490

9591
# Finally create the Simulation
9692
src = Simulation(
97-
L=v.resolution,
9893
n=num_imgs,
99-
vols=v,
94+
vols=og_v,
10095
noise_adder=custom_noise,
10196
unique_filters=ctf_filters,
102-
dtype=v.dtype,
97+
dtype=np.float64,
10398
)
99+
100+
# Downsample
101+
src = src.downsample(img_size).cache()
102+
104103
# Peek
105104
if interactive:
106105
src.images[:10].show()
@@ -115,7 +114,7 @@ def noise_function(x, y):
115114

116115
# Plot the noise profile for inspection
117116
if interactive:
118-
plt.imshow(aiso_noise_estimator.filter.evaluate_grid(L))
117+
plt.imshow(aiso_noise_estimator.filter.evaluate_grid(img_size))
119118
plt.show()
120119

121120
# Peek, what do the whitened images look like...

0 commit comments

Comments
 (0)