#include <aligner.h>
Inheritance diagram for EMAN::RotationalAligner:
Public Member Functions | |
virtual EMData * | align (EMData *this_img, EMData *to_img, const string &cmp_name="dot", const Dict &cmp_params=Dict()) const |
To align 'this_img' with another image passed in through its parameters. | |
virtual EMData * | align (EMData *this_img, EMData *to_img) const |
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 () |
EMData * | align_180_ambiguous (EMData *this_img, EMData *to_img, int rfp_mode=2, int zscore=0) |
Static Public Attributes | |
const string | NAME = "rotational" |
rfp_mode | Either 0,1 or 2. A temporary flag for testing the rotational foot print. O is the original eman1 way. 1 is just using calc_ccf without padding. 2 is using calc_mutual_correlation without padding |
Definition at line 285 of file aligner.h.
|
Implements EMAN::Aligner. Definition at line 291 of file aligner.h. References align(). 00292 { 00293 return align(this_img, to_img, "dot", Dict()); 00294 }
|
|
To align 'this_img' with another image passed in through its parameters. The alignment uses a user-given comparison method to compare the two images. If none is given, a default one is used.
Implements EMAN::Aligner. Definition at line 440 of file aligner.cpp. References align_180_ambiguous(), EMAN::EMData::cmp(), EMAN::EMData::get_attr(), EMAN::Transform::get_rotation(), InvalidParameterException, EMAN::EMData::process(), EMAN::EMData::set_attr(), and EMAN::Dict::set_default(). 00442 { 00443 if (!to) throw InvalidParameterException("Can not rotational align - the image to align to is NULL"); 00444 00445 #ifdef EMAN2_USING_CUDA 00446 if(EMData::usecuda == 1) { 00447 //if(!this_img->getcudarwdata()) this_img->copy_to_cuda(); 00448 //if(!to->getcudarwdata()) to->copy_to_cuda(); 00449 } 00450 #endif 00451 00452 // Perform 180 ambiguous alignment 00453 int rfp_mode = params.set_default("rfp_mode",2); 00454 int zscore = params.set_default("zscore",0); 00455 int ambig180 = params.set_default("ambig180",0); 00456 00457 EMData* rot_aligned = RotationalAligner::align_180_ambiguous(this_img,to,rfp_mode,zscore); 00458 Transform * tmp = rot_aligned->get_attr("xform.align2d"); 00459 Dict rot = tmp->get_rotation("2d"); 00460 float rotate_angle_solution = rot["alpha"]; 00461 delete tmp; 00462 00463 // Don't resolve the 180 degree ambiguity here 00464 if (ambig180) { 00465 return rot_aligned; 00466 } 00467 00468 EMData *rot_align_180 = rot_aligned->process("math.rotate.180"); 00469 00470 // Generate the comparison metrics for both rotational candidates 00471 float rot_cmp = rot_aligned->cmp(cmp_name, to, cmp_params); 00472 float rot_180_cmp = rot_align_180->cmp(cmp_name, to, cmp_params); 00473 00474 // Decide on the result 00475 float score = 0.0; 00476 EMData* result = NULL; 00477 if (rot_cmp < rot_180_cmp){ 00478 result = rot_aligned; 00479 score = rot_cmp; 00480 delete rot_align_180; rot_align_180 = 0; 00481 } else { 00482 result = rot_align_180; 00483 score = rot_180_cmp; 00484 delete rot_aligned; rot_aligned = 0; 00485 rotate_angle_solution = rotate_angle_solution-180.0f; 00486 } 00487 00488 // Transform* t = get_align_attr("xform.align2d",result); 00489 // t->set_rotation(Dict("type","2d","alpha",rotate_angle_solution)); 00490 Transform tmp2(Dict("type","2d","alpha",rotate_angle_solution)); 00491 result->set_attr("xform.align2d",&tmp2); 00492 return result; 00493 }
|
|
Definition at line 386 of file aligner.cpp. References EMAN::EMData::calc_ccfx(), data, EMAN::Util::find_max(), EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), InvalidParameterException, EMAN::EMData::make_rotational_footprint(), EMAN::EMData::make_rotational_footprint_cmc(), EMAN::EMData::make_rotational_footprint_e1(), EMAN::EMData::process(), and EMAN::EMData::set_attr(). Referenced by EMAN::RotateTranslateAligner::align(), and align(). 00386 { 00387 00388 // Make translationally invariant rotational footprints 00389 EMData* this_img_rfp, * to_rfp; 00390 if (rfp_mode == 0) { 00391 this_img_rfp = this_img->make_rotational_footprint_e1(); 00392 to_rfp = to->make_rotational_footprint_e1(); 00393 } else if (rfp_mode == 1) { 00394 this_img_rfp = this_img->make_rotational_footprint(); 00395 to_rfp = to->make_rotational_footprint(); 00396 } else if (rfp_mode == 2) { 00397 this_img_rfp = this_img->make_rotational_footprint_cmc(); 00398 to_rfp = to->make_rotational_footprint_cmc(); 00399 } else { 00400 throw InvalidParameterException("rfp_mode must be 0,1 or 2"); 00401 } 00402 int this_img_rfp_nx = this_img_rfp->get_xsize(); 00403 00404 // Do row-wise correlation, returning a sum. 00405 EMData *cf = this_img_rfp->calc_ccfx(to_rfp, 0, this_img->get_ysize(),false,false,zscore); 00406 // cf->process_inplace("normalize"); 00407 // cf->write_image("ralisum.hdf",-1); 00408 // 00409 // EMData *cf2 = this_img_rfp->calc_ccfx(to_rfp, 0, this_img->get_ysize(),true); 00410 // cf2->write_image("ralistack.hdf",-1); 00411 // delete cf2; 00412 00413 // Delete them, they're no longer needed 00414 delete this_img_rfp; this_img_rfp = 0; 00415 delete to_rfp; to_rfp = 0; 00416 00417 // Now solve the rotational alignment by finding the max in the column sum 00418 float *data = cf->get_data(); 00419 00420 float peak = 0; 00421 int peak_index = 0; 00422 Util::find_max(data, this_img_rfp_nx, &peak, &peak_index); 00423 00424 if( cf ) { 00425 delete cf; 00426 cf = 0; 00427 } 00428 float rot_angle = (float) (peak_index * 180.0f / this_img_rfp_nx); 00429 00430 // Return the result 00431 Transform tmp(Dict("type","2d","alpha",rot_angle)); 00432 cf=this_img->process("xform",Dict("transform",(Transform*)&tmp)); 00433 // Transform* t = get_set_align_attr("xform.align2d",cf,this_img); 00434 // Dict d("type","2d","alpha",rot_angle); 00435 // t->set_rotation(d); 00436 cf->set_attr("xform.align2d",&tmp); 00437 return cf; 00438 }
|
|
Implements EMAN::Aligner. Definition at line 301 of file aligner.h. 00302 { 00303 return "Performs rotational alignment, even on poorly centered images, but leaves a 180 degree ambiguity which requires a translational alignment to resolve. Usually called internally by rotate_translate aligner."; 00304 }
|
|
Get the Aligner's name. Each Aligner is identified by a unique name.
Implements EMAN::Aligner. Definition at line 296 of file aligner.h. 00297 {
00298 return NAME;
00299 }
|
|
Implements EMAN::Aligner. Definition at line 313 of file aligner.h. References EMAN::TypeDict::put(). 00314 { 00315 TypeDict d; 00316 d.put("rfp_mode", EMObject::INT,"Either 0,1 or 2. A temporary flag for testing the rotational foot print. O is the original eman1 way. 1 is just using calc_ccf without padding. 2 is using calc_mutual_correlation without padding."); 00317 d.put("zscore", EMObject::INT,"Either 0 or 1. If set, will convert per-radius CCF curves into Z-score significnace curves before averaging. In theory this should produce better results by focusing on radii with more alignment information. (default=false)"); 00318 d.put("ambig180", EMObject::INT,"Either 0 or 1. If set, will not try and resolve the 180 degree ambiguity. If not set, it will assume the particle is well centered and resolve the ambiguity that way. default=false"); 00319 return d; 00320 }
|
|
Definition at line 306 of file aligner.h. 00307 { 00308 return new RotationalAligner(); 00309 }
|
|
Definition at line 60 of file aligner.cpp. |