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

3D rotational symmetry aligner. More...

#include <aligner.h>

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

List of all members.

Public Member Functions

virtual EMDataalign (EMData *this_img, EMData *to_img, const string &cmp_name="ccc.tomo", const Dict &cmp_params=Dict()) const
 See Aligner comments for more details.
virtual EMDataalign (EMData *this_img, EMData *to_img) const
 See Aligner comments for more details.
virtual vector< Dictxform_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 AlignerNEW ()

Static Public Attributes

static const string NAME = "rotate_symmetry_3d"

Detailed Description

3D rotational symmetry aligner.

This aligner takes a map, which must be first aligned to the symmetry axis, and rotates it to it symmetric positions. This is used to check for pseudo symmetry (such as finding the tail of an icosahedral virus). A list of best matches (moving to a reference is produced. Alternativly, a rotated verison of the moving map is returned.

Parameters:
symThe symmtery to use
verboseTurn this on to have useful information printed to standard out
Author:
John Flanagan
Date:
Mar 2011

Definition at line 1676 of file aligner.h.


Member Function Documentation

EMData * RT3DSymmetryAligner::align ( EMData this_img,
EMData to_img,
const string &  cmp_name = "ccc.tomo",
const Dict cmp_params = Dict() 
) const [virtual]

See Aligner comments for more details.

Implements EMAN::Aligner.

Definition at line 2812 of file aligner.cpp.

References EMAN::EMData::process(), EMAN::EMData::set_attr(), and EMAN::Aligner::xform_align_nbest().

Referenced by align().

{

        vector<Dict> alis = xform_align_nbest(this_img,to,1,cmp_name,cmp_params);

        Transform* tr = (Transform*) alis[0]["xform.align3d"];
        EMData* soln = this_img->process("xform",Dict("transform",tr));
        soln->set_attr("xform.align3d",tr);
        delete tr; tr = 0;

        return soln;

}
virtual EMData* EMAN::RT3DSymmetryAligner::align ( EMData this_img,
EMData to_img 
) const [inline, virtual]

See Aligner comments for more details.

Implements EMAN::Aligner.

Definition at line 1685 of file aligner.h.

References align().

                        {
                                return align(this_img, to_img, "ccc.tomo", Dict());
                        }
virtual string EMAN::RT3DSymmetryAligner::get_desc ( ) const [inline, virtual]

Implements EMAN::Aligner.

Definition at line 1700 of file aligner.h.

                        {
                                return "3D symmetry aligner";
                        }
virtual string EMAN::RT3DSymmetryAligner::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 1695 of file aligner.h.

References NAME.

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

Implements EMAN::Aligner.

Definition at line 1710 of file aligner.h.

References EMAN::EMObject::BOOL, EMAN::EMObject::FLOAT, EMAN::TypeDict::put(), and EMAN::EMObject::TRANSFORM.

                        {
                                TypeDict d;
                                d.put("sym", EMObject::FLOAT,"The symmetry. Default is icos");
                                d.put("transform", EMObject::TRANSFORM,"The transform to move to symmetry axis");
                                d.put("verbose", EMObject::BOOL,"Turn this on to have useful information printed to standard out.");
                                return d;
                        }
static Aligner* EMAN::RT3DSymmetryAligner::NEW ( ) [inline, static]

Definition at line 1705 of file aligner.h.

                        {
                                return new RT3DSymmetryAligner();
                        }
vector< Dict > RT3DSymmetryAligner::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 2826 of file aligner.cpp.

References copy(), EMAN::Transform::get_rotation(), EMAN::Symmetry3D::get_symmetries(), EMAN::Dict::has_key(), EMAN::Aligner::params, EMAN::EMData::process(), EMAN::Dict::set_default(), and t.

{
        
        bool verbose = params.set_default("verbose",false);
        Transform* ixform;
        if (params.has_key("transform") ) {
                ixform = params["transform"];
        }else{
                ixform = new Transform(); // is the identity
        }
        
        //Initialize a soln dict
        vector<Dict> solns;
        if (nsoln == 0) return solns; // What was the user thinking?
        for (unsigned int i = 0; i < nsoln; ++i ) {
                Dict d;
                d["score"] = 1.e24;
                Transform t; // identity by default
                d["xform.align3d"] = &t; // deep copy is going on here
                solns.push_back(d);
        }
        
        #ifdef EMAN2_USING_CUDA 
        if(EMData::usecuda == 1) {
                cout << "Using CUDA for 3D sym alignment" << endl;
                if(!this_img->getcudarwdata()) this_img->copy_to_cudaro();
                if(!to->getcudarwdata()) to->copy_to_cuda();
        }
        #endif

        //Generate symmetry related orientations
        vector<Transform> syms = Symmetry3D::get_symmetries((string)params.set_default("sym","icos"));
        Cmp* c = Factory <Cmp>::get(cmp_name, cmp_params);
        
        float score = 0.0f;
        for ( vector<Transform>::const_iterator symit = syms.begin(); symit != syms.end(); ++symit ) {
                //Here move to sym position and compute the score
                Transform sympos = (*symit)*(*ixform);
                EMData* transformed = this_img->process("xform",Dict("transform", &sympos));
                score = c->cmp(transformed,to);
                delete transformed; transformed = 0;
                
                if (verbose) {
                        Dict rots = sympos.get_rotation("eman");
                        cout <<"Score is: " << score << " az " << float(rots["az"]) << " alt " << float(rots["alt"]) << " phi " << float(rots["phi"]) << endl;
                }
                
                unsigned int j = 0;
                for ( vector<Dict>::iterator it = solns.begin(); it != solns.end(); ++it, ++j ) {
                        if ( (float)(*it)["score"] > score ) { // Note greater than - EMAN2 preferes minimums as a matter of policy
                                vector<Dict>::reverse_iterator rit = solns.rbegin();
                                copy(rit+1,solns.rend()-j,rit);
                                Dict& d = (*it);
                                d["score"] = score;
                                d["xform.align3d"] = &sympos; // deep copy is going on here
                                break;
                        }
                }
        }
        
        if (c != 0) delete c;
        
        return solns;
}

Member Data Documentation

const string RT3DSymmetryAligner::NAME = "rotate_symmetry_3d" [static]

Definition at line 1719 of file aligner.h.

Referenced by get_name().


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