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

Mask out (or in) peaks in Fourier space based on the average amplitude at each spatial frequency. More...

#include <processor.h>

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

Public Member Functions

void process_inplace (EMData *image)
 To process an image in-place. More...
 
string get_name () const
 Get the processor's name. More...
 
string get_desc () const
 Get the descrition of this specific processor. More...
 
TypeDict get_param_types () const
 Get processor parameter information in a dictionary. More...
 
- Public Member Functions inherited from EMAN::Processor
virtual ~Processor ()
 
virtual EMDataprocess (const EMData *const image)
 To proccess an image out-of-place. More...
 
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 = "mask.fft.peak"
 

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

Mask out (or in) peaks in Fourier space based on the average amplitude at each spatial frequency.

Definition at line 5387 of file processor.h.

Member Function Documentation

◆ get_desc()

string EMAN::FFTPeakProcessor::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 5401 of file processor.h.

5402 {
5403 return "Identifies pixels corresponding to peaks in Fourier space based on the mean & standard deviation of the corresponding Fourier amplitude in each ring/shell. These pixels are masked out or in depending on options.";
5404 }

◆ get_name()

string EMAN::FFTPeakProcessor::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 5392 of file processor.h.

5393 {
5394 return NAME;
5395 }
static const string NAME
Definition: processor.h:5415

References NAME.

◆ get_param_types()

TypeDict EMAN::FFTPeakProcessor::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 5406 of file processor.h.

5407 {
5408 TypeDict d;
5409 d.put("thresh_sigma", EMObject::FLOAT, "Values above mean + thresh_sigma * sigma are identified. Default 1.0");
5410 d.put("removepeaks", EMObject::BOOL, "Instead of keeping peaks and removing everything else, this will remove peaks and keep everything else.");
5411 d.put("to_mean", EMObject::BOOL, "Instead of setting identified pixels to zero, set the amplitude to the mean amplitude.");
5412 return d;
5413 }
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::BOOL, EMAN::EMObject::FLOAT, and EMAN::TypeDict::put().

◆ NEW()

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

Definition at line 5396 of file processor.h.

5397 {
5398 return new FFTPeakProcessor();
5399 }
Mask out (or in) peaks in Fourier space based on the average amplitude at each spatial frequency.
Definition: processor.h:5388

◆ process_inplace()

void FFTPeakProcessor::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 906 of file processor.cpp.

907{
908 EMData *fft;
909
910 if (!image) throw InvalidParameterException("FFTPeakProcessor: no image provided");
911 if (!image->is_complex()) fft = image->do_fft();
912 else fft = image;
913
914 int nx=fft->get_xsize();
915 int ny=fft->get_ysize();
916 int nz=fft->get_zsize();
917 float thresh_sigma = (float)params.set_default("thresh_sigma", 1.0);
918 bool removepeaks = (bool)params.set_default("removepeaks",0);
919 bool to_mean = (bool)params.set_default("to_mean",0);
920
921 vector<float> amp=fft->calc_radial_dist(nx/2,0,1,0); // amplitude
922 vector<float> thr=fft->calc_radial_dist(nx/2,0,1,1); // start with inten (avg of amp^2)
923
924 for (int i=0; i<nx/2; i++) thr[i]=thresh_sigma*sqrt(thr[i]-amp[i]*amp[i])+amp[i]; // sqrt(inten-amp^2) is st
925
926 if (nz>1) {
927 for (int z=-nz/2; z<nz/2; z++) {
928 for (int y=-ny/2; y<ny/2; y++) {
929 for (int x=0; x<nx/2; x++) {
930 float r2=Util::hypot3(x,y,z);
931 int r=int(r2);
932 if (r>=nx/2) continue;
933 complex<float> v=fft->get_complex_at(x,y,z);
934 float va=std::abs(v);
935 if (va>=thr[r]) {
936 if (removepeaks) {
937 if (to_mean) {
938 v*=amp[r]/va;
939 fft->set_complex_at(x,y,z,v);
940 }
941 else fft->set_complex_at(x,y,z,0.0);
942 }
943 }
944 else {
945 if (!removepeaks) {
946 if (to_mean) {
947 v*=amp[r]/va;
948 fft->set_complex_at(x,y,z,v);
949 }
950 else fft->set_complex_at(x,y,z,0.0);
951 }
952 }
953 }
954 }
955 }
956 }
957 else {
958 for (int y=-ny/2; y<ny/2; y++) {
959 for (int x=0; x<nx/2; x++) {
960 int r=Util::hypot_fast_int(x,y);
961 if (r>=nx/2) continue;
962 complex<float> v=fft->get_complex_at(x,y);
963 float va=std::abs(v);
964 if (va>=thr[r]) {
965 if (removepeaks) {
966 if (to_mean) {
967 v*=amp[r]/va;
968 fft->set_complex_at(x,y,v);
969 }
970 else fft->set_complex_at(x,y,0.0);
971 }
972 }
973 else {
974 if (!removepeaks) {
975 if (to_mean) {
976 v*=amp[r]/va;
977 fft->set_complex_at(x,y,v);
978 }
979 else fft->set_complex_at(x,y,0.0);
980 }
981 }
982 }
983 }
984 }
985
986 if (fft!=image) {
987 EMData *ift=fft->do_ift();
988 memcpy(image->get_data(),ift->get_data(),(nx-2)*ny*nz*sizeof(float));
989 delete fft;
990 delete ift;
991 }
992 image->update();
993
994// image->update();
995}
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
vector< float > calc_radial_dist(int n, float x0, float dx, int inten)
calculates radial distribution.
Definition: emdata.cpp:2781
static short hypot_fast_int(int x, int y)
Euclidean distance in 2D for integers computed fast using a cached lookup table.
Definition: util.cpp:764
static float hypot3(int x, int y, int z)
Euclidean distance function in 3D: f(x,y,z) = sqrt(x*x + y*y + z*z);.
Definition: util.h:827
EMData * sqrt() const
return square root of current image
#define InvalidParameterException(desc)
Definition: exception.h:361
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

References EMAN::EMData::calc_radial_dist(), EMAN::Util::hypot3(), EMAN::Util::hypot_fast_int(), InvalidParameterException, EMAN::Processor::params, EMAN::Dict::set_default(), sqrt(), x, and y.

Member Data Documentation

◆ NAME

const string FFTPeakProcessor::NAME = "mask.fft.peak"
static

Definition at line 5415 of file processor.h.

Referenced by get_name().


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