#include <aligner.h>
Inheritance diagram for EMAN::RT3DGridAligner:
Public Member Functions | |
virtual EMData * | align (EMData *this_img, EMData *to_img, const string &cmp_name, const Dict &cmp_params) const |
See Aligner comments for more details. | |
virtual EMData * | align (EMData *this_img, EMData *to_img) const |
See Aligner comments for more details. | |
virtual vector< Dict > | xform_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 Aligner * | NEW () |
Static Public Attributes | |
static const string | NAME = "rt.3d.grid" |
Definition at line 665 of file aligner.h.
EMData * RT3DGridAligner::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 1387 of file aligner.cpp.
References EMAN::EMData::process(), EMAN::EMData::set_attr(), t, and xform_align_nbest().
Referenced by align().
01388 { 01389 01390 vector<Dict> alis = xform_align_nbest(this_img,to,1,cmp_name,cmp_params); 01391 01392 Dict t; 01393 Transform* tr = (Transform*) alis[0]["xform.align3d"]; 01394 t["transform"] = tr; 01395 EMData* soln = this_img->process("xform",t); 01396 soln->set_attr("xform.align3d",tr); 01397 delete tr; tr = 0; 01398 01399 return soln; 01400 01401 }
virtual string EMAN::RT3DGridAligner::get_desc | ( | ) | const [inline, virtual] |
Implements EMAN::Aligner.
Definition at line 689 of file aligner.h.
00690 { 00691 return "3D rotational and translational alignment using specified ranges and maximum shifts"; 00692 }
virtual string EMAN::RT3DGridAligner::get_name | ( | ) | const [inline, virtual] |
virtual TypeDict EMAN::RT3DGridAligner::get_param_types | ( | ) | const [inline, virtual] |
Implements EMAN::Aligner.
Definition at line 699 of file aligner.h.
References EMAN::EMObject::BOOL, EMAN::EMObject::FLOAT, EMAN::EMObject::INT, and EMAN::TypeDict::put().
00700 { 00701 TypeDict d; 00702 d.put("daz", EMObject::FLOAT,"The angle increment in the azimuth direction. Default is 10"); 00703 d.put("raz", EMObject::FLOAT,"The range of angles to sample in the azimuth direction. Default is 360."); 00704 d.put("dphi", EMObject::FLOAT,"The angle increment in the phi direction. Default is 10."); 00705 d.put("rphi", EMObject::FLOAT,"The range of angles to sample in the phi direction. Default is 180."); 00706 d.put("dalt", EMObject::FLOAT,"The angle increment in the altitude direction. Default is 10."); 00707 d.put("ralt", EMObject::FLOAT,"The range of angles to sample in the altitude direction. Default is 180."); 00708 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."); 00709 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."); 00710 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."); 00711 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"); 00712 d.put("verbose", EMObject::BOOL,"Turn this on to have useful information printed to standard out."); 00713 return d; 00714 }
static Aligner* EMAN::RT3DGridAligner::NEW | ( | ) | [inline, static] |
vector< Dict > RT3DGridAligner::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 1403 of file aligner.cpp.
References EMAN::EMData::calc_ccf(), EMAN::EMData::calc_max_location_wrap(), EMAN::EMData::cmp(), copy(), 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().
01403 { 01404 01405 if ( this_img->get_ndim() != 3 || to->get_ndim() != 3 ) { 01406 throw ImageDimensionException("This aligner only works for 3D images"); 01407 } 01408 01409 int searchx = 0; 01410 int searchy = 0; 01411 int searchz = 0; 01412 01413 if (params.has_key("search")) { 01414 vector<string> check; 01415 check.push_back("searchx"); 01416 check.push_back("searchy"); 01417 check.push_back("searchz"); 01418 for(vector<string>::const_iterator cit = check.begin(); cit != check.end(); ++cit) { 01419 if (params.has_key(*cit)) throw InvalidParameterException("The search parameter is mutually exclusive of the searchx, searchy, and searchz parameters"); 01420 } 01421 int search = params["search"]; 01422 searchx = search; 01423 searchy = search; 01424 searchz = search; 01425 } else { 01426 searchx = params.set_default("searchx",3); 01427 searchy = params.set_default("searchy",3); 01428 searchz = params.set_default("searchz",3); 01429 } 01430 01431 float ralt = params.set_default("ralt",180.f); 01432 float rphi = params.set_default("rphi",180.f); 01433 float raz = params.set_default("raz",180.f); 01434 float dalt = params.set_default("dalt",10.f); 01435 float daz = params.set_default("daz",10.f); 01436 float dphi = params.set_default("dphi",10.f); 01437 float threshold = params.set_default("threshold",0.f); 01438 if (threshold < 0.0f) throw InvalidParameterException("The threshold parameter must be greater than or equal to zero"); 01439 bool verbose = params.set_default("verbose",false); 01440 01441 vector<Dict> solns; 01442 if (nsoln == 0) return solns; // What was the user thinking? 01443 for (unsigned int i = 0; i < nsoln; ++i ) { 01444 Dict d; 01445 d["score"] = 1.e24; 01446 Transform t; // identity by default 01447 d["xform.align3d"] = &t; // deep copy is going on here 01448 solns.push_back(d); 01449 } 01450 Dict d; 01451 d["type"] = "eman"; // d is used in the loop below 01452 for ( float alt = 0.0f; alt <= ralt; alt += dalt) { 01453 // An optimization for the range of az is made at the top of the sphere 01454 // If you think about it, this is just a coarse way of making this approach slightly more efficient 01455 if (verbose) { 01456 cout << "Trying angle " << alt << endl; 01457 } 01458 01459 float begin_az = -raz; 01460 float end_az = raz; 01461 if (alt == 0.0f) { 01462 begin_az = 0.0f; 01463 end_az = 0.0f; 01464 } 01465 01466 for ( float az = begin_az; az <= end_az; az += daz ){ 01467 for( float phi = -rphi-az; phi <= rphi-az; phi += dphi ) { 01468 d["alt"] = alt; 01469 d["phi"] = phi; 01470 d["az"] = az; 01471 Transform t(d); 01472 EMData* transformed = this_img->process("xform",Dict("transform",&t)); 01473 EMData* ccf = transformed->calc_ccf(to); 01474 01475 IntPoint point = ccf->calc_max_location_wrap(searchx,searchy,searchz); 01476 Dict altered_cmp_params(cmp_params); 01477 if (cmp_name == "dot.tomo") { 01478 altered_cmp_params["ccf"] = ccf; 01479 altered_cmp_params["tx"] = point[0]; 01480 altered_cmp_params["ty"] = point[1]; 01481 altered_cmp_params["tz"] = point[2]; 01482 } 01483 01484 float best_score = transformed->cmp(cmp_name,to,altered_cmp_params); 01485 delete transformed; transformed =0; 01486 delete ccf; ccf = 0; 01487 01488 unsigned int j = 0; 01489 for ( vector<Dict>::iterator it = solns.begin(); it != solns.end(); ++it, ++j ) { 01490 if ( (float)(*it)["score"] > best_score ) { // Note greater than - EMAN2 preferes minimums as a matter of policy 01491 vector<Dict>::reverse_iterator rit = solns.rbegin(); 01492 copy(rit+1,solns.rend()-j,rit); 01493 Dict& d = (*it); 01494 d["score"] = best_score; 01495 d["xform.align3d"] = &t; 01496 break; 01497 } 01498 } 01499 } 01500 } 01501 } 01502 01503 return solns; 01504 01505 }
const string RT3DGridAligner::NAME = "rt.3d.grid" [static] |