#include <processor.h>
Inheritance diagram for EMAN::LowpassAutoBProcessor:
Public Member Functions | |
string | get_name () const |
Get the processor's name. | |
string | get_desc () const |
Get the descrition of this specific processor. | |
virtual TypeDict | get_param_types () const |
Get processor parameter information in a dictionary. | |
Static Public Member Functions | |
static Processor * | NEW () |
Static Public Attributes | |
static const string | NAME = "filter.lowpass.autob" |
Protected Member Functions | |
virtual void | preprocess (EMData *image) |
void | create_radial_func (vector< float > &radial_mask, EMData *image) const |
Definition at line 982 of file processor.h.
|
Implements EMAN::FourierAnlProcessor. Definition at line 623 of file processor.cpp. References B, EMAN::Util::calc_least_square_fit(), EMAN::EMData::get_attr(), EMAN::EMData::get_xsize(), ImageFormatException, log(), EMAN::Processor::params, EMAN::Util::save_data(), EMAN::Dict::set_default(), x, and y. 00623 { 00624 float apix=(float)image->get_attr("apix_x"); 00625 int verbose=(int)params["verbose"]; 00626 // int adaptnoise=params.set_default("adaptnoise",0); 00627 float noisecutoff=(float)params.set_default("noisecutoff",0.0); 00628 if (apix<=0 || apix>7.0f) throw ImageFormatException("0 < apix_x < 7.0"); 00629 float ds=1.0f/(apix*image->get_xsize()); // 0.5 is because radial mask is 2x oversampled 00630 unsigned int start=(int)floor(1.0/(15.0*ds)); 00631 unsigned int end=radial_mask.size()-2; 00632 if (noisecutoff>0) end=(int)floor(noisecutoff/ds); 00633 if (end>radial_mask.size()-2) { 00634 printf("WARNING: specified noisecutoff too close to Nyquist, reset !"); 00635 end=radial_mask.size()-2; 00636 } 00637 if (end<start+2) { 00638 printf("WARNING: noise cutoff too close to 15 A ! Results will not be good..."); 00639 start=end-5; 00640 } 00641 00642 FILE *out=NULL; 00643 if (verbose>2) out=fopen("fitplot.txt","w"); 00644 int N=(radial_mask.size()-start-2); 00645 float *x=(float *)malloc(N*sizeof(float)); 00646 float *y=(float *)malloc(N*sizeof(float)); 00647 float *dy=(float *)malloc(N*sizeof(float)); 00648 for (unsigned int i=start; i<radial_mask.size()-2; i++ ) { // -2 is arbitrary because sometimes the last pixel or two have funny values 00649 x[i-start]=ds*ds*i*i; 00650 if (radial_mask[i]>0) y[i-start]=log(radial_mask[i]); // ok 00651 else if (i>start) y[i-start]=y[i-start-1]; // not good 00652 else y[i-start]=0.0; // bad 00653 if (i<radial_mask.size()-3) dy[i-start]=y[i-start]-y[i-start-1]; // creates a 'derivative' of sorts, for use in adaptnoise 00654 if (out) fprintf(out,"%f\t%f\n",x[i-start],y[i-start]); 00655 } 00656 if (out) fclose(out); 00657 00658 float slope=0,intercept=0; 00659 Util::calc_least_square_fit(end-start, x,y,&slope,&intercept,1); 00660 00661 if (verbose) printf("slope=%f intercept=%f\n",slope,intercept); 00662 00663 float B=(float)params["bfactor"]+slope*4.0f/2.0f; // *4 is for Henderson definition, 2.0 is for intensity vs amplitude 00664 float B2=(float)params["bfactor"]; 00665 00666 if (verbose) printf("User B = %1.2f Corrective B = %1.2f Total B=%1.3f\n",(float)params["bfactor"],slope*2.0,B); 00667 00668 float cutval=exp(-B*pow(end*ds,2.0f)/4.0f)/exp(-B2*pow(end*ds,2.0f)/4.0f); 00669 for (unsigned int i=0; i<radial_mask.size(); i++) { 00670 if (i<=end) radial_mask[i]=exp(-B*pow(i*ds,2.0f)/4.0f); 00671 else radial_mask[i]=cutval*exp(-B2*pow(i*ds,2.0f)/4.0f); 00672 } 00673 if (verbose>1) Util::save_data(0,ds,radial_mask,"filter.txt"); 00674 00675 free(x); 00676 free(y); 00677 free(dy); 00678 }
|
|
Get the descrition of this specific processor. This function must be overwritten by a subclass.
Implements EMAN::Processor. Definition at line 995 of file processor.h. 00996 { 00997 return "This processor sharpens a map based on the concept that the power spectrum should be roughly flat over the ~15 A-Nyquist resolution range, then combines this inverse B-factor with the specified low-pass Gaussian filter parameters to produce a single aggregate Gaussian filter."; 00998 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 985 of file processor.h. References NAME. 00986 { 00987 return NAME; 00988 }
|
|
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::FourierAnlProcessor. Definition at line 1002 of file processor.h. References EMAN::EMObject::FLOAT, EMAN::FourierAnlProcessor::get_param_types(), EMAN::EMObject::INT, and EMAN::TypeDict::put(). 01003 { 01004 TypeDict d = FourierAnlProcessor::get_param_types(); 01005 d.put("bfactor", EMObject::FLOAT, "B-factor in terms of e^-(B s^2/4)"); 01006 d.put("noisecutoff", EMObject::FLOAT, "Spatial frequency past which inverse-B will not be applied"); 01007 // d.put("adaptnoise", EMObject::INT, "Dual linear fit separating lower resolution signal from higher resolution noise. Noise region not upweighted."); 01008 d.put("verbose", EMObject::INT, "Print information about the determined B-factor"); 01009 return d; 01010 }
|
|
Definition at line 990 of file processor.h. 00991 { 00992 return new LowpassAutoBProcessor(); 00993 }
|
|
Reimplemented from EMAN::FourierAnlProcessor. Definition at line 1013 of file processor.h. References EMAN::EMData::get_attr(), EMAN::EMData::get_attr_dict(), EMAN::Dict::has_key(), EMAN::Processor::params, and EMAN::EMData::set_attr(). 01013 { 01014 if(params.has_key("apix")) { 01015 image->set_attr("apix_x", (float)params["apix"]); 01016 image->set_attr("apix_y", (float)params["apix"]); 01017 image->set_attr("apix_z", (float)params["apix"]); 01018 } 01019 float apix=(float)image->get_attr("apix_x"); 01020 01021 const Dict dict = image->get_attr_dict(); 01022 if (params.has_key("cutoff_abs")) { 01023 params["bfactor"] = pow(apix/(float)params["cutoff_abs"],2.0f); 01024 } 01025 else if( params.has_key("cutoff_freq") ) { 01026 float val = (float)params["cutoff_freq"] * apix; 01027 params["cutoff_abs"] = val; 01028 params["bfactor"] = pow(apix/(float)params["cutoff_abs"],2.0f); 01029 } 01030 else if( params.has_key("cutoff_pixels") ) { 01031 float val = 0.5f*(float)params["cutoff_pixels"] / (float)dict["nx"]; 01032 params["cutoff_abs"] = val; 01033 params["bfactor"] = pow(apix/(float)params["cutoff_abs"],2.0f); 01034 } 01035 }
|
|
Definition at line 1000 of file processor.h. Referenced by get_name(). |