EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes
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]

List of all members.

Public Member Functions

virtual EMDataprocess (EMData const *image)
 To proccess an image out-of-place.
virtual void process_inplace (EMData *image)
 To process an image in-place.
virtual string get_name () const
 Get the processor's name.
virtual 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 ProcessorNEW ()

Static Public Attributes

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

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


Member Function Documentation

virtual string EMAN::FSCFourierProcessor::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 5582 of file processor.h.

                {
                        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 \
a 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, \
since the SSNR is being computed as FSC/(1-FSC). Ie - the SSNR of the combined halves is twice as high.";
                }
virtual string EMAN::FSCFourierProcessor::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 5572 of file processor.h.

References NAME.

                {
                        return NAME;
                }
virtual TypeDict EMAN::FSCFourierProcessor::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 5589 of file processor.h.

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

                {
                        TypeDict d;
                        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");
                        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");
                        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");
                        d.put("fscfile", EMObject::STRING, "filename of a file containing the FSC curve to use for the SNR computation");
                        return d;
                }
static Processor* EMAN::FSCFourierProcessor::NEW ( ) [inline, static]

Definition at line 5577 of file processor.h.

                {
                        return new FSCFourierProcessor();
                }
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 6165 of file processor.cpp.

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

{
        const char *fsp = params["fscfile"];
        float snrmult = params.set_default("snrmult",2.0f);
        float sscale = params.set_default("sscale",1.0f);
        float maxfreq = params.set_default("sscale",1.0f);

        XYData fsc;
        fsc.read_file(fsp);
        float nyquist=1.0/(2.0f*(float)image->get_attr("apix_x"));

        float lf=1.0f;
        int N=(int)fsc.get_size();
        int localav=0;                          // once triggered, this uses a local average of 5 points instead of the point itself
        // While this could all be in one equation, the compiler will optimize it, and this is much more transparent
        for (int i=0; i<N; i++) {
                if (localav==2) {
                        fsc.set_y(i,0.00001);
                        continue;
                }

                float s=i*nyquist/N;
                float f=fsc.get_y(i);
                float snr;
                if (s>=maxfreq && lf<f) f=lf;
                if (f<0 && i>2) localav=1;
                if (localav) 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;
                if (f>=1.0) snr=1000.0;
                else if (f<0) localav=2;
                else 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
                float wiener=snr*snr/(snr*snr+1);
                if (wiener<.00001) wiener=.00001;       // we don't want to go all the way to zero. We leave behind just just a touch to preserve potential phase info
                fsc.set_y(i,wiener);
                lf=f;
        }
        fsc.set_x(0,0);         // just to make sure we have values to the origin.
//      fsc.write_file("wiener.txt");
        FILE *out=fopen("wiener.txt","w");
        vector<float> wienerary(image->get_ysize());
        for (int i=0; i<image->get_ysize(); i++) {
                wienerary[i]=fsc.get_yatx(i*nyquist/image->get_ysize());
                fprintf(out,"%f\t%f\n",sscale*i*nyquist/image->get_ysize(),wienerary[i]);
        }
        fclose(out);

        EMData *fft=image->do_fft();
        fft->apply_radial_func(0,sscale*0.5/(float)image->get_ysize(),wienerary);

        EMData *ret=fft->do_ift();
        delete fft;

        return ret;
}
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 6156 of file processor.cpp.

References EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::Processor::process(), and EMAN::EMData::update().

{
        EMData *tmp=process(image);
        size_t n = (size_t)image->get_xsize()*image->get_ysize()*image->get_zsize();
        memcpy(image->get_data(),tmp->get_data(),n*sizeof(float));
        image->update();
        delete tmp;
}

Member Data Documentation

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

Definition at line 5599 of file processor.h.

Referenced by get_name().


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