EMAN::RT3DSphereAligner Class Reference

3D rotational and translational alignment using spherical sampling, can reduce the search space based on symmetry. More...

#include <aligner.h>

Inheritance diagram for EMAN::RT3DSphereAligner:

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

Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual EMDataalign (EMData *this_img, EMData *to_img, const string &cmp_name, const Dict &cmp_params) const
 See Aligner comments for more details.
virtual EMDataalign (EMData *this_img, EMData *to_img) const
 See Aligner comments for more details.
virtual vector< Dictxform_align_nbest (EMData *this_img, EMData *to_img, const unsigned int nsoln, const string &cmp_name, const Dict &cmp_params) const
 See Aligner comments for more details.
virtual string get_name () const
 Get the Aligner's name.
virtual string get_desc () const
virtual TypeDict get_param_types () const

Static Public Member Functions

static AlignerNEW ()


Detailed Description

3D rotational and translational alignment using spherical sampling, can reduce the search space based on symmetry.

can also make use of different OrientationGenerators (random, for example) 160-180% more efficient than the RT3DGridAligner

Author:
David Woolford
Date:
June 23 2009

Definition at line 701 of file aligner.h.


Member Function Documentation

EMData * RT3DSphereAligner::align ( EMData this_img,
EMData to_img,
const string &  cmp_name,
const Dict cmp_params 
) const [virtual]

See Aligner comments for more details.

Implements EMAN::Aligner.

Definition at line 1473 of file aligner.cpp.

References EMAN::EMData::process(), EMAN::EMData::set_attr(), t, and xform_align_nbest().

Referenced by align().

01474 {
01475 
01476         vector<Dict> alis = xform_align_nbest(this_img,to,1,cmp_name,cmp_params);
01477 
01478         Dict t;
01479         Transform* tr = (Transform*) alis[0]["xform.align3d"];
01480         t["transform"] = tr;
01481         EMData* soln = this_img->process("math.transform",t);
01482         soln->set_attr("xform.align3d",tr);
01483         delete tr; tr = 0;
01484 
01485         return soln;
01486 
01487 }

virtual EMData* EMAN::RT3DSphereAligner::align ( EMData this_img,
EMData to_img 
) const [inline, virtual]

See Aligner comments for more details.

Implements EMAN::Aligner.

Definition at line 710 of file aligner.h.

References align().

00711                         {
00712                                 return align(this_img, to_img, "sqeuclidean", Dict());
00713                         }

vector< Dict > RT3DSphereAligner::xform_align_nbest ( EMData this_img,
EMData to_img,
const unsigned int  nsoln,
const string &  cmp_name,
const Dict cmp_params 
) const [virtual]

See Aligner comments for more details.

Reimplemented from EMAN::Aligner.

Definition at line 1489 of file aligner.cpp.

References EMAN::EMData::calc_ccf(), EMAN::EMData::calc_max_location_wrap(), EMAN::EMData::cmp(), copy(), EMAN::Symmetry3D::gen_orientations(), EMAN::EMData::get_ndim(), EMAN::Dict::has_key(), ImageDimensionException, InvalidParameterException, EMAN::Aligner::params, phi, EMAN::EMData::process(), EMAN::Dict::set_default(), and t.

Referenced by align().

01489                                                                                                                                                                  {
01490 
01491         if ( this_img->get_ndim() != 3 || to->get_ndim() != 3 ) {
01492                 throw ImageDimensionException("This aligner only works for 3D images");
01493         }
01494 
01495         int searchx = 0;
01496         int searchy = 0;
01497         int searchz = 0;
01498 
01499         if (params.has_key("search")) {
01500                 vector<string> check;
01501                 check.push_back("searchx");
01502                 check.push_back("searchy");
01503                 check.push_back("searchz");
01504                 for(vector<string>::const_iterator cit = check.begin(); cit != check.end(); ++cit) {
01505                         if (params.has_key(*cit)) throw InvalidParameterException("The search parameter is mutually exclusive of the searchx, searchy, and searchz parameters");
01506                 }
01507                 int search  = params["search"];
01508                 searchx = search;
01509                 searchy = search;
01510                 searchz = search;
01511         } else {
01512                 searchx = params.set_default("searchx",3);
01513                 searchy = params.set_default("searchy",3);
01514                 searchz = params.set_default("searchz",3);
01515         }
01516 
01517         float rphi = params.set_default("rphi",180.f);
01518         float dphi = params.set_default("dphi",10.f);
01519         float threshold = params.set_default("threshold",0.f);
01520         if (threshold < 0.0f) throw InvalidParameterException("The threshold parameter must be greater than or equal to zero");
01521         bool verbose = params.set_default("verbose",false);
01522 
01523         vector<Dict> solns;
01524         if (nsoln == 0) return solns; // What was the user thinking?
01525         for (unsigned int i = 0; i < nsoln; ++i ) {
01526                 Dict d;
01527                 d["score"] = 1.e24;
01528                 Transform t; // identity by default
01529                 d["xform.align3d"] = &t; // deep copy is going on here
01530                 solns.push_back(d);
01531         }
01532 
01533         Dict d;
01534         d["inc_mirror"] = true; // This should probably always be true for 3D case. If it ever changes we might have to make inc_mirror a parameter
01535         if ( params.has_key("delta") && params.has_key("n") ) {
01536                 throw InvalidParameterException("The delta and n parameters are mutually exclusive in the RT3DSphereAligner aligner");
01537         } else if ( params.has_key("n") ) {
01538                 d["n"] = params["n"];
01539         } else {
01540                 // If they didn't specify either then grab the default delta - if they did supply delta we're still safe doing this
01541                 d["delta"] = params.set_default("delta",10.f);
01542         }
01543 
01544         Symmetry3D* sym = Factory<Symmetry3D>::get((string)params.set_default("sym","c1"));
01545         vector<Transform> transforms = sym->gen_orientations((string)params.set_default("orientgen","eman"),d);
01546 
01547         float verbose_alt = -1.0f;;
01548         for(vector<Transform>::const_iterator trans_it = transforms.begin(); trans_it != transforms.end(); trans_it++) {
01549                 Dict params = trans_it->get_params("eman");
01550                 float az = params["az"];
01551                 if (verbose) {
01552                         float alt = params["alt"];
01553                         if ( alt != verbose_alt ) {
01554                                 verbose_alt = alt;
01555                                 cout << "Trying angle " << alt << endl;
01556                         }
01557                 }
01558                 for( float phi = -rphi-az; phi <= rphi-az; phi += dphi ) {
01559                         params["phi"] = phi;
01560                         Transform t(params);
01561                         EMData* transformed = this_img->process("math.transform",Dict("transform",&t));
01562                         EMData* ccf = transformed->calc_ccf(to);
01563                         IntPoint point = ccf->calc_max_location_wrap(searchx,searchy,searchz);
01564                         Dict altered_cmp_params(cmp_params);
01565                         if (cmp_name == "dot.tomo") {
01566                                 altered_cmp_params["ccf"] = ccf;
01567                                 altered_cmp_params["tx"] = point[0];
01568                                 altered_cmp_params["ty"] = point[1];
01569                                 altered_cmp_params["tz"] = point[2];
01570                         }
01571 
01572                         float best_score = transformed->cmp(cmp_name,to,altered_cmp_params);
01573                         delete transformed; transformed =0;
01574                         delete ccf; ccf =0;
01575 
01576                         unsigned int j = 0;
01577                         for ( vector<Dict>::iterator it = solns.begin(); it != solns.end(); ++it, ++j ) {
01578                                 if ( (float)(*it)["score"] > best_score ) { // Note greater than - EMAN2 preferes minimums as a matter of policy
01579                                         vector<Dict>::reverse_iterator rit = solns.rbegin();
01580                                         copy(rit+1,solns.rend()-j,rit);
01581                                         Dict& d = (*it);
01582                                         d["score"] = best_score;
01583                                         d["xform.align3d"] = &t; // deep copy is going on here
01584                                         break;
01585                                 }
01586                         }
01587 
01588                 }
01589         }
01590         delete sym; sym = 0;
01591         return solns;
01592 
01593 }

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

Get the Aligner's name.

Each Aligner is identified by a unique name.

Returns:
The Aligner's name.

Implements EMAN::Aligner.

Definition at line 720 of file aligner.h.

00721                         {
00722                                 return "rt.3d.sphere";
00723                         }

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

Implements EMAN::Aligner.

Definition at line 725 of file aligner.h.

00726                         {
00727                                 return "3D rotational and translational alignment using spherical sampling. Can reduce the search space if symmetry is supplied";
00728                         }

static Aligner* EMAN::RT3DSphereAligner::NEW (  )  [inline, static]

Definition at line 730 of file aligner.h.

00731                         {
00732                                 return new RT3DSphereAligner();
00733                         }

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

Implements EMAN::Aligner.

Definition at line 735 of file aligner.h.

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

00736                         {
00737                                 TypeDict d;
00738                                 d.put("sym", EMObject::STRING,"The symmtery to use as the basis of the spherical sampling. Default is c1 (asymmetry).");
00739                                 d.put("orientgen", EMObject::STRING,"Advanced. The orientation generation strategy. Default is eman");
00740                                 d.put("delta", EMObject::FLOAT,"Angle the separates points on the sphere. This is exclusive of the \'n\' paramater. Default is 10");
00741                                 d.put("n", EMObject::INT,"An alternative to the delta argument, this is the number of points you want generated on the sphere. Default is OFF");
00742                                 d.put("dphi", EMObject::FLOAT,"The angle increment in the phi direction. Default is 10.");
00743                                 d.put("rphi", EMObject::FLOAT,"The range of angles to sample in the phi direction. Default is 180.");
00744                                 d.put("search", EMObject::INT,"The maximum length of the detectable translational shift - if you supply this parameter you can not supply the maxshiftx, maxshifty or maxshiftz parameters. Each approach is mutually exclusive.");
00745                                 d.put("searchx", EMObject::INT,"The maximum length of the detectable translational shift in the x direction- if you supply this parameter you can not supply the maxshift parameters. Default is 3.");
00746                                 d.put("searchy", EMObject::INT,"The maximum length of the detectable translational shift in the y direction- if you supply this parameter you can not supply the maxshift parameters. Default is 3.");
00747                                 d.put("searchz", EMObject::INT,"The maximum length of the detectable translational shift in the z direction- if you supply this parameter you can not supply the maxshift parameters. Default is 3");
00748                                 d.put("verbose", EMObject::BOOL,"Turn this on to have useful information printed to standard out.");
00749                                 return d;
00750                         }


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

Generated on Sat Nov 21 02:20:15 2009 for EMAN2 by  doxygen 1.5.6