EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes
EMAN::RotateTranslateAligner Class Reference

rotational, translational alignment More...

#include <aligner.h>

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

List of all members.

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.
virtual EMDataalign (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

static AlignerNEW ()

Static Public Attributes

static const string NAME = "rotate_translate"

Detailed Description

rotational, translational alignment

Parameters:
maxshiftMaximum translation in pixels
nozeroZero translation not permitted (useful for CCD images)
rfp_modeEither 0,1 or 2. A temporary flag for testing the rotational foot print

Definition at line 412 of file aligner.h.


Member Function Documentation

EMData * RotateTranslateAligner::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.

Definition at line 706 of file aligner.cpp.

References EMAN::EMData::align(), EMAN::RotationalAligner::align_180_ambiguous(), EMAN::EMData::cmp(), cmp1(), cmp2(), EMAN::EMData::get_attr(), EMAN::Transform::get_rotation(), EMAN::Aligner::params, EMAN::EMData::process(), EMAN::EMData::set_attr(), EMAN::Dict::set_default(), EMAN::Transform::set_rotation(), and t.

Referenced by align().

{

#ifdef EMAN2_USING_CUDA
        if(EMData::usecuda == 1) {
                //if(!this_img->getcudarwdata()) this_img->copy_to_cuda();
                //if(!to->getcudarwdata()) to->copy_to_cuda();
        }
#endif

        // Get the 180 degree ambiguously rotationally aligned and its 180 degree rotation counterpart
        int zscore = params.set_default("zscore",0);
        int rfp_mode = params.set_default("rfp_mode",2);
        EMData *rot_align  =  RotationalAligner::align_180_ambiguous(this_img,to,rfp_mode,zscore);
        Transform * tmp = rot_align->get_attr("xform.align2d");
        Dict rot = tmp->get_rotation("2d");
        float rotate_angle_solution = rot["alpha"];
        delete tmp;

        EMData *rot_align_180 = rot_align->process("math.rotate.180");

        Dict trans_params;
        trans_params["intonly"]  = 0;
        trans_params["maxshift"] = params.set_default("maxshift", -1);
        trans_params["useflcf"]=params.set_default("useflcf",0);

        // Do the first case translational alignment
        trans_params["nozero"]   = params.set_default("nozero",false);
        EMData* rot_trans = rot_align->align("translational", to, trans_params, cmp_name, cmp_params);
        if( rot_align ) { // Clean up
                delete rot_align;
                rot_align = 0;
        }

        // Do the second case translational alignment
        EMData*  rot_180_trans = rot_align_180->align("translational", to, trans_params, cmp_name, cmp_params);
        if( rot_align_180 )     { // Clean up
                delete rot_align_180;
                rot_align_180 = 0;
        }

        // Finally decide on the result
        float cmp1 = rot_trans->cmp(cmp_name, to, cmp_params);
        float cmp2 = rot_180_trans->cmp(cmp_name, to, cmp_params);

        EMData *result = 0;
        if (cmp1 < cmp2) { // All comparators are defined so default return is "smaller is better"
                if( rot_180_trans )     {
                        delete rot_180_trans;
                        rot_180_trans = 0;
                }
                result = rot_trans;
        }
        else {
                if( rot_trans ) {
                        delete rot_trans;
                        rot_trans = 0;
                }
                result = rot_180_trans;
                rotate_angle_solution -= 180.f;
        }

        Transform* t = result->get_attr("xform.align2d");
        t->set_rotation(Dict("type","2d","alpha",rotate_angle_solution));
        result->set_attr("xform.align2d",t);
        delete t;

        return result;
}
virtual EMData* EMAN::RotateTranslateAligner::align ( EMData this_img,
EMData to_img 
) const [inline, virtual]

Implements EMAN::Aligner.

Definition at line 418 of file aligner.h.

References align().

                {
                        return align(this_img, to_img, "sqeuclidean", Dict());
                }
virtual string EMAN::RotateTranslateAligner::get_desc ( ) const [inline, virtual]

Implements EMAN::Aligner.

Definition at line 428 of file aligner.h.

                {
                        return "Performs rotational alignment and follows this with translational alignment.";
                }
virtual string EMAN::RotateTranslateAligner::get_name ( ) const [inline, virtual]

Get the Aligner's name.

Each Aligner is identified by a unique name.

Returns:
The Aligner's name.

Implements EMAN::Aligner.

Definition at line 423 of file aligner.h.

References NAME.

                {
                        return NAME;
                }
virtual TypeDict EMAN::RotateTranslateAligner::get_param_types ( ) const [inline, virtual]

Implements EMAN::Aligner.

Definition at line 438 of file aligner.h.

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

                {
                        TypeDict d;
                        //d.put("usedot", EMObject::INT);
                        d.put("maxshift", EMObject::INT, "Maximum translation in pixels");
                        d.put("nozero", EMObject::INT,"Zero translation not permitted (useful for CCD images)");
                        d.put("rfp_mode", EMObject::INT,"Either 0,1 or 2. A temporary flag for testing the rotational foot print");
                        d.put("useflcf", EMObject::INT,"Use Fast Local Correlation Function rather than CCF for translational alignment");
                        d.put("zscore", EMObject::INT,"Either 0 or 1. This option is passed directly to the rotational aligner (default=false)");
                        return d;
                }
static Aligner* EMAN::RotateTranslateAligner::NEW ( ) [inline, static]

Definition at line 433 of file aligner.h.

                {
                        return new RotateTranslateAligner();
                }

Member Data Documentation

const string RotateTranslateAligner::NAME = "rotate_translate" [static]

Definition at line 450 of file aligner.h.

Referenced by get_name().


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