Skip to content

Commit f2ffbcf

Browse files
authored
Merge pull request #63 from jdickerson95/jd_b-env
Calculate b-factor envelope and CTF separately, and update `torch-fourier-filter` dependency accordingly
2 parents d9e404d + 3de276c commit f2ffbcf

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ dependencies = [
4949
"roma",
5050
"tqdm",
5151
"torch-fourier-slice>=v0.2.0",
52-
"torch-fourier-filter>=v0.2.3",
52+
"torch-fourier-filter>=v0.2.6",
5353
"torch-so3>=v0.2.0",
5454
"ttsim3d>=v0.4.0",
5555
"lmfit",

src/leopard_em/pydantic_models/utils.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import torch
77
from torch_fourier_filter.ctf import calculate_ctf_2d
8+
from torch_fourier_filter.envelopes import b_envelope
89

910
# Using the TYPE_CHECKING statement to avoid circular imports
1011
if TYPE_CHECKING:
@@ -166,13 +167,22 @@ def calculate_ctf_filter_stack_full_args(
166167
voltage=kwargs["voltage"],
167168
spherical_aberration=cs_val,
168169
amplitude_contrast=kwargs["amplitude_contrast_ratio"],
169-
b_factor=kwargs["ctf_B_factor"],
170170
phase_shift=kwargs["phase_shift"],
171171
pixel_size=kwargs["pixel_size"],
172172
image_shape=template_shape,
173173
rfft=True,
174174
fftshift=False,
175175
)
176+
# calc B-envelope and apply
177+
b_envelope_tmp = b_envelope(
178+
B=kwargs["ctf_B_factor"],
179+
image_shape=template_shape,
180+
pixel_size=kwargs["pixel_size"],
181+
rfft=True,
182+
fftshift=False,
183+
device=tmp.device,
184+
)
185+
tmp *= b_envelope_tmp
176186
ctf_list.append(tmp)
177187

178188
ctf = torch.stack(ctf_list, dim=0)

0 commit comments

Comments
 (0)