Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

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

ProcessorNEW ()

Static Public Attributes

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 797 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 828 of file processor.h.

00829                 {
00830                         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. ";
00831                 }

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 800 of file processor.h.

00801                 {
00802                         return NAME;
00803                 }

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 809 of file processor.h.

References EMAN::TypeDict::put().

00810                 {
00811                         TypeDict d;
00812                         d.put("defocus", EMObject::FLOAT, "Defocus in microns (underfocus positive)");
00813                         d.put("ampcont", EMObject::FLOAT, "% amplitude contrast (0-100)");
00814                         d.put("bfactor", EMObject::FLOAT, "B-factor in A^2, uses MRC convention rather than EMAN1 convention");
00815                         d.put("noiseamp", EMObject::FLOAT, "Amplitude of the added empirical pink noise");
00816                         d.put("noiseampwhite", EMObject::FLOAT, "Amplitude of added white noise");
00817                         d.put("voltage", EMObject::FLOAT, "Microscope voltage in KV");
00818                         d.put("cs", EMObject::FLOAT, "Cs of microscope in mm");
00819                         d.put("apix", EMObject::FLOAT, "A/pix of data");
00820                         return d;
00821                 }

Processor* EMAN::CtfSimProcessor::NEW  )  [inline, static]
 

Definition at line 823 of file processor.h.

00824                 {
00825                         return new CtfSimProcessor();
00826                 }

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:
image The 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 5513 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::EMData::process_inplace(), EMAN::Dict::set_default(), and EMAN::Ctf::voltage.

Referenced by process_inplace().

05513                                                            {
05514         if (!image) {
05515                 LOGWARN("NULL Image");
05516                 return NULL;
05517         }
05518 
05519         EMData *fft;
05520         if (!image->is_complex()) fft=image->do_fft();
05521         else fft=image->copy();
05522 
05523         EMAN2Ctf ctf;
05524         ctf.defocus=params["defocus"];
05525         ctf.bfactor=params["bfactor"];
05526         ctf.ampcont=params.set_default("ampcont",10.0f);
05527         ctf.voltage=params.set_default("voltage",200.0f);
05528         ctf.cs=params.set_default("cs",2.0);
05529         ctf.apix=params.set_default("apix",image->get_attr_default("apix_x",1.0));
05530         ctf.dsbg=1.0/(ctf.apix*fft->get_ysize()*4.0);           //4x oversampling
05531         
05532         float noiseamp=params.set_default("noiseamp",0.0f);
05533         float noiseampwhite=params.set_default("noiseampwhite",0.0f);
05534         
05535         // compute and apply the CTF
05536         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
05537 
05538 //      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());
05539 //      FILE *out=fopen("x.txt","w");
05540 //      for (int i=0; i<ctfc.size(); i++) fprintf(out,"%f\t%1.3g\n",0.25*i/(float)fft->get_ysize(),ctfc[i]);
05541 //      fclose(out);
05542         
05543         fft->apply_radial_func(0,0.25f/fft->get_ysize(),ctfc,1);
05544         
05545         // Add noise
05546         if (noiseamp!=0 || noiseampwhite!=0) {
05547                 EMData *noise = new EMData(image->get_ysize(),image->get_ysize(),1);
05548                 noise->process_inplace("testimage.noise.gauss");
05549                 noise->do_fft_inplace();
05550         
05551                 // White noise
05552                 if (noiseampwhite!=0) {
05553                         noise->mult((float)noiseampwhite*15.0f);                // The 15.0 is to roughly compensate for the stronger pink noise curve
05554                         fft->add(*noise);
05555                         noise->mult((float)1.0/(noiseampwhite*15.0f));
05556                 }
05557                 
05558                 // Pink noise
05559                 if (noiseamp!=0) {
05560                         vector <float> pinkbg;
05561                         pinkbg.resize(500);
05562                         float nyimg=0.5f/ctf.apix;      // image nyquist
05563                         // This pink curve came from a typical image in the GroEL 4A data set
05564                         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
05565                         noise->apply_radial_func(0,.002f,pinkbg,1);             // Image nyquist is at 250 -> 0.5
05566                         fft->add(*noise);
05567                 }
05568                 
05569         }
05570         
05571         EMData *ret=fft->do_ift();
05572         delete fft;
05573         
05574         return ret;
05575 }

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:
image The image to be processed.

Implements EMAN::Processor.

Definition at line 5505 of file processor.cpp.

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

05505                                                    {
05506         EMData *tmp=process(image);
05507         memcpy(image->get_data(),tmp->get_data(),image->get_xsize()*image->get_ysize()*image->get_zsize()*sizeof(float));
05508         delete tmp;
05509         image->update();
05510         return;
05511 }


Member Data Documentation

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

Definition at line 68 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Tue Jun 11 13:42:13 2013 for EMAN2 by  doxygen 1.3.9.1