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 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.

References NAME.

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::EMObject::FLOAT, and 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                 }

static 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 5511 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.

Referenced by process_inplace().

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

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 5503 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().

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


Member Data Documentation

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

Definition at line 833 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Fri Aug 10 16:35:34 2012 for EMAN2 by  doxygen 1.4.7