#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 | |
Processor * | NEW () |
Static Public Attributes | |
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 942 of file processor.h.
|
Implements EMAN::FourierAnlProcessor. Definition at line 621 of file processor.cpp. References B, EMAN::Util::calc_least_square_fit(), EMAN::EMData::get_attr(), EMAN::EMData::get_xsize(), ImageFormatException, log(), EMAN::Util::save_data(), EMAN::Dict::set_default(), EMAN::Dict::size(), x, and y. 00621 { 00622 float apix=(float)image->get_attr("apix_x"); 00623 int verbose=(int)params["verbose"]; 00624 // int adaptnoise=params.set_default("adaptnoise",0); 00625 float noisecutoff=(float)params.set_default("noisecutoff",0.0); 00626 if (apix<=0 || apix>7.0) throw ImageFormatException("0 < apix_x < 7.0"); 00627 float ds=1.0/(apix*image->get_xsize()); // 0.5 is because radial mask is 2x oversampled 00628 int start=(int)floor(1.0/(15.0*ds)); 00629 int end=radial_mask.size()-2; 00630 if (noisecutoff>0) end=(int)floor(noisecutoff/ds); 00631 if (end>radial_mask.size()-2) { 00632 printf("WARNING: specified noisecutoff too close to Nyquist, reset !"); 00633 end=radial_mask.size()-2; 00634 } 00635 if (end<start+2) { 00636 printf("WARNING: noise cutoff too close to 15 A ! Results will not be good..."); 00637 start=end-5; 00638 } 00639 00640 FILE *out=NULL; 00641 if (verbose>2) out=fopen("fitplot.txt","w"); 00642 int N=(radial_mask.size()-start-2); 00643 float *x=(float *)malloc(N*sizeof(float)); 00644 float *y=(float *)malloc(N*sizeof(float)); 00645 float *dy=(float *)malloc(N*sizeof(float)); 00646 for (int i=start; i<radial_mask.size()-2; i++ ) { // -2 is arbitrary because sometimes the last pixel or two have funny values 00647 x[i-start]=ds*ds*i*i; 00648 if (radial_mask[i]>0) y[i-start]=log(radial_mask[i]); // ok 00649 else if (i>start) y[i-start]=y[i-start-1]; // not good 00650 else y[i-start]=0.0; // bad 00651 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 00652 if (out) fprintf(out,"%f\t%f\n",x[i-start],y[i-start]); 00653 } 00654 if (out) fclose(out); 00655 00656 float slope=0,intercept=0; 00657 Util::calc_least_square_fit(end-start, x,y,&slope,&intercept,1); 00658 00659 if (verbose) printf("slope=%f intercept=%f\n",slope,intercept); 00660 00661 float B=(float)params["bfactor"]+slope*4.0/2.0; // *4 is for Henderson definition, 2.0 is for intensity vs amplitude 00662 float B2=(float)params["bfactor"]; 00663 00664 if (verbose) printf("User B = %1.2f Corrective B = %1.2f Total B=%1.3f\n",(float)params["bfactor"],slope*2.0,B); 00665 00666 float cutval=exp(-B*pow(end*ds,2.0f)/4.0f)/exp(-B2*pow(end*ds,2.0f)/4.0f); 00667 for (int i=0; i<radial_mask.size(); i++) { 00668 if (i<=end) radial_mask[i]=exp(-B*pow(i*ds,2.0f)/4.0f); 00669 else radial_mask[i]=cutval*exp(-B2*pow(i*ds,2.0f)/4.0f); 00670 } 00671 if (verbose>1) Util::save_data(0,ds,radial_mask,"filter.txt"); 00672 00673 free(x); 00674 free(y); 00675 free(dy); 00676 }
|
|
Get the descrition of this specific processor. This function must be overwritten by a subclass.
Implements EMAN::Processor. Definition at line 955 of file processor.h. 00956 { 00957 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."; 00958 }
|
|
Get the processor's name. Each processor is identified by a unique name.
Implements EMAN::Processor. Definition at line 945 of file processor.h. 00946 {
00947 return NAME;
00948 }
|
|
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 962 of file processor.h. References EMAN::TypeDict::put(). 00963 { 00964 TypeDict d = FourierAnlProcessor::get_param_types(); 00965 d.put("bfactor", EMObject::FLOAT, "B-factor in terms of e^-(B s^2/4)"); 00966 d.put("noisecutoff", EMObject::FLOAT, "Spatial frequency past which inverse-B will not be applied"); 00967 // d.put("adaptnoise", EMObject::INT, "Dual linear fit separating lower resolution signal from higher resolution noise. Noise region not upweighted."); 00968 d.put("verbose", EMObject::INT, "Print information about the determined B-factor"); 00969 return d; 00970 }
|
|
Definition at line 950 of file processor.h. 00951 { 00952 return new LowpassAutoBProcessor(); 00953 }
|
|
Reimplemented from EMAN::FourierAnlProcessor. Definition at line 973 of file processor.h. References EMAN::EMData::get_attr(), EMAN::EMData::get_attr_dict(), and EMAN::EMData::set_attr(). 00973 { 00974 if(params.has_key("apix")) { 00975 image->set_attr("apix_x", (float)params["apix"]); 00976 image->set_attr("apix_y", (float)params["apix"]); 00977 image->set_attr("apix_z", (float)params["apix"]); 00978 } 00979 float apix=(float)image->get_attr("apix_x"); 00980 00981 const Dict dict = image->get_attr_dict(); 00982 if (params.has_key("cutoff_abs")) { 00983 params["bfactor"] = pow(apix/(float)params["cutoff_abs"],2.0f); 00984 } 00985 else if( params.has_key("cutoff_freq") ) { 00986 float val = (float)params["cutoff_freq"] * apix; 00987 params["cutoff_abs"] = val; 00988 params["bfactor"] = pow(apix/(float)params["cutoff_abs"],2.0f); 00989 } 00990 else if( params.has_key("cutoff_pixels") ) { 00991 float val = 0.5f*(float)params["cutoff_pixels"] / (float)dict["nx"]; 00992 params["cutoff_abs"] = val; 00993 params["bfactor"] = pow(apix/(float)params["cutoff_abs"],2.0f); 00994 } 00995 }
|
|
Definition at line 226 of file processor.cpp. |