2424# Image size to use throughout the demo.
2525IMG_SIZE = 512
2626
27- # Pixel size in Angstrom
28- pixel_size = 0.5
29-
30- # %%
31- # .. note::
32- # Pixel size was chosen to demonstrate effects similar to lecture notes,
33- # but at a higher resolution.
34-
3527
3628# %%
3729# Visualizing the CTF
5951# The CTF filter can be visualized as an image once it is evaluated at a specific resolution.
6052# More specifically the following code will return a transfer function as an array,
6153# which is then plotted.
62- rctf_fn = radial_ctf_filter .evaluate_grid (IMG_SIZE , pixel_size = pixel_size )
54+ rctf_fn = radial_ctf_filter .evaluate_grid (IMG_SIZE , pixel_size = 1 )
6355plt .imshow (rctf_fn )
6456plt .colorbar ()
6557plt .show ()
8476)
8577
8678# Again, we plot it, and note the difference from the RadialCTFFilter.
87- plt .imshow (ctf_filter .evaluate_grid (IMG_SIZE , pixel_size = pixel_size ))
79+ plt .imshow (ctf_filter .evaluate_grid (IMG_SIZE , pixel_size = 1 ))
8880plt .colorbar ()
8981plt .show ()
9082
9789# array returned by ASPIRE's ``CTFFilter.evaluate_grid``.
9890
9991
100- ctf_sign = np .sign (radial_ctf_filter .evaluate_grid (IMG_SIZE , pixel_size = pixel_size ))
92+ ctf_sign = np .sign (radial_ctf_filter .evaluate_grid (IMG_SIZE , pixel_size = 1 ))
10193plt .imshow (ctf_sign )
10294plt .colorbar ()
10395plt .show ()
@@ -147,7 +139,7 @@ def generate_example_image(L, noise_variance=0.1):
147139 return img
148140
149141
150- img = Image (generate_example_image (IMG_SIZE ), pixel_size = pixel_size )
142+ img = Image (generate_example_image (IMG_SIZE ), pixel_size = 1 )
151143img .show ()
152144
153145
@@ -172,7 +164,7 @@ def generate_example_image(L, noise_variance=0.1):
172164# Generate images corrupted by progressively increasing defocus.
173165
174166# For each defocus, apply filter to the base image.
175- imgs = Image (np .empty ((len (defoci ), IMG_SIZE , IMG_SIZE )), pixel_size = pixel_size )
167+ imgs = Image (np .empty ((len (defoci ), IMG_SIZE , IMG_SIZE )), pixel_size = 1 )
176168for i , ctf in enumerate (ctf_filters ):
177169 imgs [i ] = img .filter (ctf )[0 ]
178170imgs .show ()
@@ -190,13 +182,13 @@ def generate_example_image(L, noise_variance=0.1):
190182 # Compute the signs of this CTF
191183 # In practice, this would be an estimated CTF,
192184 # but in the demo we have the luxury of using the model CTF that was applied.
193- signs = np .sign (ctf .evaluate_grid (IMG_SIZE , pixel_size = pixel_size ))
185+ signs = np .sign (ctf .evaluate_grid (IMG_SIZE , pixel_size = 1 ))
194186 # Apply to the image in Fourier space.
195187 phase_flipped_imgs_f [i ] = signs * imgs_f [i ]
196188
197189# Construct the centered 2D FFT of the images.
198190phase_flipped_imgs = aspire .numeric .fft .centered_ifft2 (phase_flipped_imgs_f ).real
199- Image (phase_flipped_imgs , pixel_size = pixel_size ).show ()
191+ Image (phase_flipped_imgs , pixel_size = 1 ).show ()
200192
201193# %%
202194# .. warning::
@@ -224,7 +216,7 @@ def generate_example_image(L, noise_variance=0.1):
224216 B = 0 ,
225217)
226218# Evaluate Filter, returning a Numpy array.
227- bad_ctf_fn = bad_est_ctf_filter .evaluate_grid (IMG_SIZE , pixel_size = pixel_size )
219+ bad_ctf_fn = bad_est_ctf_filter .evaluate_grid (IMG_SIZE , pixel_size = 1 )
228220
229221c = IMG_SIZE // 2 + 1
230222plt .plot (rctf_fn [c , c :], label = "Model CTF" ) # radial_ctf_filter
@@ -264,7 +256,7 @@ def generate_example_image(L, noise_variance=0.1):
264256
265257 radial_ctf_est = estimate_ctf (
266258 data_folder = d ,
267- pixel_size = pixel_size ,
259+ pixel_size = 1 ,
268260 cs = radial_ctf_filter .Cs ,
269261 amplitude_contrast = radial_ctf_filter .alpha ,
270262 voltage = radial_ctf_filter .voltage ,
@@ -298,7 +290,7 @@ def generate_example_image(L, noise_variance=0.1):
298290 alpha = est ["amplitude_contrast" ],
299291 B = 0 ,
300292)
301- est_ctf_fn = est_ctf .evaluate_grid (IMG_SIZE , pixel_size = pixel_size )
293+ est_ctf_fn = est_ctf .evaluate_grid (IMG_SIZE , pixel_size = 1 )
302294
303295# Compare the model CTF with the estimated CTF.
304296c = IMG_SIZE // 2 + 1
@@ -342,7 +334,7 @@ def generate_example_image(L, noise_variance=0.1):
342334from aspire .source import Simulation
343335
344336# Create the Source. ``ctf_filters`` are re-used from earlier section.
345- src = Simulation (L = 64 , n = 4 , unique_filters = ctf_filters , pixel_size = pixel_size )
337+ src = Simulation (L = 64 , n = 4 , unique_filters = ctf_filters , pixel_size = 1 )
346338src .images [:4 ].show ()
347339
348340# %%
0 commit comments