EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
EMAN::FSCFourierProcessor Class Reference

This processor will apply a Wiener filter to a volume based on a provided FSC curve. More...

#include <processor.h>

Inheritance diagram for EMAN::FSCFourierProcessor:
Inheritance graph
[legend]
Collaboration diagram for EMAN::FSCFourierProcessor:
Collaboration graph
[legend]

Public Member Functions

virtual EMDataprocess (EMData const *image)
 To proccess an image out-of-place. More...
 
virtual void process_inplace (EMData *image)
 To process an image in-place. More...
 
virtual string get_name () const
 Get the processor's name. More...
 
virtual string get_desc () const
 Get the descrition of this specific processor. More...
 
virtual TypeDict get_param_types () const
 Get processor parameter information in a dictionary. More...
 
- Public Member Functions inherited from EMAN::Processor
virtual ~Processor ()
 
virtual void process_list_inplace (vector< EMData * > &images)
 To process multiple images using the same algorithm. More...
 
virtual Dict get_params () const
 Get the processor parameters in a key/value dictionary. More...
 
virtual void set_params (const Dict &new_params)
 Set the processor parameters using a key/value dictionary. More...
 

Static Public Member Functions

static ProcessorNEW ()
 
- Static Public Member Functions inherited from EMAN::Processor
static string get_group_desc ()
 Get the description of this group of processors. More...
 
static void EMFourierFilterInPlace (EMData *fimage, Dict params)
 Compute a Fourier-filter processed image in place. More...
 
static EMDataEMFourierFilter (EMData *fimage, Dict params)
 Compute a Fourier-processor processed image without altering the original image. More...
 

Static Public Attributes

static const string NAME = "filter.wiener.byfsc"
 

Additional Inherited Members

- Public Types inherited from EMAN::Processor
enum  fourier_filter_types {
  TOP_HAT_LOW_PASS , TOP_HAT_HIGH_PASS , TOP_HAT_BAND_PASS , TOP_HOMOMORPHIC ,
  GAUSS_LOW_PASS , GAUSS_HIGH_PASS , GAUSS_BAND_PASS , GAUSS_INVERSE ,
  GAUSS_HOMOMORPHIC , BUTTERWORTH_LOW_PASS , BUTTERWORTH_HIGH_PASS , BUTTERWORTH_HOMOMORPHIC ,
  KAISER_I0 , KAISER_SINH , KAISER_I0_INVERSE , KAISER_SINH_INVERSE ,
  SHIFT , TANH_LOW_PASS , TANH_HIGH_PASS , TANH_HOMOMORPHIC ,
  TANH_BAND_PASS , RADIAL_TABLE , CTF_
}
 Fourier filter Processor type enum. More...
 
- Protected Attributes inherited from EMAN::Processor
Dict params
 

Detailed Description

This processor will apply a Wiener filter to a volume based on a provided FSC curve.

The assumption is that the FSC curve represents a "gold standard" FSC between two 1/2 sets, and that the filter is being applied to the combined average.

Parameters
snrmultThis multiplier is applied to the computed SNR before Wiener filtration. This permits the filter to be applied to 1/2 images, etc. Default=1.0
fscfileFile containing the FSC curve to use
sscaleThis rescales the S axis to produce empirical under/overfiltration. sscale=1.1 for example will extend the resolution (underfilter) by 10%. Default=1.0

Definition at line 7198 of file processor.h.

Member Function Documentation

◆ get_desc()

virtual string EMAN::FSCFourierProcessor::get_desc ( ) const
inlinevirtual

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

7215 {
7216 return "This processor will apply a Wiener filter to a volume based on a provided FSC curve. The assumption is that the FSC curve represents \
7217a gold standard FSC between two 1/2 sets, and that the filter is being applied to the combined average. Hence the default fscmult of 2, \
7218since the SSNR is being computed as FSC/(1-FSC). Ie - the SSNR of the combined halves is twice as high.";
7219 }

◆ get_name()

virtual string EMAN::FSCFourierProcessor::get_name ( ) const
inlinevirtual

Get the processor's name.

Each processor is identified by a unique name.

Returns
The processor's name.

Implements EMAN::Processor.

Definition at line 7204 of file processor.h.

7205 {
7206 return NAME;
7207 }
static const string NAME
Definition: processor.h:7231

References NAME.

◆ get_param_types()

virtual TypeDict EMAN::FSCFourierProcessor::get_param_types ( ) const
inlinevirtual

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

7222 {
7223 TypeDict d;
7224 d.put("snrmult", EMObject::FLOAT, "This multiplier is applied to the computed SNR before Wiener filtration. This permits the filter to be applied to 1/2 images, etc. Default=2.0");
7225 d.put("sscale", EMObject::FLOAT, "This rescales the S axis to produce empirical under/overfiltration. sscale=1.1 for example will extend the resolution (underfilter) by 10%. Default=1.0");
7226 d.put("maxfreq", EMObject::FLOAT, "This acts as a high resolution limit to prevent FSC artifacts from iteratively reinforcing themselves. Above this spatial frequency, the FSC is forced to decrease monotonically. Default=1.0");
7227 d.put("fscfile", EMObject::STRING, "filename of a file containing the FSC curve to use for the SNR computation");
7228 return d;
7229 }
TypeDict is a dictionary to store <string, EMObject::ObjectType> pair.
Definition: emobject.h:305
void put(const string &key, EMObject::ObjectType o, const string &desc="")
Definition: emobject.h:330

References EMAN::EMObject::FLOAT, EMAN::TypeDict::put(), and EMAN::EMObject::STRING.

◆ NEW()

static Processor * EMAN::FSCFourierProcessor::NEW ( )
inlinestatic

Definition at line 7209 of file processor.h.

7210 {
7211 return new FSCFourierProcessor();
7212 }
This processor will apply a Wiener filter to a volume based on a provided FSC curve.
Definition: processor.h:7199

◆ process()

EMData * FSCFourierProcessor::process ( 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
imageThe 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 7573 of file processor.cpp.

7574{
7575 const char *fsp = params["fscfile"];
7576 float snrmult = params.set_default("snrmult",1.5f);
7577 float sscale = params.set_default("sscale",1.0f);
7578 float maxfreq = params.set_default("maxfreq",1.0f);
7579
7580 XYData fsc;
7581 fsc.read_file(fsp);
7582 float nyquist=1.0/(2.0f*(float)image->get_attr("apix_x"));
7583
7584 float lf=1.0f;
7585 int N=(int)fsc.get_size();
7586 int localav=0; // once triggered, this uses a local average of 5 points instead of the point itself
7587 // While this could all be in one equation, the compiler will optimize it, and this is much more transparent
7588 for (int i=0; i<N; i++) {
7589 float s=i*nyquist/N;
7590 float f=fsc.get_y(i);
7591 float snr;
7592 if (s>=maxfreq && lf<f) f=lf*.9;
7593 if (f<0 && i>2) localav=1;
7594 if (localav==1 && i>N-3) f=lf;
7595 else if (localav==1) f=(fsc.get_y(i-2)+fsc.get_y(i-1)+fsc.get_y(i)+fsc.get_y(i+1)+fsc.get_y(i+2))/5.0f;
7596 else if (localav==2) f=.00001;
7597
7598 if (f>=1.0) f=.9999;
7599 if (f<0) { localav=2; f=.00001; }
7600
7601 snr=snrmult*f/(1.0-f); // if FSC==1, we just set it to 1000, which is large enough to make the Wiener filter effectively 1
7602 float wiener=snr*snr/(snr*snr+1);
7603 if (wiener<.001) wiener=.001; // we don't want to go all the way to zero. We leave behind just just a touch to preserve potential phase info
7604
7605 fsc.set_y(i,wiener);
7606 lf=f;
7607 }
7608 fsc.set_x(0,0); // just to make sure we have values to the origin.
7609// fsc.write_file("wiener.txt");
7610 FILE *out=fopen("wiener.txt","w");
7611 vector<float> wienerary(image->get_ysize());
7612 for (int i=0; i<image->get_ysize(); i++) {
7613 wienerary[i]=fsc.get_yatx(i*nyquist/image->get_ysize());
7614 fprintf(out,"%f\t%f\n",sscale*i*nyquist/image->get_ysize(),wienerary[i]);
7615 }
7616 fclose(out);
7617
7618 EMData *fft=image->do_fft();
7619 fft->apply_radial_func(0,sscale*0.5/(float)image->get_ysize(),wienerary);
7620
7621 EMData *ret=fft->do_ift();
7622 delete fft;
7623
7624 return ret;
7625}
type set_default(const string &key, type val)
Default setting behavior This can be achieved using a template - d.woolford Jan 2008 (before there wa...
Definition: emobject.h:569
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
void apply_radial_func(float x0, float dx, vector< float >array, bool interp=true)
multiplies by a radial function in fourier space.
Definition: emdata.cpp:2677
XYData defines a 1D (x,y) data set.
Definition: xydata.h:47
void set_x(size_t i, float x)
Definition: xydata.h:89
size_t get_size() const
Definition: xydata.h:127
float get_y(size_t i) const
Definition: xydata.h:95
float get_yatx(float x, bool outzero=true)
Definition: xydata.cpp:172
void set_y(size_t i, float y)
Definition: xydata.h:101
int read_file(const string &filename)
Definition: xydata.cpp:77

References EMAN::EMData::apply_radial_func(), EMAN::XYData::get_size(), EMAN::XYData::get_y(), EMAN::XYData::get_yatx(), EMAN::Processor::params, EMAN::XYData::read_file(), EMAN::Dict::set_default(), EMAN::XYData::set_x(), and EMAN::XYData::set_y().

Referenced by process_inplace().

◆ process_inplace()

void FSCFourierProcessor::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
imageThe image to be processed.

Implements EMAN::Processor.

Definition at line 7564 of file processor.cpp.

7565{
7566 EMData *tmp=process(image);
7567 size_t n = (size_t)image->get_xsize()*image->get_ysize()*image->get_zsize();
7568 memcpy(image->get_data(),tmp->get_data(),n*sizeof(float));
7569 image->update();
7570 delete tmp;
7571}
virtual EMData * process(EMData const *image)
To proccess an image out-of-place.
Definition: processor.cpp:7573

References process().

Member Data Documentation

◆ NAME

const string FSCFourierProcessor::NAME = "filter.wiener.byfsc"
static

Definition at line 7231 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files: