#include <aligner.h>


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 () |
Definition at line 643 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 1353 of file aligner.cpp.
References EMAN::EMData::process(), EMAN::EMData::set_attr(), t, and xform_align_nbest().
Referenced by align().
01354 { 01355 01356 vector<Dict> alis = xform_align_nbest(this_img,to,1,cmp_name,cmp_params); 01357 01358 Dict t; 01359 Transform* tr = (Transform*) alis[0]["xform.align3d"]; 01360 t["transform"] = tr; 01361 EMData* soln = this_img->process("math.transform",t); 01362 soln->set_attr("xform.align3d",tr); 01363 delete tr; tr = 0; 01364 01365 return soln; 01366 01367 }
| 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 1369 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().
01369 { 01370 01371 if ( this_img->get_ndim() != 3 || to->get_ndim() != 3 ) { 01372 throw ImageDimensionException("This aligner only works for 3D images"); 01373 } 01374 01375 int searchx = 0; 01376 int searchy = 0; 01377 int searchz = 0; 01378 01379 if (params.has_key("search")) { 01380 vector<string> check; 01381 check.push_back("searchx"); 01382 check.push_back("searchy"); 01383 check.push_back("searchz"); 01384 for(vector<string>::const_iterator cit = check.begin(); cit != check.end(); ++cit) { 01385 if (params.has_key(*cit)) throw InvalidParameterException("The search parameter is mutually exclusive of the searchx, searchy, and searchz parameters"); 01386 } 01387 int search = params["search"]; 01388 searchx = search; 01389 searchy = search; 01390 searchz = search; 01391 } else { 01392 searchx = params.set_default("searchx",3); 01393 searchy = params.set_default("searchy",3); 01394 searchz = params.set_default("searchz",3); 01395 } 01396 01397 float ralt = params.set_default("ralt",180.f); 01398 float rphi = params.set_default("rphi",180.f); 01399 float raz = params.set_default("raz",180.f); 01400 float dalt = params.set_default("dalt",10.f); 01401 float daz = params.set_default("daz",10.f); 01402 float dphi = params.set_default("dphi",10.f); 01403 float threshold = params.set_default("threshold",0.f); 01404 if (threshold < 0.0f) throw InvalidParameterException("The threshold parameter must be greater than or equal to zero"); 01405 bool verbose = params.set_default("verbose",false); 01406 01407 vector<Dict> solns; 01408 if (nsoln == 0) return solns; // What was the user thinking? 01409 for (unsigned int i = 0; i < nsoln; ++i ) { 01410 Dict d; 01411 d["score"] = 1.e24; 01412 Transform t; // identity by default 01413 d["xform.align3d"] = &t; // deep copy is going on here 01414 solns.push_back(d); 01415 } 01416 Dict d; 01417 d["type"] = "eman"; // d is used in the loop below 01418 for ( float alt = 0.0f; alt <= ralt; alt += dalt) { 01419 // An optimization for the range of az is made at the top of the sphere 01420 // If you think about it, this is just a coarse way of making this approach slightly more efficient 01421 if (verbose) { 01422 cout << "Trying angle " << alt << endl; 01423 } 01424 01425 float begin_az = -raz; 01426 float end_az = raz; 01427 if (alt == 0.0f) { 01428 begin_az = 0.0f; 01429 end_az = 0.0f; 01430 } 01431 01432 for ( float az = begin_az; az <= end_az; az += daz ){ 01433 for( float phi = -rphi-az; phi <= rphi-az; phi += dphi ) { 01434 d["alt"] = alt; 01435 d["phi"] = phi; 01436 d["az"] = az; 01437 Transform t(d); 01438 EMData* transformed = this_img->process("math.transform",Dict("transform",&t)); 01439 EMData* ccf = transformed->calc_ccf(to); 01440 01441 IntPoint point = ccf->calc_max_location_wrap(searchx,searchy,searchz); 01442 Dict altered_cmp_params(cmp_params); 01443 if (cmp_name == "dot.tomo") { 01444 altered_cmp_params["ccf"] = ccf; 01445 altered_cmp_params["tx"] = point[0]; 01446 altered_cmp_params["ty"] = point[1]; 01447 altered_cmp_params["tz"] = point[2]; 01448 } 01449 01450 float best_score = transformed->cmp(cmp_name,to,altered_cmp_params); 01451 delete transformed; transformed =0; 01452 delete ccf; ccf = 0; 01453 01454 unsigned int j = 0; 01455 for ( vector<Dict>::iterator it = solns.begin(); it != solns.end(); ++it, ++j ) { 01456 if ( (float)(*it)["score"] > best_score ) { // Note greater than - EMAN2 preferes minimums as a matter of policy 01457 vector<Dict>::reverse_iterator rit = solns.rbegin(); 01458 copy(rit+1,solns.rend()-j,rit); 01459 Dict& d = (*it); 01460 d["score"] = best_score; 01461 d["xform.align3d"] = &t; 01462 break; 01463 } 01464 } 01465 } 01466 } 01467 } 01468 01469 return solns; 01470 01471 }
| virtual string EMAN::RT3DGridAligner::get_name | ( | ) | const [inline, virtual] |
Get the Aligner's name.
Each Aligner is identified by a unique name.
Implements EMAN::Aligner.
Definition at line 662 of file aligner.h.
| virtual string EMAN::RT3DGridAligner::get_desc | ( | ) | const [inline, virtual] |
Implements EMAN::Aligner.
Definition at line 667 of file aligner.h.
00668 { 00669 return "3D rotational and translational alignment using specified ranges and maximum shifts"; 00670 }
| static Aligner* EMAN::RT3DGridAligner::NEW | ( | ) | [inline, static] |
| virtual TypeDict EMAN::RT3DGridAligner::get_param_types | ( | ) | const [inline, virtual] |
Implements EMAN::Aligner.
Definition at line 677 of file aligner.h.
References EMAN::EMObject::BOOL, EMAN::EMObject::FLOAT, EMAN::EMObject::INT, and EMAN::TypeDict::put().
00678 { 00679 TypeDict d; 00680 d.put("daz", EMObject::FLOAT,"The angle increment in the azimuth direction. Default is 10"); 00681 d.put("raz", EMObject::FLOAT,"The range of angles to sample in the azimuth direction. Default is 360."); 00682 d.put("dphi", EMObject::FLOAT,"The angle increment in the phi direction. Default is 10."); 00683 d.put("rphi", EMObject::FLOAT,"The range of angles to sample in the phi direction. Default is 180."); 00684 d.put("dalt", EMObject::FLOAT,"The angle increment in the altitude direction. Default is 10."); 00685 d.put("ralt", EMObject::FLOAT,"The range of angles to sample in the altitude direction. Default is 180."); 00686 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."); 00687 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."); 00688 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."); 00689 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"); 00690 d.put("verbose", EMObject::BOOL,"Turn this on to have useful information printed to standard out."); 00691 return d; 00692 }
1.5.6