Hi,
there are two ways to use multiplication by the CTF: easy and hard.
Easy:
from sparx import *
m = model_gauss_noise(1.0,256,256)
c = generate_ctf([defocus, cs, voltage, apix, bfactor, ampcont, astigmatism_amplitude, astigmatism_angle])
Units: [ microns, mm, kV, Angstroms, A^2, microns, radians]
f = filt_ctf(m,c)
Hard:
you can parse body of film_ctf, it is written in python and refers only to EMAN2 functions:
def filt_ctf(img, ctf, dopad=True, sign=1, binary = 0):
"""
Name
filt_ctf - apply Contrast Transfer Function (CTF) to an image in Fourier space
Input
image: input image, it can be real or complex
ctf: an CTF object, please see CTF_info for description.
pad: apply padding with zeroes in real space to twice the size before CTF application (Default is True, if set to False, no padding, if input image is Fourier, the flag has no effect).
sign: sign of the CTF. If cryo data had inverted contrast, i.e., images were multiplied by -1 and particle projections appear bright on dark background, it has to be set to -1). (Default is 1).
binary: phase flipping if set to 1 (default is 0).
Output
image multiplied in Fourier space by the CTF, the output image has the same format as the input image.
"""
from EMAN2 import Processor
assert img.get_ysize() > 1
dict = ctf.to_dict()
dz = dict["defocus"]
cs = dict["cs"]
voltage = dict["voltage"]
pixel_size = dict["apix"]
b_factor = dict["bfactor"]
ampcont = dict["ampcont"]
dza = dict["dfdiff"]
azz = dict["dfang"]
if dopad and not img.is_complex(): ip = 1
else: ip = 0
params = {"filter_type": Processor.fourier_filter_types.CTF_,
"defocus" : dz,
"Cs": cs,
"voltage": voltage,
"Pixel_size": pixel_size,
"B_factor": b_factor,
"amp_contrast": ampcont,
"dopad": ip,
"binary": binary,
"sign": sign,
"dza": dza,
"azz":azz}
tmp = Processor.EMFourierFilter(img, params)
tmp.set_attr_dict({"ctf":ctf})
return tmp
Depending on your taste, you may also consider easy what I consider hard.
Regards,
Pawel.