Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

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

AlignerNEW ()

Static Public Attributes

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 951 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 957 of file aligner.h.

References align().

00958                         {
00959                                 return align(this_img, to_img, "ccc", Dict());
00960                         }

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 1670 of file aligner.cpp.

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

01671 {
01672         //Get pretransform
01673         Transform* t;
01674         if (params.has_key("xform.align3d") ) {
01675                 t = params["xform.align3d"];
01676         }else {
01677                 t = new Transform(); // is the identity
01678         }
01679         
01680         float sdi = 0.0;
01681         float sdj = 0.0;
01682         float sdk = 0.0;
01683         float sdx = 0.0;
01684         float sdy = 0.0;
01685         float sdz = 0.0;
01686 
01687         float spincoeff =  params.set_default("spin_coeff",10.0f); // spin coefficient, controls speed of convergence (sort of)
01688         
01689         int np = 6; // the number of dimensions
01690         Dict gsl_params;
01691         gsl_params["volume"] = volume;
01692         gsl_params["transform"] = t;
01693         gsl_params["sym"] = params.set_default("sym","c1");
01694         gsl_params["spincoeff"] = spincoeff;
01695         
01696         const gsl_multimin_fminimizer_type *T = gsl_multimin_fminimizer_nmsimplex;
01697         gsl_vector *ss = gsl_vector_alloc(np);
01698 
01699         float stepi = params.set_default("stepn0",1.0f); // doesn't really matter b/c the vecor part will be normalized anyway
01700         float stepj = params.set_default("stepn1",1.0f); // doesn't really matter b/c the vecor part will be normalized anyway
01701         float stepk = params.set_default("stepn2",1.0f); // doesn't really matter b/c the vecor part will be normalized anyway
01702         float stepx = params.set_default("stepx",1.0f);
01703         float stepy = params.set_default("stepy",1.0f);
01704         float stepz = params.set_default("stepz",1.0f);
01705 
01706         gsl_vector_set(ss, 0, stepi);
01707         gsl_vector_set(ss, 1, stepj);
01708         gsl_vector_set(ss, 2, stepk);
01709         gsl_vector_set(ss, 3, stepx);
01710         gsl_vector_set(ss, 4, stepy);
01711         gsl_vector_set(ss, 5, stepz);
01712 
01713         gsl_vector *x = gsl_vector_alloc(np);
01714         gsl_vector_set(x, 0, sdi);
01715         gsl_vector_set(x, 1, sdj);
01716         gsl_vector_set(x, 2, sdk);
01717         gsl_vector_set(x, 3, sdx);
01718         gsl_vector_set(x, 4, sdy);
01719         gsl_vector_set(x, 5, sdz);
01720         
01721         gsl_multimin_function minex_func;
01722         Cmp *c = Factory < Cmp >::get(cmp_name, cmp_params);
01723         gsl_params["cmp"] = (void *) c;
01724         minex_func.f = &symquat;
01725         minex_func.n = np;
01726         minex_func.params = (void *) &gsl_params;
01727         gsl_multimin_fminimizer *s = gsl_multimin_fminimizer_alloc(T, np);
01728         gsl_multimin_fminimizer_set(s, &minex_func, x, ss);
01729         
01730         int rval = GSL_CONTINUE;
01731         int status = GSL_SUCCESS;
01732         int iter = 1;
01733         
01734         float precision = params.set_default("precision",0.01f);
01735         int maxiter = params.set_default("maxiter",100);
01736         while (rval == GSL_CONTINUE && iter < maxiter) {
01737                 iter++;
01738                 status = gsl_multimin_fminimizer_iterate(s);
01739                 if (status) {
01740                         break;
01741                 }
01742                 rval = gsl_multimin_test_size(gsl_multimin_fminimizer_size(s), precision);
01743         }
01744 
01745         int maxshift = params.set_default("maxshift",-1);
01746 
01747         if (maxshift <= 0) {
01748                 maxshift = volume->get_xsize() / 4;
01749         }
01750         float fmaxshift = static_cast<float>(maxshift);
01751         
01752         EMData *result;
01753         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))
01754         {
01755                 float n0 = (float)gsl_vector_get(s->x, 0);
01756                 float n1 = (float)gsl_vector_get(s->x, 1);
01757                 float n2 = (float)gsl_vector_get(s->x, 2);
01758                 float x = (float)gsl_vector_get(s->x, 3);
01759                 float y = (float)gsl_vector_get(s->x, 4);
01760                 float z = (float)gsl_vector_get(s->x, 5);
01761                 
01762                 Transform tsoln = refalin3d_perturbquat(t,spincoeff,n0,n1,n2,x,y,z);
01763                         
01764                 result = volume->process("xform",Dict("transform",&tsoln));
01765                 result->set_attr("xform.align3d",&tsoln);
01766                 EMData *tmpsym = result->process("xform.applysym",Dict("sym",gsl_params["sym"]));
01767                 result->set_attr("score", result->cmp(cmp_name,tmpsym,cmp_params));
01768                 delete tmpsym;
01769         } else { // The refine aligner failed - this shift went beyond the max shift
01770                 result = volume->process("xform",Dict("transform",t));
01771                 result->set_attr("xform.align3d",t);
01772                 result->set_attr("score",0.0);
01773         }
01774         
01775         gsl_vector_free(x);
01776         gsl_vector_free(ss);
01777         gsl_multimin_fminimizer_free(s);
01778 
01779         if ( c != 0 ) delete c;
01780         delete t;
01781                                       
01782         return result;
01783 }

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

Implements EMAN::Aligner.

Definition at line 970 of file aligner.h.

00971                 {
00972                         return "Finds the symmetry axis using the simplex algorithm.";
00973                 }

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 962 of file aligner.h.

00963                 {
00964                         return NAME;
00965                 }

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

Implements EMAN::Aligner.

Definition at line 974 of file aligner.h.

References EMAN::TypeDict::put().

00975                 {
00976                         TypeDict d;
00977                         d.put("sym", EMObject::STRING, "The symmettry. Default is c1");
00978                         d.put("xform.align3d", EMObject::TRANSFORM, "The initial guess for to align the particel to sym axis");
00979                         d.put("stepx", EMObject::FLOAT, "The initial simplex step size in x. Default is 1");
00980                         d.put("stepy", EMObject::FLOAT, "The initial simplex step size in y. Default is 1");
00981                         d.put("stepz", EMObject::FLOAT, "The initial simplex step size in z. Default is 1." );
00982                         d.put("stepn0", EMObject::FLOAT, "The initial simplex step size in the first quaternion vecotr component. Default is 1." );
00983                         d.put("stepn1", EMObject::FLOAT, "The initial simplex step size in the second quaternion vecotr component. Default is 1." );
00984                         d.put("stepn2", EMObject::FLOAT, "The initial simplex step size in the third quaternion vecotr component. Default is 1." );
00985                         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.");
00986                         d.put("precision", EMObject::FLOAT, "The precision which, if achieved, can stop the iterative refinement before reaching the maximum iterations. Default is 0.01." );
00987                         d.put("maxiter", EMObject::INT, "The maximum number of iterations that can be performed by the Simplex minimizer. Default is 100.");
00988                         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.");
00989                         return d;
00990                 }

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

Definition at line 966 of file aligner.h.

00967                 {
00968                         return new SymAlignProcessorQuat();
00969                 }


Member Data Documentation

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

Definition at line 75 of file aligner.cpp.


The documentation for this class was generated from the following files:
Generated on Thu Nov 17 12:45:16 2011 for EMAN2 by  doxygen 1.3.9.1