EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes
EMAN::CtfSimProcessor Class Reference

CTF simulation processor. More...

#include <processor.h>

Inheritance diagram for EMAN::CtfSimProcessor:
Inheritance graph
[legend]
Collaboration diagram for EMAN::CtfSimProcessor:
Collaboration graph
[legend]

List of all members.

Public Member Functions

string get_name () const
 Get the processor's name.
virtual EMDataprocess (const EMData *const image)
 To proccess an image out-of-place.
void process_inplace (EMData *image)
 To process an image in-place.
TypeDict get_param_types () const
 Get processor parameter information in a dictionary.
string get_desc () const
 Get the descrition of this specific processor.

Static Public Member Functions

static ProcessorNEW ()

Static Public Attributes

static const string NAME = "math.simulatectf"

Detailed Description

CTF simulation processor.

Takes individual CTF parameters, suitable for use with programs like e2filtertool.py. Can use an internal noise profile or an external profile from a text file.

Parameters:
defocus[in]Defocus in microns (underfocus positive)
ampcont[in]% amplitude contrast (0-100)
bfactor[in]B-factor in A^2, uses MRC convention rather than EMAN1 convention
noiseamp[in]Amplitude of the added empirical pink noise
noiseampwhite[in]Amplitude of added white noise
voltage[in]Microscope voltage in KV
cs[in]Cs of microscope in mm
apix[in]A/pix of data
Author:
Steve Ludtke
Date:
2011/11/03

Definition at line 848 of file processor.h.


Member Function Documentation

string EMAN::CtfSimProcessor::get_desc ( ) const [inline, virtual]

Get the descrition of this specific processor.

This function must be overwritten by a subclass.

Returns:
The description of this processor.

Implements EMAN::Processor.

Definition at line 879 of file processor.h.

                {
                        return "Applies a simulated CTF with noise to an image. The added noise is either white or based on an empirical curve generated from cryoEM data. ";
                }
string EMAN::CtfSimProcessor::get_name ( ) const [inline, virtual]

Get the processor's name.

Each processor is identified by a unique name.

Returns:
The processor's name.

Implements EMAN::Processor.

Definition at line 851 of file processor.h.

References NAME.

                {
                        return NAME;
                }
TypeDict EMAN::CtfSimProcessor::get_param_types ( ) const [inline, virtual]

Get processor parameter information in a dictionary.

Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.

Returns:
A dictionary containing the parameter info.

Reimplemented from EMAN::Processor.

Definition at line 860 of file processor.h.

References EMAN::EMObject::FLOAT, and EMAN::TypeDict::put().

                {
                        TypeDict d;
                        d.put("defocus", EMObject::FLOAT, "Defocus in microns (underfocus positive)");
                        d.put("ampcont", EMObject::FLOAT, "% amplitude contrast (0-100)");
                        d.put("bfactor", EMObject::FLOAT, "B-factor in A^2, uses MRC convention rather than EMAN1 convention");
                        d.put("noiseamp", EMObject::FLOAT, "Amplitude of the added empirical pink noise");
                        d.put("noiseampwhite", EMObject::FLOAT, "Amplitude of added white noise");
                        d.put("voltage", EMObject::FLOAT, "Microscope voltage in KV");
                        d.put("cs", EMObject::FLOAT, "Cs of microscope in mm");
                        d.put("apix", EMObject::FLOAT, "A/pix of data");
                        return d;
                }
static Processor* EMAN::CtfSimProcessor::NEW ( ) [inline, static]

Definition at line 874 of file processor.h.

                {
                        return new CtfSimProcessor();
                }
EMData * CtfSimProcessor::process ( const EMData *const  image) [virtual]

To proccess an image out-of-place.

For those processors which can only be processed out-of-place, override this function to give the right behavior.

Parameters:
imageThe image will be copied, actual process happen on copy of image.
Returns:
the image processing result, may or may not be the same size of the input image

Reimplemented from EMAN::Processor.

Definition at line 5727 of file processor.cpp.

References EMAN::EMData::add(), EMAN::EMAN2Ctf::ampcont, EMAN::Ctf::apix, EMAN::EMData::apply_radial_func(), EMAN::Ctf::bfactor, EMAN::EMAN2Ctf::compute_1d(), EMAN::EMData::copy(), EMAN::Ctf::cs, EMAN::Ctf::CTF_AMP, EMAN::Ctf::defocus, EMAN::EMData::do_fft(), EMAN::EMData::do_fft_inplace(), EMAN::EMData::do_ift(), EMAN::EMAN2Ctf::dsbg, EMAN::EMData::get_attr_default(), EMAN::EMData::get_ysize(), EMAN::EMData::is_complex(), LOGWARN, EMAN::EMData::mult(), EMAN::Processor::params, EMAN::EMData::process_inplace(), EMAN::Dict::set_default(), and EMAN::Ctf::voltage.

                                                           {
        if (!image) {
                LOGWARN("NULL Image");
                return NULL;
        }

        EMData *fft;
        if (!image->is_complex()) fft=image->do_fft();
        else fft=image->copy();

        EMAN2Ctf ctf;
        ctf.defocus=params["defocus"];
        ctf.bfactor=params["bfactor"];
        ctf.ampcont=params.set_default("ampcont",10.0f);
        ctf.voltage=params.set_default("voltage",200.0f);
        ctf.cs=params.set_default("cs",2.0);
        ctf.apix=params.set_default("apix",image->get_attr_default("apix_x",1.0));
        ctf.dsbg=1.0/(ctf.apix*fft->get_ysize()*4.0);           //4x oversampling

        float noiseamp=params.set_default("noiseamp",0.0f);
        float noiseampwhite=params.set_default("noiseampwhite",0.0f);

        // compute and apply the CTF
        vector <float> ctfc = ctf.compute_1d(fft->get_ysize()*6,ctf.dsbg,ctf.CTF_AMP,NULL); // *6 goes to corner, remember you provide 2x the number of points you need

//      printf("%1.3f\t%1.3f\t%1.3f\t%1.3f\t%1.3f\t%d\n",ctf.defocus,ctf.bfactor,ctf.ampcont,ctf.dsbg,ctf.apix,fft->get_ysize());
//      FILE *out=fopen("x.txt","w");
//      for (int i=0; i<ctfc.size(); i++) fprintf(out,"%f\t%1.3g\n",0.25*i/(float)fft->get_ysize(),ctfc[i]);
//      fclose(out);

        fft->apply_radial_func(0,0.25f/fft->get_ysize(),ctfc,1);

        // Add noise
        if (noiseamp!=0 || noiseampwhite!=0) {
                EMData *noise = new EMData(image->get_ysize(),image->get_ysize(),1);
                noise->process_inplace("testimage.noise.gauss");
                noise->do_fft_inplace();

                // White noise
                if (noiseampwhite!=0) {
                        noise->mult((float)noiseampwhite*15.0f);                // The 15.0 is to roughly compensate for the stronger pink noise curve
                        fft->add(*noise);
                        noise->mult((float)1.0/(noiseampwhite*15.0f));
                }

                // Pink noise
                if (noiseamp!=0) {
                        vector <float> pinkbg;
                        pinkbg.resize(500);
                        float nyimg=0.5f/ctf.apix;      // image nyquist
                        // This pink curve came from a typical image in the GroEL 4A data set
                        for (int i=0; i<500; i++) pinkbg[i]=noiseamp*(44.0f*exp(-5.0f*nyimg*i/250.0f)+10.0f*exp(-90.0f*nyimg*i/250.0f));                // compute curve to image Nyquist*2
                        noise->apply_radial_func(0,.002f,pinkbg,1);             // Image nyquist is at 250 -> 0.5
                        fft->add(*noise);
                }

        }

        EMData *ret=fft->do_ift();
        delete fft;

        return ret;
}
void CtfSimProcessor::process_inplace ( EMData image) [virtual]

To process an image in-place.

For those processors which can only be processed out-of-place, override this function to just print out some error message to remind user call the out-of-place version.

Parameters:
imageThe image to be processed.

Implements EMAN::Processor.

Definition at line 5719 of file processor.cpp.

References EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::Processor::process(), and EMAN::EMData::update().

                                                   {
        EMData *tmp=process(image);
        memcpy(image->get_data(),tmp->get_data(),(size_t)image->get_xsize()*image->get_ysize()*image->get_zsize()*sizeof(float));
        delete tmp;
        image->update();
        return;
}

Member Data Documentation

const string CtfSimProcessor::NAME = "math.simulatectf" [static]

Definition at line 884 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files: