EMAN::TomoDotCmp Class Reference

Use dot product but normalize based on characteristics of the missing wedge. More...

#include <cmp.h>

Inheritance diagram for EMAN::TomoDotCmp:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual float cmp (EMData *image, EMData *with) const
 To compare 'image' with another image passed in through its parameters.
virtual string get_name () const
 Get the Cmp's name.
virtual string get_desc () const
TypeDict get_param_types () const
 Get Cmp parameter information in a dictionary.

Static Public Member Functions

static CmpNEW ()

Static Public Attributes

static const string NAME = "dot.tomo"

Detailed Description

Use dot product but normalize based on characteristics of the missing wedge.

Author:
David Woolford (a port of Mike Schmid's code - Mike Schmid is the intellectual author)
Date:
2009-08-04
Parameters:
threshold threshold value to count large fourier amplitudes in the ccf image

Definition at line 271 of file cmp.h.


Member Function Documentation

float TomoDotCmp::cmp ( EMData image,
EMData with 
) const [virtual]

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

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

Parameters:
image The first image to be compared.
with The second image to be comppared.
Returns:
The comparison result. Smaller better by default

Implements EMAN::Cmp.

Definition at line 484 of file cmp.cpp.

References EMAN::EMData::calc_ccf(), EMAN::EMData::do_fft(), EMAN::EMData::dot(), ENTERFUNC, EMAN::EMData::get_size(), EMAN::EMData::get_value_at_wrap(), InvalidParameterException, norm(), EMAN::Cmp::params, EMAN::EMData::process_inplace(), EMAN::Dict::set_default(), and UnexpectedBehaviorException.

00485 {
00486         ENTERFUNC;
00487         float threshold = params.set_default("threshold",0.f);
00488         if (threshold < 0.0f) throw InvalidParameterException("The threshold parameter must be greater than or equal to zero");
00489 
00490         if ( threshold > 0) {
00491                 EMData* ccf = params.set_default("ccf",(EMData*) NULL);
00492                 bool ccf_ownership = false;
00493                 if (!ccf) {
00494                         ccf = image->calc_ccf(with);
00495                         ccf_ownership = true;
00496                 }
00497                 bool norm = params.set_default("norm",false);
00498                 if (norm) ccf->process_inplace("normalize");
00499                 int tx = params.set_default("tx",0); int ty = params.set_default("ty",0); int tz = params.set_default("tz",0);
00500                 float best_score = ccf->get_value_at_wrap(tx,ty,tz)/static_cast<float>(image->get_size());
00501                 EMData* ccf_fft = ccf->do_fft();// so cuda works, or else we could do an fft_inplace - though honestly doing an fft inplace is less efficient anyhow
00502                 if (ccf_ownership) delete ccf; ccf = 0;
00503                 ccf_fft->process_inplace("threshold.binary.fourier",Dict("value",threshold));
00504                 float map_sum =  ccf_fft->get_attr("mean");
00505                 if (map_sum == 0.0f) throw UnexpectedBehaviorException("The number of voxels in the Fourier image with an amplitude above your threshold is zero. Please adjust your parameters");
00506                 best_score /= map_sum;
00507                 delete ccf_fft; ccf_fft = 0;
00508                 return -best_score;
00509         } else {
00510                 return -image->dot(with);
00511         }
00512 
00513 
00514 }

virtual string EMAN::TomoDotCmp::get_desc (  )  const [inline, virtual]

Implements EMAN::Cmp.

Definition at line 281 of file cmp.h.

00282                 {
00283                         return "straight dot product with consideration given for the missing wedge - normalization is applied by detecting significantly large Fourier amplitudes in the cross correlation image";
00284                 }

virtual string EMAN::TomoDotCmp::get_name (  )  const [inline, virtual]

Get the Cmp's name.

Each Cmp is identified by a unique name.

Returns:
The Cmp's name.

Implements EMAN::Cmp.

Definition at line 276 of file cmp.h.

References NAME.

00277                 {
00278                         return NAME;
00279                 }

TypeDict EMAN::TomoDotCmp::get_param_types (  )  const [inline, virtual]

Get Cmp 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.

Implements EMAN::Cmp.

Definition at line 291 of file cmp.h.

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

00292                 {
00293                         TypeDict d;
00294                         d.put("threshold", EMObject::FLOAT,"Threshold applied to the Fourier amplitudes of the ccf image - helps to correct for the missing wedge.");
00295                         d.put("norm", EMObject::BOOL,"Whether the cross correlation image should be normalized. Default is false.");
00296                         d.put("ccf", EMObject::EMDATA,"The ccf image, can be provided if it already exists to avoid recalculating it");
00297                         d.put("tx", EMObject::INT, "The x location of the maximum in the ccf image. May be negative. Useful thing to supply if you know the maximum is not at the phase origin");
00298                         d.put("ty", EMObject::INT, "The y location of the maximum in the ccf image. May be negative. Useful thing to supply if you know the maximum is not at the phase origin");
00299                         d.put("tz", EMObject::INT, "The z location of the maximum in the ccf image. May be negative. Useful thing to supply if you know the maximum is not at the phase origin");
00300 
00301                         return d;
00302                 }

static Cmp* EMAN::TomoDotCmp::NEW (  )  [inline, static]

Definition at line 286 of file cmp.h.

00287                 {
00288                         return new TomoDotCmp();
00289                 }


Member Data Documentation

const string TomoDotCmp::NAME = "dot.tomo" [static]

Definition at line 304 of file cmp.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Mon Jul 19 12:42:26 2010 for EMAN2 by  doxygen 1.4.7