EMAN::SymAlignProcessorQuat Class Reference

Aligns a particle with a specified symetry to its symmetry axis using the simplex multidimensional minimization algorithm. More...

#include <aligner.h>

Inheritance diagram for EMAN::SymAlignProcessorQuat:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual EMDataalign (EMData *this_img, EMData *to_img, const string &cmp_name="ccc", 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.
string get_desc () const
virtual TypeDict get_param_types () const

Static Public Member Functions

static AlignerNEW ()

Static Public Attributes

static const string NAME = "symalignquat"

Detailed Description

Aligns a particle with a specified symetry to its symmetry axis using the simplex multidimensional minimization algorithm.

Author:
John Flanagan
Date:
October 2011
Parameters:
sym The symmetry of the particle in question
xform.align3d The initial guess to align the paricle to its symmetry axis

Definition at line 1257 of file aligner.h.


Member Function Documentation

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

Implements EMAN::Aligner.

Definition at line 1263 of file aligner.h.

References align().

01264                         {
01265                                 return align(this_img, to_img, "ccc", Dict());
01266                         }

EMData * SymAlignProcessorQuat::align ( EMData this_img,
EMData to_img,
const string &  cmp_name = "ccc",
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_img The image to be compared.
to_img 'this_img" is aligned with 'to_img'.
cmp_name The comparison method to compare the two images.
cmp_params The parameter dictionary for comparison method.
Returns:
The aligned image.

Implements EMAN::Aligner.

Definition at line 1854 of file aligner.cpp.

References EMAN::EMData::get_xsize(), EMAN::Dict::has_key(), EMAN::Aligner::params, EMAN::EMData::process(), refalin3d_perturbquat(), EMAN::EMData::set_attr(), EMAN::Dict::set_default(), status, symquat(), t, x, and y.

Referenced by align().

01855 {
01856         //Get pretransform
01857         Transform* t;
01858         if (params.has_key("xform.align3d") ) {
01859                 t = params["xform.align3d"];
01860         }else {
01861                 t = new Transform(); // is the identity
01862         }
01863         
01864         float sdi = 0.0;
01865         float sdj = 0.0;
01866         float sdk = 0.0;
01867         float sdx = 0.0;
01868         float sdy = 0.0;
01869         float sdz = 0.0;
01870 
01871         float spincoeff =  params.set_default("spin_coeff",10.0f); // spin coefficient, controls speed of convergence (sort of)
01872         
01873         int np = 6; // the number of dimensions
01874         Dict gsl_params;
01875         gsl_params["volume"] = volume;
01876         gsl_params["transform"] = t;
01877         gsl_params["sym"] = params.set_default("sym","c1");
01878         gsl_params["spincoeff"] = spincoeff;
01879         
01880         const gsl_multimin_fminimizer_type *T = gsl_multimin_fminimizer_nmsimplex;
01881         gsl_vector *ss = gsl_vector_alloc(np);
01882 
01883         float stepi = params.set_default("stepn0",1.0f); // doesn't really matter b/c the vecor part will be normalized anyway
01884         float stepj = params.set_default("stepn1",1.0f); // doesn't really matter b/c the vecor part will be normalized anyway
01885         float stepk = params.set_default("stepn2",1.0f); // doesn't really matter b/c the vecor part will be normalized anyway
01886         float stepx = params.set_default("stepx",1.0f);
01887         float stepy = params.set_default("stepy",1.0f);
01888         float stepz = params.set_default("stepz",1.0f);
01889 
01890         gsl_vector_set(ss, 0, stepi);
01891         gsl_vector_set(ss, 1, stepj);
01892         gsl_vector_set(ss, 2, stepk);
01893         gsl_vector_set(ss, 3, stepx);
01894         gsl_vector_set(ss, 4, stepy);
01895         gsl_vector_set(ss, 5, stepz);
01896 
01897         gsl_vector *x = gsl_vector_alloc(np);
01898         gsl_vector_set(x, 0, sdi);
01899         gsl_vector_set(x, 1, sdj);
01900         gsl_vector_set(x, 2, sdk);
01901         gsl_vector_set(x, 3, sdx);
01902         gsl_vector_set(x, 4, sdy);
01903         gsl_vector_set(x, 5, sdz);
01904         
01905         gsl_multimin_function minex_func;
01906         Cmp *c = Factory < Cmp >::get(cmp_name, cmp_params);
01907         gsl_params["cmp"] = (void *) c;
01908         minex_func.f = &symquat;
01909         minex_func.n = np;
01910         minex_func.params = (void *) &gsl_params;
01911         gsl_multimin_fminimizer *s = gsl_multimin_fminimizer_alloc(T, np);
01912         gsl_multimin_fminimizer_set(s, &minex_func, x, ss);
01913         
01914         int rval = GSL_CONTINUE;
01915         int status = GSL_SUCCESS;
01916         int iter = 1;
01917         
01918         float precision = params.set_default("precision",0.01f);
01919         int maxiter = params.set_default("maxiter",100);
01920         while (rval == GSL_CONTINUE && iter < maxiter) {
01921                 iter++;
01922                 status = gsl_multimin_fminimizer_iterate(s);
01923                 if (status) {
01924                         break;
01925                 }
01926                 rval = gsl_multimin_test_size(gsl_multimin_fminimizer_size(s), precision);
01927         }
01928 
01929         int maxshift = params.set_default("maxshift",-1);
01930 
01931         if (maxshift <= 0) {
01932                 maxshift = volume->get_xsize() / 4;
01933         }
01934         float fmaxshift = static_cast<float>(maxshift);
01935         
01936         EMData *result;
01937         if ( fmaxshift >= (float)gsl_vector_get(s->x, 0) && fmaxshift >= (float)gsl_vector_get(s->x, 1)  && fmaxshift >= (float)gsl_vector_get(s->x, 2))
01938         {
01939                 float n0 = (float)gsl_vector_get(s->x, 0);
01940                 float n1 = (float)gsl_vector_get(s->x, 1);
01941                 float n2 = (float)gsl_vector_get(s->x, 2);
01942                 float x = (float)gsl_vector_get(s->x, 3);
01943                 float y = (float)gsl_vector_get(s->x, 4);
01944                 float z = (float)gsl_vector_get(s->x, 5);
01945                 
01946                 Transform tsoln = refalin3d_perturbquat(t,spincoeff,n0,n1,n2,x,y,z);
01947                         
01948                 result = volume->process("xform",Dict("transform",&tsoln));
01949                 result->set_attr("xform.align3d",&tsoln);
01950                 EMData *tmpsym = result->process("xform.applysym",Dict("sym",gsl_params["sym"]));
01951                 result->set_attr("score", result->cmp(cmp_name,tmpsym,cmp_params));
01952                 delete tmpsym;
01953         } else { // The refine aligner failed - this shift went beyond the max shift
01954                 result = volume->process("xform",Dict("transform",t));
01955                 result->set_attr("xform.align3d",t);
01956                 result->set_attr("score",0.0);
01957         }
01958         
01959         gsl_vector_free(x);
01960         gsl_vector_free(ss);
01961         gsl_multimin_fminimizer_free(s);
01962 
01963         if (c != 0) delete c;
01964         delete t;
01965                                       
01966         return result;
01967 }

string EMAN::SymAlignProcessorQuat::get_desc (  )  const [inline, virtual]

Implements EMAN::Aligner.

Definition at line 1276 of file aligner.h.

01277                 {
01278                         return "Finds the symmetry axis using the simplex algorithm.";
01279                 }

virtual string EMAN::SymAlignProcessorQuat::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 1268 of file aligner.h.

References NAME.

01269                 {
01270                         return NAME;
01271                 }

virtual TypeDict EMAN::SymAlignProcessorQuat::get_param_types (  )  const [inline, virtual]

Implements EMAN::Aligner.

Definition at line 1280 of file aligner.h.

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

01281                 {
01282                         TypeDict d;
01283                         d.put("sym", EMObject::STRING, "The symmettry. Default is c1");
01284                         d.put("xform.align3d", EMObject::TRANSFORM, "The initial guess for to align the particel to sym axis");
01285                         d.put("stepx", EMObject::FLOAT, "The initial simplex step size in x. Default is 1");
01286                         d.put("stepy", EMObject::FLOAT, "The initial simplex step size in y. Default is 1");
01287                         d.put("stepz", EMObject::FLOAT, "The initial simplex step size in z. Default is 1." );
01288                         d.put("stepn0", EMObject::FLOAT, "The initial simplex step size in the first quaternion vecotr component. Default is 1." );
01289                         d.put("stepn1", EMObject::FLOAT, "The initial simplex step size in the second quaternion vecotr component. Default is 1." );
01290                         d.put("stepn2", EMObject::FLOAT, "The initial simplex step size in the third quaternion vecotr component. Default is 1." );
01291                         d.put("spin_coeff", EMObject::FLOAT,"The multiplier appied to the spin (if it is too small or too large the simplex will not converge).  Default is 10.");
01292                         d.put("precision", EMObject::FLOAT, "The precision which, if achieved, can stop the iterative refinement before reaching the maximum iterations. Default is 0.01." );
01293                         d.put("maxiter", EMObject::INT, "The maximum number of iterations that can be performed by the Simplex minimizer. Default is 100.");
01294                         d.put("maxshift", EMObject::INT,"Maximum translation in pixels in any direction. If the solution yields a shift beyond this value in any direction, then the refinement is judged a failure and the original alignment is used as the solution.");
01295                         return d;
01296                 }

static Aligner* EMAN::SymAlignProcessorQuat::NEW (  )  [inline, static]

Definition at line 1272 of file aligner.h.

01273                 {
01274                         return new SymAlignProcessorQuat();
01275                 }


Member Data Documentation

const string SymAlignProcessorQuat::NAME = "symalignquat" [static]

Definition at line 1297 of file aligner.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Thu May 3 10:08:49 2012 for EMAN2 by  doxygen 1.4.7