EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | List of all members
EMAN::EmanOrientationGenerator Class Reference

EmanOrientationGenerator generates orientations quasi-evenly distributed in the asymmetric unit. More...

#include <symmetry.h>

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

Public Member Functions

 EmanOrientationGenerator ()
 
virtual ~EmanOrientationGenerator ()
 
virtual string get_name () const
 Return "eman". More...
 
virtual string get_desc () const
 Get a description. More...
 
virtual TypeDict get_param_types () const
 Get a dictionary containing the permissable parameters of this class. More...
 
virtual vector< Transformgen_orientations (const Symmetry3D *const sym) const
 generate orientations given some symmetry type More...
 
- Public Member Functions inherited from EMAN::OrientationGenerator
 OrientationGenerator ()
 
virtual ~OrientationGenerator ()
 
bool add_orientation (vector< Transform > &v, const float &az, const float &alt) const
 This functions adds one or more Transform objects to the vector v, depending on the parameters stored in the dictionary (which the inheriting class may include by initializing the typedict in get_param_types by calling. More...
 
float get_optimal_delta (const Symmetry3D *const sym, const int &n) const
 This function gets the optimal value of the delta (or angular spacing) of the orientations based on a desired total number of orientations (n). More...
 
- Public Member Functions inherited from EMAN::FactoryBase
 FactoryBase ()
 
virtual ~FactoryBase ()
 
Dict get_params () const
 get a copy of the parameters of this class More...
 
void set_params (const Dict &new_params)
 Set new parameters. More...
 
void set_param (const string key, const EMObject val)
 
void insert_params (const Dict &new_params)
 Insert parameters. More...
 
Dict copy_relevant_params (const FactoryBase *const that) const
 

Static Public Member Functions

static OrientationGeneratorNEW ()
 Factory support function NEW. More...
 

Static Public Attributes

static const string NAME = "eman"
 The name of this class - used to access it from factories etc. Should be "icos". More...
 

Private Member Functions

 EmanOrientationGenerator (const EmanOrientationGenerator &)
 Disallow copy construction. More...
 
EmanOrientationGeneratoroperator= (const EmanOrientationGenerator &)
 Disallow assignment. More...
 
virtual int get_orientations_tally (const Symmetry3D *const sym, const float &delta) const
 This function returns how many orientations will be generated for a given delta (angular spacing) It does this by simulated gen_orientations. More...
 
float get_az_delta (const float &delta, const float &altitude, const int maxcsym) const
 Gets the optimum azimuth delta (angular step) for a given altitude, delta and maximum symmetry. More...
 

Additional Inherited Members

- Protected Member Functions inherited from EMAN::OrientationGenerator
void get_az_max (const Symmetry3D *const sym, const float &altmax, const bool inc_mirror, const float &alt_iterator, const float &h, bool &d_odd_mirror_flag, float &azmax_adjusted) const
 
- Protected Attributes inherited from EMAN::FactoryBase
Dict params
 This is the dictionary the stores the parameters of the object. More...
 

Detailed Description

EmanOrientationGenerator generates orientations quasi-evenly distributed in the asymmetric unit.

Historically, it is an adaptation of the method first used in EMAN1 and developed by Steve Ludtke. In EMAN2 it is more or less the same thing, but with more precise treatmeant of the platonic symmetries. In terms of approach, the altitude angles in the asymmetric unit are traversed constantly in steps of "prop" (a parameter of this class). However, the azimuth steps vary according to altitude, and this helps to achieve a more even distribution of orientations.

Author
David Woolford (based on previous work by Phil Baldwin and Steve Ludtke)
Date
Feb 2008

Definition at line 1083 of file symmetry.h.

Constructor & Destructor Documentation

◆ EmanOrientationGenerator() [1/2]

EMAN::EmanOrientationGenerator::EmanOrientationGenerator ( )
inline

Definition at line 1086 of file symmetry.h.

1086{};

Referenced by NEW().

◆ ~EmanOrientationGenerator()

virtual EMAN::EmanOrientationGenerator::~EmanOrientationGenerator ( )
inlinevirtual

Definition at line 1087 of file symmetry.h.

1087{};

◆ EmanOrientationGenerator() [2/2]

EMAN::EmanOrientationGenerator::EmanOrientationGenerator ( const EmanOrientationGenerator )
private

Disallow copy construction.

Member Function Documentation

◆ gen_orientations()

vector< Transform > EmanOrientationGenerator::gen_orientations ( const Symmetry3D *const  sym) const
virtual

generate orientations given some symmetry type

Parameters
symthe symmetry which defines the interesting asymmetric unit
Returns
a vector of Transform objects containing the set of evenly distributed orientations

Implements EMAN::OrientationGenerator.

Definition at line 389 of file symmetry.cpp.

390{
391 float delta = params.set_default("delta", 0.0f);
392 int n = params.set_default("n", 0);
393 bool breaksym = params.set_default("breaksym",false);
394 bool breaksymreal = params.set_default("breaksym_real",false);
395
396 if ( delta <= 0 && n <= 0 ) throw InvalidParameterException("Error, you must specify a positive non-zero delta or n");
397 if ( delta > 0 && n > 0 ) throw InvalidParameterException("Error, the delta and the n arguments are mutually exclusive");
398
399 if ( n > 0 ) {
400 delta = get_optimal_delta(sym,n);
401 }
402
403 bool inc_mirror = params.set_default("inc_mirror",false);
404 bool inc_mirror_real = inc_mirror;
405 if (breaksym) inc_mirror=true; // we need to enable mirror generation, then strip them out at the end, or things don't work right...
406 if (breaksymreal){
407 inc_mirror=false;
408 breaksym=true;
409 }
410 Dict delimiters = sym->get_delimiters(inc_mirror);
411 float altmax = delimiters["alt_max"];
412 float azmax = delimiters["az_max"];
413
414 float paltmin = params.set_default("alt_min",0.0f);
415 float paltmax = params.set_default("alt_max",180.0f);
416 if (altmax>paltmax) altmax=paltmax;
417
418 bool perturb = params.set_default("perturb",false); // changed to false default on 7/17/15 by steve
419
420 float alt_iterator = 0.0f;
421
422 // #If it's a h symmetry then the alt iterator starts at very close
423 // #to the altmax... the object is a h symmetry then it knows its alt_min...
424 if (sym->is_h_sym()) alt_iterator = delimiters["alt_min"];
425
426 vector<Transform> ret;
427 while ( alt_iterator <= altmax ) {
428 float h = get_az_delta(delta,alt_iterator, sym->get_max_csym() );
429
430 // not sure what this does code taken from EMAN1 - FIXME original author add comments
431 if ( (alt_iterator > 0) && ( (azmax/h) < 2.8f) ) h = azmax / 2.1f;
432 else if (alt_iterator == 0) h = azmax;
433
434 float az_iterator = 0.0f;
435
436 float azmax_adjusted = azmax;
437
438 bool d_odd_mirror_flag = false;
439 get_az_max(sym,altmax, inc_mirror,alt_iterator, h,d_odd_mirror_flag, azmax_adjusted);
440 if (alt_iterator<paltmin) { alt_iterator += delta; continue; }
441
442
443 while ( az_iterator <= azmax_adjusted ) {
444 // FIXME: add an intelligent comment - this was copied from old code
445// if ( az_iterator > 180.0 && alt_iterator > 180.0/(2.0-0.001) && alt_iterator < 180.0/(2.0+0.001) ) {
446// az_iterator += h;
447// continue;
448// }
449// // Now that I am handling the boundaries very specifically, I don't think we need
450 // the above if statement. But I am leaving it there in case I need to reconsider.
451
452 if (alt_iterator == 0 && az_iterator > 0){
453 az_iterator += h;
454 continue; // We only ever need to generate on orientation at alt=0
455 }
456
457
458 float alt_soln = alt_iterator;
459 float az_soln = az_iterator;
460
461 if (sym->is_platonic_sym()) {
462 if ( sym->is_in_asym_unit(alt_soln, az_soln,inc_mirror) == false ) {
463 az_iterator += h;
464 continue;
465 }
466 // Some objects have alignment offsets (icos and tet particularly)
467 az_soln += sym->get_az_alignment_offset();
468 }
469//printf("%f %f/n",alt_soln,az_soln);
470 if ( perturb && alt_soln != 0 ) {
471 alt_soln += Util::get_gauss_rand(0.0f,.125f*delta);
472 az_soln += Util::get_gauss_rand(0.0f,h*.125f);
473 }
474
475 add_orientation(ret,az_soln,alt_soln);
476
477 // Add helical symmetry orientations on the other side of the equator (if we're including
478 // mirror orientations)
479 if ( sym->is_h_sym() && inc_mirror && alt_iterator != (float) delimiters["alt_min"] ) {
480 add_orientation(ret, az_soln,2.0f*(float)delimiters["alt_min"]-alt_soln);
481 }
482
483 az_iterator += h;
484 if ( (az_iterator > azmax_adjusted) && d_odd_mirror_flag) {
485 azmax_adjusted = azmax;
486 az_iterator += azmax/2.0f;
487 }
488 }
489 alt_iterator += delta;
490 }
491
492 // With breaksym, values are generated for one asymmetric unit as if symmetry were imposed, then
493 // the symmetry equivalent points are generated. Used with asymmetric structures with pseudosymmetry
494 if (breaksym) {
495 // no iterators here since we are making the list longer as we go
496 int nwithsym=ret.size(); // transforms in one asym unit
497 int nsym=sym->get_nsym(); // number of asymmetric units to generate
498 for (int j=1; j<nsym; j++) {
499 Transform t=sym->get_sym(j);
500 for (int i=0; i<nwithsym; i++) {
501 ret.push_back(ret[i]*t); // add the symmetry modified transform to the end of the vector
502 }
503 }
504 if (breaksymreal) return ret;
505 // Now we get rid of anything in the bottom half of the unit sphere if requested
506 if (!inc_mirror_real) {
507 vector<Transform> ret2;
508 for (vector<Transform>::iterator t=ret.begin(); t!=ret.end(); ++t) {
509 if ((*t)[2][2]>=0) ret2.push_back(*t);
510// printf("%f\n",t[2][2]);
511 }
512 return ret2;
513 }
514 }
515
516 return ret;
517}
Dict is a dictionary to store <string, EMObject> pair.
Definition: emobject.h:385
type set_default(const string &key, type val)
Default setting behavior This can be achieved using a template - d.woolford Jan 2008 (before there wa...
Definition: emobject.h:569
float get_az_delta(const float &delta, const float &altitude, const int maxcsym) const
Gets the optimum azimuth delta (angular step) for a given altitude, delta and maximum symmetry.
Definition: symmetry.cpp:301
Dict params
This is the dictionary the stores the parameters of the object.
Definition: emobject.h:953
bool add_orientation(vector< Transform > &v, const float &az, const float &alt) const
This functions adds one or more Transform objects to the vector v, depending on the parameters stored...
Definition: symmetry.cpp:273
float get_optimal_delta(const Symmetry3D *const sym, const int &n) const
This function gets the optimal value of the delta (or angular spacing) of the orientations based on a...
Definition: symmetry.cpp:236
void get_az_max(const Symmetry3D *const sym, const float &altmax, const bool inc_mirror, const float &alt_iterator, const float &h, bool &d_odd_mirror_flag, float &azmax_adjusted) const
Definition: symmetry.cpp:187
virtual bool is_h_sym() const
A function that is used to determine if this is a Helical symmetry object This function is only virtu...
Definition: symmetry.h:100
virtual int get_max_csym() const =0
The Symmetry3D object must return the maximum degree of symmetry it exhibits about any one axis.
virtual int get_nsym() const =0
The total number of unique symmetry operations that will be return by this object when a calling prog...
virtual bool is_platonic_sym() const
A function that is used to determine if this is a platonic symmetry object This function is only virt...
Definition: symmetry.h:94
virtual bool is_in_asym_unit(const float &altitude, const float &azimuth, const bool inc_mirror) const =0
A function to be used when generating orientations over portion of the unit sphere defined by paramet...
virtual Transform get_sym(const int n) const =0
Every Symmetry3D object must provide access to the full set of its symmetry operators via this functi...
virtual Dict get_delimiters(const bool inc_mirror=false) const =0
Every Symmetry3D object must return a dictionary containing the delimiters that define its asymmetric...
virtual float get_az_alignment_offset() const
This functionality is only relevant to platonic symmetries.
Definition: symmetry.h:86
A Transform object is a somewhat specialized object designed specifically for EMAN2/Sparx storage of ...
Definition: transform.h:75
static float get_gauss_rand(float mean, float sigma)
Get a Gaussian random number.
Definition: util.cpp:845
#define InvalidParameterException(desc)
Definition: exception.h:361

References EMAN::OrientationGenerator::add_orientation(), EMAN::Symmetry3D::get_az_alignment_offset(), get_az_delta(), EMAN::OrientationGenerator::get_az_max(), EMAN::Symmetry3D::get_delimiters(), EMAN::Util::get_gauss_rand(), EMAN::Symmetry3D::get_max_csym(), EMAN::Symmetry3D::get_nsym(), EMAN::OrientationGenerator::get_optimal_delta(), EMAN::Symmetry3D::get_sym(), InvalidParameterException, EMAN::Symmetry3D::is_h_sym(), EMAN::Symmetry3D::is_in_asym_unit(), EMAN::Symmetry3D::is_platonic_sym(), EMAN::FactoryBase::params, and EMAN::Dict::set_default().

◆ get_az_delta()

float EmanOrientationGenerator::get_az_delta ( const float &  delta,
const float &  altitude,
const int  maxcsym 
) const
private

Gets the optimum azimuth delta (angular step) for a given altitude, delta and maximum symmetry.

This function is important for the generation of evenly distributed orientations

Parameters
delta- the angular spacing of the altitude angles, this is usually the "delta" parameter
altitudethe altitude along which the azimuth is going to be varied
maxcsymthe maximum csym of the Symmetry3D object - this is usually Symmetry3D::get_max_csym
Returns
the optimal azimuth angular spacing

Definition at line 301 of file symmetry.cpp.

302{
303 // convert altitude into radians
304 float tmp = (float)(EMConsts::deg2rad * altitude);
305
306 // This is taken from EMAN1 project3d.C
307 // This wasn't working like it was supposed to. Rather than
308 // figuring it out, I'm just replacing it --steve
309/* float h=floor(360.0f/(delta*1.1547f)); // the 1.1547 makes the overall distribution more like a hexagonal mesh
310 h=(int)floor(h*sin(tmp)+.5f);
311 if (h==0) h=1;
312 h=abs(maxcsym)*floor(h/(float)abs(maxcsym)+.5f);
313 if ( h == 0 ) h = (float)maxcsym;
314 h=2.0f*M_PI/h;
315
316 return (float)(EMConsts::rad2deg*h);*/
317
318 return altitude==0?360.0f:delta/sin(tmp);
319
320}
static const double deg2rad
Definition: emobject.h:78

References EMAN::EMConsts::deg2rad.

Referenced by gen_orientations(), and get_orientations_tally().

◆ get_desc()

virtual string EMAN::EmanOrientationGenerator::get_desc ( ) const
inlinevirtual

Get a description.

Returns
a clear desciption of this class

Implements EMAN::FactoryBase.

Definition at line 1105 of file symmetry.h.

1105{ return "Generate orientations distributed quasi-uniformaly over the asymmetric unit using an altitude-proportional strategy"; }

◆ get_name()

virtual string EMAN::EmanOrientationGenerator::get_name ( ) const
inlinevirtual

Return "eman".

Returns
the unique name of this class

Implements EMAN::FactoryBase.

Definition at line 1100 of file symmetry.h.

1100{ return NAME; }
static const string NAME
The name of this class - used to access it from factories etc. Should be "icos".
Definition: symmetry.h:1132

References NAME.

◆ get_orientations_tally()

int EmanOrientationGenerator::get_orientations_tally ( const Symmetry3D *const  sym,
const float &  delta 
) const
privatevirtual

This function returns how many orientations will be generated for a given delta (angular spacing) It does this by simulated gen_orientations.

Parameters
symthe symmetry which defines the interesting asymmetric unit
deltathe desired angular spacing of the orientations
Returns
the number of orientations that will be generated using these parameters

Implements EMAN::OrientationGenerator.

Definition at line 323 of file symmetry.cpp.

324{
325 //FIXME THIS IS SO SIMILAR TO THE gen_orientations function that they should be probably use
326 // a common routine - SAME ISSUE FOR OTHER ORIENTATION GENERATORS
327 bool inc_mirror = params.set_default("inc_mirror",false);
328 bool breaksym = params.set_default("breaksym",false);
329 Dict delimiters = sym->get_delimiters(inc_mirror);
330 float altmax = delimiters["alt_max"];
331 float azmax = delimiters["az_max"];
332
333 float paltmin = params.set_default("alt_min",0.0f);
334 float paltmax = params.set_default("alt_max",180.0f);
335 if (altmax>paltmax) altmax=paltmax;
336
337 float alt_iterator = 0.0f;
338
339 // #If it's a h symmetry then the alt iterator starts at very close
340 // #to the altmax... the object is a h symmetry then it knows its alt_min...
341 if (sym->is_h_sym()) alt_iterator = delimiters["alt_min"];
342
343 int tally = 0;
344 while ( alt_iterator <= altmax ) {
345 float h = get_az_delta(delta,alt_iterator, sym->get_max_csym() );
346
347 // not sure what this does code taken from EMAN1 - FIXME original author add comments
348 if ( (alt_iterator > 0) && ( (azmax/h) < 2.8f) ) h = azmax / 2.1f;
349 else if (alt_iterator == 0) h = azmax;
350
351 float az_iterator = 0.0f;
352
353 float azmax_adjusted = azmax;
354 bool d_odd_mirror_flag = false;
355 get_az_max(sym,altmax, inc_mirror,alt_iterator, h,d_odd_mirror_flag, azmax_adjusted);
356 if (alt_iterator<paltmin) { alt_iterator += delta; continue; }
357
358 while ( az_iterator <= azmax_adjusted ) {
359 // FIXME: add an intelligent comment - this was copied from old code
360// if ( az_iterator > 180.0 && alt_iterator > 180.0/(2.0-0.001) && alt_iterator < 180.0/(2.0+0.001) ) {
361// az_iterator += h;
362// continue;
363// }
364
365 if (sym->is_platonic_sym()) {
366 if ( sym->is_in_asym_unit(alt_iterator, az_iterator,inc_mirror) == false ) {
367 az_iterator += h;
368 continue;
369 }
370 }
371
372 tally++;
373 if ( sym->is_h_sym() && inc_mirror && alt_iterator != (float) delimiters["alt_min"] ) {
374 tally++;
375 }
376 az_iterator += h;
377 if ( (az_iterator > azmax_adjusted) && d_odd_mirror_flag) {
378 azmax_adjusted = azmax;
379 az_iterator += azmax/2.0f;
380 }
381 }
382 alt_iterator += delta;
383 }
384
385 if (breaksym) return tally*sym->get_nsym();
386 return tally;
387}

References get_az_delta(), EMAN::OrientationGenerator::get_az_max(), EMAN::Symmetry3D::get_delimiters(), EMAN::Symmetry3D::get_max_csym(), EMAN::Symmetry3D::get_nsym(), EMAN::Symmetry3D::is_h_sym(), EMAN::Symmetry3D::is_in_asym_unit(), EMAN::Symmetry3D::is_platonic_sym(), EMAN::FactoryBase::params, and EMAN::Dict::set_default().

◆ get_param_types()

virtual TypeDict EMAN::EmanOrientationGenerator::get_param_types ( ) const
inlinevirtual

Get a dictionary containing the permissable parameters of this class.

Returns
a dictionary containing the permissable parameters of this class parameters are explained in the dictionary itself

Reimplemented from EMAN::OrientationGenerator.

Definition at line 1111 of file symmetry.h.

1112 {
1114 d.put("delta", EMObject::FLOAT, "The angular separation of orientations in degrees. This option is mutually exclusively of the n argument.");
1115 d.put("perturb", EMObject::BOOL, "Whether or not to perturb the generated orientations in a small local area, default is true.");
1116 d.put("n", EMObject::INT, "The number of orientations to generate. This option is mutually exclusively of the delta argument.Will attempt to get as close to the number specified as possible.");
1117 d.put("inc_mirror", EMObject::BOOL, "Indicates whether or not to include the mirror portion of the asymmetric unit. Default is false.");
1118 d.put("alt_min", EMObject::FLOAT, "Minimum altitude value to include (alt=0 is Z axis). Default=0");
1119 d.put("alt_max", EMObject::FLOAT, "Maximum altitude value to include (alt=90 is X-Y plane). Default=no limit");
1120 d.put("breaksym", EMObject::BOOL, "If specified, still generates orientations filling the unit (hemi)sphere, but does it by filling one asymmetric unit, then generating all symmetric equivalents.");
1121 d.put("breaksym_real", EMObject::BOOL, "Same as breaksym, but do not use inc_mirror.");
1122 return d;
1123 }
virtual TypeDict get_param_types() const
Definition: symmetry.h:1011

References EMAN::EMObject::BOOL, EMAN::EMObject::FLOAT, EMAN::OrientationGenerator::get_param_types(), EMAN::EMObject::INT, and EMAN::TypeDict::put().

◆ NEW()

static OrientationGenerator * EMAN::EmanOrientationGenerator::NEW ( )
inlinestatic

Factory support function NEW.

Returns
a newly instantiated class of this type

Definition at line 1092 of file symmetry.h.

1093 {
1094 return new EmanOrientationGenerator();
1095 }

References EmanOrientationGenerator().

◆ operator=()

EmanOrientationGenerator & EMAN::EmanOrientationGenerator::operator= ( const EmanOrientationGenerator )
private

Disallow assignment.

Member Data Documentation

◆ NAME

const string EmanOrientationGenerator::NAME = "eman"
static

The name of this class - used to access it from factories etc. Should be "icos".

Definition at line 1132 of file symmetry.h.

Referenced by get_name().


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