#include <aligner.h>
Inheritance diagram for EMAN::SymAlignProcessorQuat:
Public Member Functions | |
virtual EMData * | align (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 EMData * | align (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 | |
Aligner * | NEW () |
Static Public Attributes | |
const string | NAME = "symalignquat" |
sym | The symmetry of the particle in question | |
xform.align3d | The initial guess to align the paricle to its symmetry axis |
Definition at line 1323 of file aligner.h.
|
Implements EMAN::Aligner. Definition at line 1329 of file aligner.h. References align(). 01330 { 01331 return align(this_img, to_img, "ccc", Dict()); 01332 }
|
|
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.
Implements EMAN::Aligner. Definition at line 2008 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. 02009 { 02010 //Get pretransform 02011 Transform* t; 02012 if (params.has_key("xform.align3d") ) { 02013 t = params["xform.align3d"]; 02014 }else { 02015 t = new Transform(); // is the identity 02016 } 02017 02018 float sdi = 0.0; 02019 float sdj = 0.0; 02020 float sdk = 0.0; 02021 float sdx = 0.0; 02022 float sdy = 0.0; 02023 float sdz = 0.0; 02024 02025 float spincoeff = params.set_default("spin_coeff",10.0f); // spin coefficient, controls speed of convergence (sort of) 02026 02027 int np = 6; // the number of dimensions 02028 Dict gsl_params; 02029 gsl_params["volume"] = volume; 02030 gsl_params["transform"] = t; 02031 gsl_params["sym"] = params.set_default("sym","c1"); 02032 gsl_params["spincoeff"] = spincoeff; 02033 02034 const gsl_multimin_fminimizer_type *T = gsl_multimin_fminimizer_nmsimplex; 02035 gsl_vector *ss = gsl_vector_alloc(np); 02036 02037 float stepi = params.set_default("stepn0",1.0f); // doesn't really matter b/c the vecor part will be normalized anyway 02038 float stepj = params.set_default("stepn1",1.0f); // doesn't really matter b/c the vecor part will be normalized anyway 02039 float stepk = params.set_default("stepn2",1.0f); // doesn't really matter b/c the vecor part will be normalized anyway 02040 float stepx = params.set_default("stepx",1.0f); 02041 float stepy = params.set_default("stepy",1.0f); 02042 float stepz = params.set_default("stepz",1.0f); 02043 02044 gsl_vector_set(ss, 0, stepi); 02045 gsl_vector_set(ss, 1, stepj); 02046 gsl_vector_set(ss, 2, stepk); 02047 gsl_vector_set(ss, 3, stepx); 02048 gsl_vector_set(ss, 4, stepy); 02049 gsl_vector_set(ss, 5, stepz); 02050 02051 gsl_vector *x = gsl_vector_alloc(np); 02052 gsl_vector_set(x, 0, sdi); 02053 gsl_vector_set(x, 1, sdj); 02054 gsl_vector_set(x, 2, sdk); 02055 gsl_vector_set(x, 3, sdx); 02056 gsl_vector_set(x, 4, sdy); 02057 gsl_vector_set(x, 5, sdz); 02058 02059 gsl_multimin_function minex_func; 02060 Cmp *c = Factory < Cmp >::get(cmp_name, cmp_params); 02061 gsl_params["cmp"] = (void *) c; 02062 minex_func.f = &symquat; 02063 minex_func.n = np; 02064 minex_func.params = (void *) &gsl_params; 02065 gsl_multimin_fminimizer *s = gsl_multimin_fminimizer_alloc(T, np); 02066 gsl_multimin_fminimizer_set(s, &minex_func, x, ss); 02067 02068 int rval = GSL_CONTINUE; 02069 int status = GSL_SUCCESS; 02070 int iter = 1; 02071 02072 float precision = params.set_default("precision",0.01f); 02073 int maxiter = params.set_default("maxiter",100); 02074 while (rval == GSL_CONTINUE && iter < maxiter) { 02075 iter++; 02076 status = gsl_multimin_fminimizer_iterate(s); 02077 if (status) { 02078 break; 02079 } 02080 rval = gsl_multimin_test_size(gsl_multimin_fminimizer_size(s), precision); 02081 } 02082 02083 int maxshift = params.set_default("maxshift",-1); 02084 02085 if (maxshift <= 0) { 02086 maxshift = volume->get_xsize() / 4; 02087 } 02088 float fmaxshift = static_cast<float>(maxshift); 02089 02090 EMData *result; 02091 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)) 02092 { 02093 float n0 = (float)gsl_vector_get(s->x, 0); 02094 float n1 = (float)gsl_vector_get(s->x, 1); 02095 float n2 = (float)gsl_vector_get(s->x, 2); 02096 float x = (float)gsl_vector_get(s->x, 3); 02097 float y = (float)gsl_vector_get(s->x, 4); 02098 float z = (float)gsl_vector_get(s->x, 5); 02099 02100 Transform tsoln = refalin3d_perturbquat(t,spincoeff,n0,n1,n2,x,y,z); 02101 02102 result = volume->process("xform",Dict("transform",&tsoln)); 02103 result->set_attr("xform.align3d",&tsoln); 02104 EMData *tmpsym = result->process("xform.applysym",Dict("sym",gsl_params["sym"])); 02105 result->set_attr("score", result->cmp(cmp_name,tmpsym,cmp_params)); 02106 delete tmpsym; 02107 } else { // The refine aligner failed - this shift went beyond the max shift 02108 result = volume->process("xform",Dict("transform",t)); 02109 result->set_attr("xform.align3d",t); 02110 result->set_attr("score",0.0); 02111 } 02112 02113 gsl_vector_free(x); 02114 gsl_vector_free(ss); 02115 gsl_multimin_fminimizer_free(s); 02116 02117 if (c != 0) delete c; 02118 delete t; 02119 02120 return result; 02121 }
|
|
Implements EMAN::Aligner. Definition at line 1342 of file aligner.h. 01343 { 01344 return "Finds the symmetry axis using the simplex algorithm."; 01345 }
|
|
Get the Aligner's name. Each Aligner is identified by a unique name.
Implements EMAN::Aligner. Definition at line 1334 of file aligner.h. 01335 {
01336 return NAME;
01337 }
|
|
Implements EMAN::Aligner. Definition at line 1346 of file aligner.h. References EMAN::TypeDict::put(). 01347 { 01348 TypeDict d; 01349 d.put("sym", EMObject::STRING, "The symmettry. Default is c1"); 01350 d.put("xform.align3d", EMObject::TRANSFORM, "The initial guess for to align the particel to sym axis"); 01351 d.put("stepx", EMObject::FLOAT, "The initial simplex step size in x. Default is 1"); 01352 d.put("stepy", EMObject::FLOAT, "The initial simplex step size in y. Default is 1"); 01353 d.put("stepz", EMObject::FLOAT, "The initial simplex step size in z. Default is 1." ); 01354 d.put("stepn0", EMObject::FLOAT, "The initial simplex step size in the first quaternion vecotr component. Default is 1." ); 01355 d.put("stepn1", EMObject::FLOAT, "The initial simplex step size in the second quaternion vecotr component. Default is 1." ); 01356 d.put("stepn2", EMObject::FLOAT, "The initial simplex step size in the third quaternion vecotr component. Default is 1." ); 01357 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."); 01358 d.put("precision", EMObject::FLOAT, "The precision which, if achieved, can stop the iterative refinement before reaching the maximum iterations. Default is 0.01." ); 01359 d.put("maxiter", EMObject::INT, "The maximum number of iterations that can be performed by the Simplex minimizer. Default is 100."); 01360 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."); 01361 return d; 01362 }
|
|
Definition at line 1338 of file aligner.h. 01339 { 01340 return new SymAlignProcessorQuat(); 01341 }
|
|
Definition at line 80 of file aligner.cpp. |