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

Uses math.sub.optimal to remove the density of the reference from the image as much as possible. More...

#include <cmp.h>

Inheritance diagram for EMAN::OptSubCmp:
Inheritance graph
Collaboration diagram for EMAN::OptSubCmp:
Collaboration graph

Public Member Functions

 OptSubCmp ()
float cmp (EMData *image, EMData *with) const
 To compare 'image' with another image passed in through its parameters. More...
string get_name () const
 Get the Cmp's name. More...
string get_desc () const
TypeDict get_param_types () const
 Get Cmp parameter information in a dictionary. More...
- Public Member Functions inherited from EMAN::Cmp
virtual ~Cmp ()
virtual Dict get_params () const
 Get the Cmp parameters in a key/value dictionary. More...
virtual void set_params (const Dict &new_params)
 Set the Cmp parameters using a key/value dictionary. More...

Static Public Member Functions

static CmpNEW ()

Static Public Attributes

static const string NAME = "optsub"

Additional Inherited Members

- Protected Member Functions inherited from EMAN::Cmp
void validate_input_args (const EMData *image, const EMData *with) const
- Protected Attributes inherited from EMAN::Cmp
Dict params

Detailed Description

Uses math.sub.optimal to remove the density of the reference from the image as much as possible.

What is left should be pure noise if there is a good match. If the match is not as good there should be additional residual power. This comparator returns the average residual power after subtraction weighted in various ways

Definition at line 524 of file cmp.h.

Constructor & Destructor Documentation

◆ OptSubCmp()

EMAN::OptSubCmp::OptSubCmp ( )

Definition at line 527 of file cmp.h.


Referenced by NEW().

Member Function Documentation

◆ cmp()

float OptSubCmp::cmp ( EMData image,
EMData with 
) const

To compare 'image' with another image passed in through its parameters.

An optional transformation may be used to transform the 2 images.

imageThe first image to be compared.
withThe second image to be comppared.
The comparison result. Smaller better by default

Implements EMAN::Cmp.

Definition at line 1575 of file cmp.cpp.

1578 validate_input_args(image, with);
1580// int snrweight = params.set_default("snrweight", 0);
1581// int ampweight = params.set_default("ampweight", 0);
1582// int sweight = params.set_default("sweight", 1);
1583// int nweight = params.set_default("nweight", 0);
1584 int ctfweight = params.set_default("ctfweight",0);
1585 int zeromask = params.set_default("zeromask",0);
1586// int swap = params.set_default("swap",0);
1587 float minres = params.set_default("minres",200.0f);
1588 float maxres = params.set_default("maxres",10.0f);
1589 EMData *mask = params.set_default("mask",(EMData *)NULL);
1591// float ds=1.0f/((float)image->get_attr("apix_x")*(int)image->get_ysize());
1592 float apix=(float)image->get_attr("apix_x");
1594 // Sometimes we will get the "raw" image with CTF as image and sometimes as with, we always want to subtract the less noisy
1595 // reference, so if one has CTF parameters (even if ctfweight isn't used) we always pass it in as the primary
1596 EMData *diff;
1597 if (image->has_attr("ctf")) diff=image->process("math.sub.optimal",Dict("ref",with,"return_presigma",1,"low_cutoff_frequency",apix/minres ,"high_cutoff_frequency",apix/maxres,"ctfweight",ctfweight));
1598 else diff=with->process("math.sub.optimal",Dict("ref",image,"return_presigma",1,"low_cutoff_frequency",apix/minres ,"high_cutoff_frequency",apix/maxres,"ctfweight",ctfweight));
1600 if (mask!=NULL) diff->mult(*mask);
1601 if (zeromask) {
1602 EMData *tmp=with->process("threshold.notzero");
1603 diff->mult(*tmp);
1604 delete tmp;
1605 }
1607// diff->process_inplace("filter.highpass.tophat",Dict("cutoff_freq",(float)1.0/minres));
1608// diff->process_inplace("filter.lowpass.tophat",Dict("cutoff_freq",(float)1.0/maxres));
1610 float ret=(float)diff->get_attr("sigma")/(float)diff->get_attr("sigma_presub");
1611 delete diff;
1612 return ret;
1615// EMData *diff=image->process("math.sub.optimal",Dict("ref",with,"return_fft",1));
1617// // Very expensive to use a mask, since it requires another ift/fft pair
1618// if (mask!=NULL) {
1619// EMData *tmp = diff->do_ift();
1620// tmp->mult(*mask);
1621// delete diff;
1622// diff=tmp->do_fft();
1623// delete tmp;
1624// }
1626// // This gives us basically the 1-D power spectrum of what's left after subtraction (and masking)
1627// vector<float> dist=diff->calc_radial_dist(diff->get_ysize()/2,0.0f,1.0f,1);
1628// int s0=int(floor(1.0/(minres*ds)));
1629// int s1=int(ceil(1.0/(maxres*ds)));
1630// if (s0<2) s0=2;
1632// if (s1<=s0) throw InvalidCallException("OptSubCmp error. minres must be greater than maxres.");
1633// // printf("%d %d\n",s0,s1);
1635// double sum=0.0f,sum2=0.0f;
1636// for (int i=s0; i<s1; i++) sum+=dist[i]*i;
1637// sum/=image->get_size()*s1;
1639// delete diff;
1640// return sum;
void validate_input_args(const EMData *image, const EMData *with) const
Definition: cmp.cpp:81
Dict params
Definition: cmp.h:132
Dict is a dictionary to store <string, EMObject> pair.
Definition: emobject.h:385
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
Definition: log.h:48

References ENTERFUNC, EMAN::Cmp::params, EMAN::Dict::set_default(), and EMAN::Cmp::validate_input_args().

◆ get_desc()

string EMAN::OptSubCmp::get_desc ( ) const

Implements EMAN::Cmp.

Definition at line 536 of file cmp.h.

537 {
538 return "Residual power left in the image after optimally subtracting the reference with math.sub.optimal. Smaller values indicate a closer match.";
539 }

◆ get_name()

string EMAN::OptSubCmp::get_name ( ) const

Get the Cmp's name.

Each Cmp is identified by a unique name.

The Cmp's name.

Implements EMAN::Cmp.

Definition at line 531 of file cmp.h.

532 {
533 return NAME;
534 }
static const string NAME
Definition: cmp.h:558

References NAME.

◆ get_param_types()

TypeDict EMAN::OptSubCmp::get_param_types ( ) const

Get Cmp parameter information in a dictionary.

Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.

A dictionary containing the parameter info.

Implements EMAN::Cmp.

Definition at line 546 of file cmp.h.

547 {
548 TypeDict d;
549 d.put("minres", EMObject::FLOAT, "Lowest resolution to use in comparison (soft cutoff). Requires accurate A/pix in image. <0 disables. Default=200");
550 d.put("maxres", EMObject::FLOAT, "Highest resolution to use in comparison (soft cutoff). Requires accurate A/pix in image. <0 disables. Default=10");
551 d.put("zeromask", EMObject::BOOL, "Treat zero regions in 'with' as a mask");
552 d.put("ctfweight", EMObject::BOOL, "Weight frequencies using CTF");
553// d.put("swap", EMObject::BOOL, "Swaps the identity of this and with, since A->B comparisons are not equivalent to B->A");
554 d.put("mask", EMObject::EMDATA, "Real space mask. Only computes the residual power under the mask. Significant speed penalty if specified. Default=None.");
555 return d;
556 }

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

◆ NEW()

static Cmp * EMAN::OptSubCmp::NEW ( )

Definition at line 541 of file cmp.h.

542 {
543 return new OptSubCmp();
544 }

References OptSubCmp().

Member Data Documentation


const string OptSubCmp::NAME = "optsub"

Definition at line 558 of file cmp.h.

Referenced by get_name().

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