#include <processor.h>
Inheritance diagram for EMAN::CtfSimProcessor:
Public Member Functions | |
string | get_name () const |
Get the processor's name. | |
virtual EMData * | process (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 | |
Processor * | NEW () |
Static Public Attributes | |
const string | NAME = "math.simulatectf" |
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.
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 |
Definition at line 772 of file processor.h.
|
Get the descrition of this specific processor. This function must be overwritten by a subclass.
Implements EMAN::Processor. Definition at line 803 of file processor.h. 00804 { 00805 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. "; 00806 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 775 of file processor.h. 00776 {
00777 return NAME;
00778 }
|
|
Get processor parameter information in a dictionary. Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.
Reimplemented from EMAN::Processor. Definition at line 784 of file processor.h. References EMAN::TypeDict::put(). 00785 { 00786 TypeDict d; 00787 d.put("defocus", EMObject::FLOAT, "Defocus in microns (underfocus positive)"); 00788 d.put("ampcont", EMObject::FLOAT, "% amplitude contrast (0-100)"); 00789 d.put("bfactor", EMObject::FLOAT, "B-factor in A^2, uses MRC convention rather than EMAN1 convention"); 00790 d.put("noiseamp", EMObject::FLOAT, "Amplitude of the added empirical pink noise"); 00791 d.put("noiseampwhite", EMObject::FLOAT, "Amplitude of added white noise"); 00792 d.put("voltage", EMObject::FLOAT, "Microscope voltage in KV"); 00793 d.put("cs", EMObject::FLOAT, "Cs of microscope in mm"); 00794 d.put("apix", EMObject::FLOAT, "A/pix of data"); 00795 return d; 00796 }
|
|
Definition at line 798 of file processor.h. 00799 { 00800 return new CtfSimProcessor(); 00801 }
|
|
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.
Reimplemented from EMAN::Processor. Definition at line 5435 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(). 05435 { 05436 if (!image) { 05437 LOGWARN("NULL Image"); 05438 return NULL; 05439 } 05440 05441 EMData *fft; 05442 if (!image->is_complex()) fft=image->do_fft(); 05443 else fft=image->copy(); 05444 05445 EMAN2Ctf ctf; 05446 ctf.defocus=params["defocus"]; 05447 ctf.bfactor=params["bfactor"]; 05448 ctf.ampcont=params.set_default("ampcont",10.0); 05449 ctf.voltage=params.set_default("voltage",200.0); 05450 ctf.cs=params.set_default("cs",2.0); 05451 ctf.apix=params.set_default("apix",image->get_attr_default("apix_x",1.0)); 05452 ctf.dsbg=1.0/(ctf.apix*fft->get_ysize()*4.0); //4x oversampling 05453 05454 float noiseamp=params.set_default("noiseamp",0.0); 05455 float noiseampwhite=params.set_default("noiseampwhite",0.0); 05456 05457 // compute and apply the CTF 05458 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 05459 05460 // 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()); 05461 // FILE *out=fopen("x.txt","w"); 05462 // for (int i=0; i<ctfc.size(); i++) fprintf(out,"%f\t%1.3g\n",0.25*i/(float)fft->get_ysize(),ctfc[i]); 05463 // fclose(out); 05464 05465 fft->apply_radial_func(0,0.25/fft->get_ysize(),ctfc,1); 05466 05467 // Add noise 05468 if (noiseamp!=0 or noiseampwhite!=0) { 05469 EMData *noise = new EMData(image->get_ysize(),image->get_ysize(),1); 05470 noise->process_inplace("testimage.noise.gauss"); 05471 noise->do_fft_inplace(); 05472 05473 // White noise 05474 if (noiseampwhite!=0) { 05475 noise->mult((float)noiseampwhite*15.0f); // The 15.0 is to roughly compensate for the stronger pink noise curve 05476 fft->add(*noise); 05477 noise->mult((float)1.0/(noiseampwhite*15.0f)); 05478 } 05479 05480 // Pink noise 05481 if (noiseamp!=0) { 05482 vector <float> pinkbg; 05483 pinkbg.resize(500); 05484 float nyimg=0.5/ctf.apix; // image nyquist 05485 // This pink curve came from a typical image in the GroEL 4A data set 05486 for (int i=0; i<500; i++) pinkbg[i]=noiseamp*(44.0*exp(-5.0*nyimg*i/250.0)+10.0*exp(-90.0*nyimg*i/250.0)); // compute curve to image Nyquist*2 05487 noise->apply_radial_func(0,.002,pinkbg,1); // Image nyquist is at 250 -> 0.5 05488 fft->add(*noise); 05489 } 05490 05491 } 05492 05493 EMData *ret=fft->do_ift(); 05494 delete fft; 05495 05496 return ret; 05497 }
|
|
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.
Implements EMAN::Processor. Definition at line 5427 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(). 05427 { 05428 EMData *tmp=process(image); 05429 memcpy(image->get_data(),tmp->get_data(),image->get_xsize()*image->get_ysize()*image->get_zsize()*sizeof(float)); 05430 delete tmp; 05431 image->update(); 05432 return; 05433 }
|
|
Definition at line 68 of file processor.cpp. |