#include <aligner.h>
Inheritance diagram for EMAN::RT3DSphereAligner:
Public Member Functions | |
virtual EMData * | align (EMData *this_img, EMData *to_img, const string &cmp_name="sqeuclidean", const Dict &cmp_params=Dict()) 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 | |
Aligner * | NEW () |
Static Public Attributes | |
const string | NAME = "rt.3d.sphere" |
can also make use of different OrientationGenerators (random, for example) 160-180% more efficient than the RT3DGridAligner
Definition at line 924 of file aligner.h.
|
See Aligner comments for more details.
Implements EMAN::Aligner. Definition at line 933 of file aligner.h. References align(). 00934 { 00935 return align(this_img, to_img, "sqeuclidean", Dict()); 00936 }
|
|
See Aligner comments for more details.
Implements EMAN::Aligner. Definition at line 1727 of file aligner.cpp. References EMAN::EMData::process(), EMAN::EMData::set_attr(), t, and xform_align_nbest(). 01728 { 01729 01730 vector<Dict> alis = xform_align_nbest(this_img,to,1,cmp_name,cmp_params); 01731 01732 Dict t; 01733 Transform* tr = (Transform*) alis[0]["xform.align3d"]; 01734 t["transform"] = tr; 01735 EMData* soln = this_img->process("xform",t); 01736 soln->set_attr("xform.align3d",tr); 01737 delete tr; tr = 0; 01738 01739 return soln; 01740 01741 }
|
|
Implements EMAN::Aligner. Definition at line 948 of file aligner.h. 00949 { 00950 return "3D rotational and translational alignment using spherical sampling. Can reduce the search space if symmetry is supplied"; 00951 }
|
|
Get the Aligner's name. Each Aligner is identified by a unique name.
Implements EMAN::Aligner. Definition at line 943 of file aligner.h. 00944 {
00945 return NAME;
00946 }
|
|
Implements EMAN::Aligner. Definition at line 958 of file aligner.h. References EMAN::TypeDict::put(). 00959 { 00960 TypeDict d; 00961 d.put("sym", EMObject::STRING,"The symmtery to use as the basis of the spherical sampling. Default is c1 (asymmetry)."); 00962 d.put("orientgen", EMObject::STRING,"Advanced. The orientation generation strategy. Default is eman"); 00963 d.put("delta", EMObject::FLOAT,"Angle the separates points on the sphere. This is exclusive of the \'n\' paramater. Default is 10"); 00964 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"); 00965 d.put("dphi", EMObject::FLOAT,"The angle increment in the phi direction. Default is 10"); 00966 d.put("lphi", EMObject::FLOAT,"Lower bound for phi. Default it 0"); 00967 d.put("uphi", EMObject::FLOAT,"Upper bound for phi. Default it 359.9"); 00968 d.put("dotrans", EMObject::BOOL,"Do a translational search. Default is True(1)"); 00969 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."); 00970 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."); 00971 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."); 00972 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"); 00973 d.put("verbose", EMObject::BOOL,"Turn this on to have useful information printed to standard out."); 00974 return d; 00975 }
|
|
Definition at line 953 of file aligner.h. 00954 { 00955 return new RT3DSphereAligner(); 00956 }
|
|
See Aligner comments for more details.
Reimplemented from EMAN::Aligner. Definition at line 1743 of file aligner.cpp. References EMAN::EMData::calc_ccf(), EMAN::EMData::calc_max_location_wrap(), EMAN::EMData::cmp(), copy(), EMAN::EMData::do_fft(), EMAN::Dict::end(), EMAN::Symmetry3D::gen_orientations(), EMAN::Factory< T >::get(), EMAN::EMData::get_attr(), EMAN::EMData::get_ndim(), EMAN::Dict::has_key(), ImageDimensionException, InvalidParameterException, phi, EMAN::EMData::process(), EMAN::Dict::set_default(), EMAN::Transform::set_trans(), and t. Referenced by align(). 01743 { 01744 01745 if ( this_img->get_ndim() != 3 || to->get_ndim() != 3 ) { 01746 throw ImageDimensionException("This aligner only works for 3D images"); 01747 } 01748 01749 int searchx = 0; 01750 int searchy = 0; 01751 int searchz = 0; 01752 01753 bool dotrans = params.set_default("dotrans",1); 01754 if (params.has_key("search")) { 01755 vector<string> check; 01756 check.push_back("searchx"); 01757 check.push_back("searchy"); 01758 check.push_back("searchz"); 01759 for(vector<string>::const_iterator cit = check.begin(); cit != check.end(); ++cit) { 01760 if (params.has_key(*cit)) throw InvalidParameterException("The search parameter is mutually exclusive of the searchx, searchy, and searchz parameters"); 01761 } 01762 int search = params["search"]; 01763 searchx = search; 01764 searchy = search; 01765 searchz = search; 01766 } else { 01767 searchx = params.set_default("searchx",3); 01768 searchy = params.set_default("searchy",3); 01769 searchz = params.set_default("searchz",3); 01770 } 01771 01772 float lphi = params.set_default("lphi",0.0f); 01773 float uphi = params.set_default("uphi",359.9f); 01774 float dphi = params.set_default("dphi",10.f); 01775 float threshold = params.set_default("threshold",0.f); 01776 if (threshold < 0.0f) throw InvalidParameterException("The threshold parameter must be greater than or equal to zero"); 01777 bool verbose = params.set_default("verbose",false); 01778 01779 //in case we arre aligning tomos 01780 Dict altered_cmp_params(cmp_params); 01781 if (cmp_name == "ccc.tomo") { 01782 altered_cmp_params.set_default("searchx", searchx); 01783 altered_cmp_params.set_default("searchy", searchy); 01784 altered_cmp_params.set_default("searchz", searchz); 01785 altered_cmp_params.set_default("norm", true); 01786 } 01787 01788 vector<Dict> solns; 01789 if (nsoln == 0) return solns; // What was the user thinking? 01790 for (unsigned int i = 0; i < nsoln; ++i ) { 01791 Dict d; 01792 d["score"] = 1.e24; 01793 Transform t; // identity by default 01794 d["xform.align3d"] = &t; // deep copy is going on here 01795 solns.push_back(d); 01796 } 01797 01798 Dict d; 01799 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 01800 if ( params.has_key("delta") && params.has_key("n") ) { 01801 throw InvalidParameterException("The delta and n parameters are mutually exclusive in the RT3DSphereAligner aligner"); 01802 } else if ( params.has_key("n") ) { 01803 d["n"] = params["n"]; 01804 } else { 01805 // If they didn't specify either then grab the default delta - if they did supply delta we're still safe doing this 01806 d["delta"] = params.set_default("delta",10.f); 01807 } 01808 01809 Symmetry3D* sym = Factory<Symmetry3D>::get((string)params.set_default("sym","c1")); 01810 vector<Transform> transforms = sym->gen_orientations((string)params.set_default("orientgen","eman"),d); 01811 01812 float verbose_alt = -1.0f; 01813 //precompute fixed FT, saves a LOT of time!!! 01814 EMData * tofft = 0; 01815 if(dotrans || cmp_name == "ccc.tomo"){ 01816 tofft = to->do_fft(); 01817 } 01818 01819 for(vector<Transform>::const_iterator trans_it = transforms.begin(); trans_it != transforms.end(); trans_it++) { 01820 Dict params = trans_it->get_params("eman"); 01821 if (verbose) { 01822 float alt = params["alt"]; 01823 float az = params["az"]; 01824 if ( alt != verbose_alt ) { 01825 verbose_alt = alt; 01826 cout << "Trying angle alt: " << alt << " az: " << az << endl; 01827 } 01828 } 01829 01830 for( float phi = lphi; phi <= uphi; phi += dphi ) { 01831 01832 params["phi"] = phi; 01833 Transform t(params); 01834 EMData* transformed = this_img->process("xform",Dict("transform",&t)); 01835 01836 //need to do things a bit diffrent if we want to compare two tomos 01837 float best_score; 01838 if (cmp_name == "ccc.tomo") { 01839 best_score = transformed->cmp(cmp_name,tofft,altered_cmp_params); 01840 t.set_trans(-(float)transformed->get_attr("tx"), -(float)transformed->get_attr("ty"), -(float)transformed->get_attr("tz")); 01841 } else { 01842 if(dotrans){ 01843 EMData* ccf = transformed->calc_ccf(tofft); 01844 IntPoint point = ccf->calc_max_location_wrap(searchx,searchy,searchz); 01845 t.set_trans((float)-point[0], (float)-point[1], (float)-point[2]); 01846 transformed = this_img->process("xform",Dict("transform",&t)); 01847 delete ccf; ccf =0; 01848 } 01849 best_score = transformed->cmp(cmp_name,to,cmp_params); 01850 } 01851 delete transformed; transformed =0; 01852 01853 unsigned int j = 0; 01854 //cout << "alt " <<float(t.get_rotation("eman").get("alt")) << " az " << float(t.get_rotation("eman").get("az")) << " phi " << float(t.get_rotation("eman").get("phi")) << endl; 01855 for ( vector<Dict>::iterator it = solns.begin(); it != solns.end(); ++it, ++j ) { 01856 if ( (float)(*it)["score"] > best_score ) { // Note greater than - EMAN2 preferes minimums as a matter of policy 01857 vector<Dict>::reverse_iterator rit = solns.rbegin(); 01858 copy(rit+1,solns.rend()-j,rit); 01859 Dict& d = (*it); 01860 d["score"] = best_score; 01861 d["xform.align3d"] = &t; // deep copy is going on here 01862 break; 01863 } 01864 } 01865 01866 } 01867 } 01868 delete sym; sym = 0; 01869 if(tofft) {delete tofft; tofft = 0;} 01870 return solns; 01871 01872 }
|
|
Definition at line 69 of file aligner.cpp. |