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

Sets the structure factor To match a second provided image/volume. More...

#include <processor.h>

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

Public Member Functions

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::FourierAnlProcessor
void process_inplace (EMData *image)
 To process an image in-place. 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::FourierAnlProcessor
static string get_group_desc ()
 
- 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.matchto"
 

Protected Member Functions

void create_radial_func (vector< float > &radial_mask, EMData *image) const
 
- Protected Member Functions inherited from EMAN::FourierAnlProcessor
virtual void preprocess (EMData *)
 

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

Sets the structure factor To match a second provided image/volume.

Parameters
toEMData object to match to. Make sure apix values are set properly

Definition at line 7870 of file processor.h.

Member Function Documentation

◆ create_radial_func()

void MatchSFProcessor::create_radial_func ( vector< float > &  radial_mask,
EMData image 
) const
protectedvirtual

Implements EMAN::FourierAnlProcessor.

Definition at line 8226 of file processor.cpp.

8226 {
8227 // The radial mask comes in with the existing radial image profile
8228 // The radial mask runs from 0 to the 1-D Nyquist (it leaves out the corners in Fourier space)
8229
8230 EMData *to = params["to"];
8231 float apixto = to->get_attr("apix_x");
8232 bool bydot = params.set_default("bydot",false);
8233 float keephires = params.set_default("keephires",false);
8234
8235 if (to->get_ysize() != image->get_ysize()) throw ImageDimensionException("Fatal Error: filter.matchto - image sizes must match");
8236
8237 // This method is similar to that used by math.sub.optimal
8238 // It scales such that the average dot product at each resolution is matched,
8239 // but negative values (phase flips) are set to zero.
8240 if (bydot) {
8241 // Note that 'image' is guaranteed to be the FFT already
8242 EMData *tofft;
8243 if (to->is_complex()) tofft=to;
8244 else tofft=to->do_fft();
8245
8246 float cornerscale;
8247 if (image->get_zsize()>1) cornerscale=sqrt(3.0);
8248 else cornerscale=sqrt(2.0);
8249
8250 int ny=image->get_ysize();
8251 int ny2=(int)floor(image->get_ysize()*cornerscale/2);
8252 vector <float>norm(ny2+1);
8253 for (int i=0; i<ny2; i++) norm[i]=rad[i]=0;
8254
8255 for (int y=-ny; y<ny; y++) {
8256 for (int x=0; x<ny; x++) { // intentionally skipping the final pixel in x
8257 int r=int(Util::hypot_fast(x,y));
8258 if (r>ny2) continue;
8259 std::complex<float> v1=image->get_complex_at(x,y);
8260 std::complex<float> v2=tofft->get_complex_at(x,y);
8261 rad[r]+=(double)(v1.real()*v2.real()+v1.imag()*v2.imag());
8262 norm[r]+=(double)(v2.real()*v2.real()+v2.imag()*v2.imag());
8263 }
8264 }
8265 float radmean=0.0f;
8266 for (int i=0; i<ny2; i++) {
8267 rad[i]=(rad[i]/norm[i]<0)?0.0:rad[i]/norm[i];
8268 radmean+=rad[i];
8269 }
8270 radmean/=ny2;
8271
8272 if (keephires) {
8273 for (int i=0; i<ny2; i++) {
8274 if (rad[i]<radmean/100.0) rad[i]=radmean/100.0;
8275 }
8276 }
8277
8278 if (!to->is_complex()) delete tofft;
8279 return;
8280 }
8281
8282 // This simply divides one radial intensity profile by the other
8283 if (to->is_complex()) {
8284 vector<float> rd=to->calc_radial_dist(rad.size(),0,1.0f,1);
8285 for (size_t i=0; i<rd.size(); ++i) {
8286 if (rad[i]>0) rad[i]=sqrt(rd[i]/rad[i]);
8287 }
8288 }
8289 else {
8290 EMData *tmp=to->do_fft();
8291 vector<float> rd=tmp->calc_radial_dist(rad.size(),0,1.0f,1);
8292 for (size_t i=0; i<rd.size(); ++i) {
8293 if (rad[i]>0) rad[i]=sqrt(rd[i]/rad[i]);
8294 }
8295 delete tmp;
8296 }
8297
8298 // This makes sure that the filter never falls below 0.01 of the mean filter value so we keep something at all resolutions
8299 if (keephires) {
8300 float radmean=0.0f;
8301 for (int i=0; i<rad.size(); i++) radmean+=rad[i];
8302 radmean/=rad.size();
8303 for (int i=0; i<rad.size(); i++) {
8304 if (rad[i]<radmean/100.0) rad[i]=radmean/100.0;
8305 }
8306 }
8307
8308
8309}
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 float hypot_fast(int x, int y)
Euclidean distance in 2D for integers computed fast using a cached lookup table.
Definition: util.cpp:742
EMData * sqrt() const
return square root of current image
#define ImageDimensionException(desc)
Definition: exception.h:166
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

References EMAN::EMData::calc_radial_dist(), EMAN::Util::hypot_fast(), ImageDimensionException, EMAN::Processor::params, EMAN::Dict::set_default(), sqrt(), x, and y.

◆ get_desc()

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

7880 {
7881 return "Filters the image so its 1-D power spectrum matches a second image. Optionally can incorporate a dot product to better match noise.";
7882 }

◆ get_name()

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

7875 {
7876 return NAME;
7877 }
static const string NAME
Definition: processor.h:7900

References NAME.

◆ get_param_types()

virtual TypeDict EMAN::MatchSFProcessor::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::FourierAnlProcessor.

Definition at line 7889 of file processor.h.

7890 {
7891 TypeDict d;
7892 d.put("to", EMObject::EMDATA, "The image to match with. Make sure apix values are correct.");
7893 d.put("bydot", EMObject::BOOL, "Rather than matching the intensity profile, uses the complex dot product as a function of resolution to match only the portion that agrees.");
7894 d.put("keephires", EMObject::BOOL, "If the reference being matched is heavily filtered, total information loss may occur at some resolutions. This insures that some information is kept at all resolutions.");
7895 d.put("return_radial", EMObject::BOOL, "Return the radial filter function as an attribute (filter_curve)");
7896 d.put("interpolate", EMObject::BOOL, "Whether or not to interpolate the radial scaling function. Default=true");
7897 return d;
7898 }
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::EMDATA, and EMAN::TypeDict::put().

◆ NEW()

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

Definition at line 7884 of file processor.h.

7885 {
7886 return new MatchSFProcessor();
7887 }
Sets the structure factor To match a second provided image/volume.
Definition: processor.h:7871

Member Data Documentation

◆ NAME

const string MatchSFProcessor::NAME = "filter.matchto"
static

Definition at line 7900 of file processor.h.

Referenced by get_name().


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