EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
EMAN::RotationalAligner Class Reference

rotational alignment using angular correlation More...

#include <aligner.h>

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

Public Member Functions

virtual EMDataalign (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. More...
 
virtual EMDataalign (EMData *this_img, EMData *to_img) const
 
virtual string get_name () const
 Get the Aligner's name. More...
 
virtual string get_desc () const
 
virtual TypeDict get_param_types () const
 
- Public Member Functions inherited from EMAN::Aligner
virtual ~Aligner ()
 
virtual Dict get_params () const
 Get the Aligner parameters in a key/value dictionary. More...
 
virtual void set_params (const Dict &new_params)
 Set the Aligner parameters using a key/value dictionary. More...
 
virtual vector< Dictxform_align_nbest (EMData *this_img, EMData *to_img, const unsigned int nsoln, const string &cmp_name, const Dict &cmp_params) const
 This function first added in the context of the 3D aligners used by e2tomohunter: which wants the n best solutions, as opposed to just the best. More...
 

Static Public Member Functions

static AlignerNEW ()
 
static EMDataalign_180_ambiguous (EMData *this_img, EMData *to_img, int rfp_mode=2, int zscore=0)
 

Static Public Attributes

static const string NAME = "rotational"
 

Additional Inherited Members

- Protected Attributes inherited from EMAN::Aligner
Dict params
 

Detailed Description

rotational alignment using angular correlation

Parameters
rfp_modeEither 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 281 of file aligner.h.

Member Function Documentation

◆ align() [1/2]

virtual EMData * EMAN::RotationalAligner::align ( EMData this_img,
EMData to_img 
) const
inlinevirtual

Implements EMAN::Aligner.

Definition at line 287 of file aligner.h.

288 {
289 return align(this_img, to_img, "dot", Dict());
290 }
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.

References align().

◆ align() [2/2]

virtual EMData * EMAN::RotationalAligner::align ( EMData this_img,
EMData to_img,
const string &  cmp_name = "dot",
const Dict cmp_params = Dict() 
) const
virtual

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.

Parameters
this_imgThe image to be compared.
to_img'this_img" is aligned with 'to_img'.
cmp_nameThe comparison method to compare the two images.
cmp_paramsThe parameter dictionary for comparison method.
Returns
The aligned image.

Implements EMAN::Aligner.

Referenced by align().

◆ align_180_ambiguous()

EMData * RotationalAligner::align_180_ambiguous ( EMData this_img,
EMData to_img,
int  rfp_mode = 2,
int  zscore = 0 
)
static

Definition at line 446 of file aligner.cpp.

446 {
447
448 // Make translationally invariant rotational footprints
449 EMData* this_img_rfp, * to_rfp;
450 if (rfp_mode == 0) {
451 this_img_rfp = this_img->make_rotational_footprint_e1();
452 to_rfp = to->make_rotational_footprint_e1();
453 } else if (rfp_mode == 1) {
454 this_img_rfp = this_img->make_rotational_footprint();
455 to_rfp = to->make_rotational_footprint();
456 } else if (rfp_mode == 2) {
457 this_img_rfp = this_img->make_rotational_footprint_cmc();
458 to_rfp = to->make_rotational_footprint_cmc();
459 } else {
460 throw InvalidParameterException("rfp_mode must be 0,1 or 2");
461 }
462 int this_img_rfp_nx = this_img_rfp->get_xsize();
463
464 // Do row-wise correlation, returning a sum.
465 EMData *cf = this_img_rfp->calc_ccfx(to_rfp, 0, this_img->get_ysize(),false,false,zscore);
466// cf->process_inplace("normalize");
467// cf->write_image("ralisum.hdf",-1);
468//
469// EMData *cf2 = this_img_rfp->calc_ccfx(to_rfp, 0, this_img->get_ysize(),true);
470// cf2->write_image("ralistack.hdf",-1);
471// delete cf2;
472
473 // Delete them, they're no longer needed
474 delete this_img_rfp; this_img_rfp = 0;
475 delete to_rfp; to_rfp = 0;
476
477 // Now solve the rotational alignment by finding the max in the column sum
478 float *data = cf->get_data();
479
480 float peak = 0;
481 int peak_index = 0;
482 Util::find_max(data, this_img_rfp_nx, &peak, &peak_index);
483
484 if( cf ) {
485 delete cf;
486 cf = 0;
487 }
488 float rot_angle = (float) (peak_index * 180.0f / this_img_rfp_nx);
489
490 // Return the result
491 Transform tmp(Dict("type","2d","alpha",rot_angle));
492 cf=this_img->process("xform",Dict("transform",(Transform*)&tmp));
493// Transform* t = get_set_align_attr("xform.align2d",cf,this_img);
494// Dict d("type","2d","alpha",rot_angle);
495// t->set_rotation(d);
496 cf->set_attr("xform.align2d",&tmp);
497 return cf;
498}
Dict is a dictionary to store <string, EMObject> pair.
Definition: emobject.h:385
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
EMData * make_rotational_footprint_cmc(bool unwrap=true)
Definition: emdata.cpp:1795
EMData * make_rotational_footprint_e1(bool unwrap=true)
Definition: emdata.cpp:1898
A Transform object is a somewhat specialized object designed specifically for EMAN2/Sparx storage of ...
Definition: transform.h:75
static void find_max(const float *data, size_t nitems, float *p_max_val, int *p_max_index=0)
Find the maximum value and (optional) its index in an array.
Definition: util.cpp:851
#define InvalidParameterException(desc)
Definition: exception.h:361
EMData * calc_ccfx(EMData *const with, int y0=0, int y1=-1, bool nosum=false, bool flip=false, bool usez=false)
Calculate Cross-Correlation Function (CCF) in the x-direction and adds them up, result in 1D.
Definition: emdata.cpp:1628
EMData * make_rotational_footprint(bool unwrap=true)
Makes a 'rotational footprint', which is an 'unwound' autocorrelation function.
Definition: emdata.cpp:1862

References EMAN::EMData::calc_ccfx(), EMAN::Util::find_max(), InvalidParameterException, EMAN::EMData::make_rotational_footprint(), EMAN::EMData::make_rotational_footprint_cmc(), and EMAN::EMData::make_rotational_footprint_e1().

◆ get_desc()

virtual string EMAN::RotationalAligner::get_desc ( ) const
inlinevirtual

Implements EMAN::Aligner.

Definition at line 297 of file aligner.h.

298 {
299 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.";
300 }

◆ get_name()

virtual string EMAN::RotationalAligner::get_name ( ) const
inlinevirtual

Get the Aligner's name.

Each Aligner is identified by a unique name.

Returns
The Aligner's name.

Implements EMAN::Aligner.

Definition at line 292 of file aligner.h.

293 {
294 return NAME;
295 }
static const string NAME
Definition: aligner.h:319

References NAME.

◆ get_param_types()

virtual TypeDict EMAN::RotationalAligner::get_param_types ( ) const
inlinevirtual

Implements EMAN::Aligner.

Definition at line 309 of file aligner.h.

310 {
311 TypeDict d;
312 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.");
313 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)");
314 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");
315 d.put("maxshift", EMObject::INT,"This is provided for compatibility with other aligners. It does absolutely nothing here, as there is an implicit maxshift=0.");
316 return d;
317 }

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

◆ NEW()

static Aligner * EMAN::RotationalAligner::NEW ( )
inlinestatic

Definition at line 302 of file aligner.h.

303 {
304 return new RotationalAligner();
305 }

Member Data Documentation

◆ NAME

const string RotationalAligner::NAME = "rotational"
static

Definition at line 319 of file aligner.h.

Referenced by get_name().


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