00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef eman__aligner_h__
00037 #define eman__aligner_h__ 1
00038
00039
00040 #include "emobject.h"
00041
00042
00043 namespace EMAN
00044 {
00045 class EMData;
00046 class Cmp;
00047
00084 class Aligner
00085 {
00086 public:
00087 virtual ~ Aligner()
00088 {
00089 }
00090
00091 virtual EMData *align(EMData * this_img, EMData * to_img) const = 0;
00092
00104 virtual EMData *align(EMData * this_img, EMData * to_img,
00105 const string & cmp_name, const Dict& cmp_params) const = 0;
00106
00110 virtual string get_name() const = 0;
00111
00112 virtual string get_desc() const = 0;
00116 virtual Dict get_params() const
00117 {
00118 return params;
00119 }
00120
00124 virtual void set_params(const Dict & new_params)
00125 {
00126 params = new_params;
00127 }
00128
00129 virtual TypeDict get_param_types() const = 0;
00130
00144 virtual vector<Dict> xform_align_nbest(EMData * this_img, EMData * to_img, const unsigned int nsoln, const string & cmp_name, const Dict& cmp_params) const;
00145
00146
00147
00148
00149
00150 protected:
00151 mutable Dict params;
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164 };
00165
00174 class TranslationalAligner:public Aligner
00175 {
00176 public:
00177 virtual EMData * align(EMData * this_img, EMData * to_img,
00178 const string & cmp_name="dot", const Dict& cmp_params = Dict()) const;
00179
00180 virtual EMData * align(EMData * this_img, EMData * to_img) const
00181 {
00182 return align(this_img, to_img, "dot", Dict());
00183 }
00184
00185 virtual string get_name() const
00186 {
00187 return NAME;
00188 }
00189
00190 virtual string get_desc() const
00191 {
00192 return "Translational 2D and 3D alignment by cross-correlation";
00193 }
00194
00195 static Aligner *NEW()
00196 {
00197 return new TranslationalAligner();
00198 }
00199
00200 virtual TypeDict get_param_types() const
00201 {
00202 TypeDict d;
00203 d.put("intonly", EMObject::INT,"Integer pixel translations only");
00204 d.put("useflcf", EMObject::INT,"Use Fast Local Correlation Function rather than CCF");
00205 d.put("maxshift", EMObject::INT,"Maximum translation in pixels");
00206 d.put("masked", EMObject::INT,"Treat zero pixels in 'this' as a mask for normalization (default false)");
00207 d.put("nozero", EMObject::INT,"Zero translation not permitted (useful for CCD images)");
00208 return d;
00209 }
00210
00211 static const string NAME;
00212 };
00213
00218 class RotationalAligner:public Aligner
00219 {
00220 public:
00221 virtual EMData * align(EMData * this_img, EMData * to_img,
00222 const string & cmp_name = "dot", const Dict& cmp_params = Dict()) const;
00223
00224 virtual EMData * align(EMData * this_img, EMData * to_img) const
00225 {
00226 return align(this_img, to_img, "dot", Dict());
00227 }
00228
00229 virtual string get_name() const
00230 {
00231 return NAME;
00232 }
00233
00234 virtual string get_desc() const
00235 {
00236 return "Performs rotational alignment,works accurately if the image is precentered, normally called internally in combination with translational and flip alignment";
00237 }
00238
00239 static Aligner *NEW()
00240 {
00241 return new RotationalAligner();
00242 }
00243
00244 static EMData * align_180_ambiguous(EMData * this_img, EMData * to_img, int rfp_mode = 0);
00245
00246 virtual TypeDict get_param_types() const
00247 {
00248 TypeDict d;
00249 d.put("rfp_mode", EMObject::INT,"Either 0,1 or 2. A temporary flag for testing the rotational foot print. O is the original eman1 way. 1 is just using calc_ccf without padding. 2 is using calc_mutual_correlation without padding.");
00250 return d;
00251 }
00252
00253 static const string NAME;
00254 };
00255
00263 class RotationalAlignerIterative:public Aligner
00264 {
00265 public:
00266 virtual EMData * align(EMData * this_img, EMData * to_img,
00267 const string & cmp_name = "dot", const Dict& cmp_params = Dict()) const;
00268
00269 virtual EMData * align(EMData * this_img, EMData * to_img) const
00270 {
00271 return align(this_img, to_img, "dot", Dict());
00272 }
00273
00274 virtual string get_name() const
00275 {
00276 return NAME;
00277 }
00278
00279 virtual string get_desc() const
00280 {
00281 return "Performs rotational alignment using the SPIDER method";
00282 }
00283
00284 static Aligner *NEW()
00285 {
00286 return new RotationalAlignerIterative();
00287 }
00288
00289 virtual TypeDict get_param_types() const
00290 {
00291 TypeDict d;
00292 d.put("r1", EMObject::INT, "Inner ring, pixels");
00293 d.put("r2", EMObject::INT, "Outer ring, pixels");
00294 return d;
00295 }
00296
00297 static const string NAME;
00298 };
00299
00302 class RotatePrecenterAligner:public Aligner
00303 {
00304 public:
00305 virtual EMData * align(EMData * this_img, EMData * to_img,
00306 const string & cmp_name = "dot", const Dict& cmp_params = Dict()) const;
00307
00308 virtual EMData * align(EMData * this_img, EMData * to_img) const
00309 {
00310 return align(this_img, to_img, "dot", Dict());
00311 }
00312
00313 virtual string get_name() const
00314 {
00315 return NAME;
00316 }
00317
00318 virtual string get_desc() const
00319 {
00320 return "Performs rotational alignment and works accurately if the image is precentered";
00321 }
00322
00323 static Aligner *NEW()
00324 {
00325 return new RotatePrecenterAligner();
00326 }
00327
00328 virtual TypeDict get_param_types() const
00329 {
00330 TypeDict d;
00331 return d;
00332 }
00333
00334 static const string NAME;
00335 };
00336
00343 class RotateTranslateAligner:public Aligner
00344 {
00345 public:
00346 virtual EMData * align(EMData * this_img, EMData * to_img,
00347 const string & cmp_name="dot", const Dict& cmp_params = Dict()) const;
00348
00349 virtual EMData * align(EMData * this_img, EMData * to_img) const
00350 {
00351 return align(this_img, to_img, "sqeuclidean", Dict());
00352 }
00353
00354 virtual string get_name() const
00355 {
00356 return NAME;
00357 }
00358
00359 virtual string get_desc() const
00360 {
00361 return "Performs rotational alignment and follows this with translational alignment.";
00362 }
00363
00364 static Aligner *NEW()
00365 {
00366 return new RotateTranslateAligner();
00367 }
00368
00369 virtual TypeDict get_param_types() const
00370 {
00371 TypeDict d;
00372
00373 d.put("maxshift", EMObject::INT, "Maximum translation in pixels");
00374 d.put("nozero", EMObject::INT,"Zero translation not permitted (useful for CCD images)");
00375 d.put("rfp_mode", EMObject::INT,"Either 0,1 or 2. A temporary flag for testing the rotational foot print");
00376 d.put("useflcf", EMObject::INT,"Use Fast Local Correlation Function rather than CCF for translational alignment");
00377 return d;
00378 }
00379
00380 static const string NAME;
00381 };
00382
00393 class RotateTranslateAlignerIterative:public Aligner
00394 {
00395 public:
00396 virtual EMData * align(EMData * this_img, EMData * to_img,
00397 const string & cmp_name="dot", const Dict& cmp_params = Dict()) const;
00398
00399 virtual EMData * align(EMData * this_img, EMData * to_img) const
00400 {
00401 return align(this_img, to_img, "sqeuclidean", Dict());
00402 }
00403
00404 virtual string get_name() const
00405 {
00406 return NAME;
00407 }
00408
00409 virtual string get_desc() const
00410 {
00411 return "Performs rotational alignment and follows this with translational alignment using the iterative method.";
00412 }
00413
00414 static Aligner *NEW()
00415 {
00416 return new RotateTranslateAlignerIterative();
00417 }
00418
00419 virtual TypeDict get_param_types() const
00420 {
00421 TypeDict d;
00422
00423 d.put("maxshift", EMObject::INT, "Maximum translation in pixels");
00424 d.put("r1", EMObject::INT, "Inner ring, pixels");
00425 d.put("r2", EMObject::INT, "Outer ring, pixels");
00426 d.put("maxiter", EMObject::INT, "Maximum number of iterations");
00427 d.put("nozero", EMObject::INT,"Zero translation not permitted (useful for CCD images)");
00428 d.put("useflcf", EMObject::INT,"Use Fast Local Correlation Function rather than CCF for translational alignment");
00429 return d;
00430 }
00431
00432 static const string NAME;
00433 };
00434
00444 class RotateTranslateAlignerPawel:public Aligner
00445 {
00446 public:
00447 virtual EMData * align(EMData * this_img, EMData * to_img,
00448 const string & cmp_name="dot", const Dict& cmp_params = Dict()) const;
00449
00450 virtual EMData * align(EMData * this_img, EMData * to_img) const
00451 {
00452 return align(this_img, to_img, "sqeuclidean", Dict());
00453 }
00454
00455 virtual string get_name() const
00456 {
00457 return NAME;
00458 }
00459
00460 virtual string get_desc() const
00461 {
00462 return "Performs rotational alignment and translation align by resampling to polar coordinates in real space.";
00463 }
00464
00465 static Aligner *NEW()
00466 {
00467 return new RotateTranslateAlignerPawel();
00468 }
00469
00470 virtual TypeDict get_param_types() const
00471 {
00472 TypeDict d;
00473
00474 d.put("tx", EMObject::INT, "Maximum x translation in pixels, Default = 0");
00475 d.put("ty", EMObject::INT, "Maximum y translation in pixels, Default = 0");
00476 d.put("r1", EMObject::INT, "Inner ring, pixels");
00477 d.put("r2", EMObject::INT, "Outer ring, pixels");
00478 return d;
00479 }
00480
00481 static const string NAME;
00482 };
00483
00488 class RotateTranslateBestAligner:public Aligner
00489 {
00490 public:
00491 virtual EMData * align(EMData * this_img, EMData * to_img,
00492 const string & cmp_name="dot", const Dict& cmp_params = Dict()) const;
00493
00494 virtual EMData * align(EMData * this_img, EMData * to_img) const
00495 {
00496 return align(this_img, to_img, "frc", Dict());
00497 }
00498
00499 virtual string get_name() const
00500 {
00501 return NAME;
00502 }
00503
00504 virtual string get_desc() const
00505 {
00506 return "Full 2D alignment using 'Rotational' and 'Translational', also incorporates 2D 'Refine' alignments.";
00507 }
00508
00509 static Aligner *NEW()
00510 {
00511 return new RotateTranslateBestAligner();
00512 }
00513
00514 virtual TypeDict get_param_types() const
00515 {
00516 TypeDict d;
00517 d.put("maxshift", EMObject::INT, "Maximum translation in pixels");
00518 d.put("snr", EMObject::FLOATARRAY, "signal to noise ratio array");
00519 return d;
00520 }
00521
00522 static const string NAME;
00523 };
00524
00530 class RotateFlipAligner:public Aligner
00531 {
00532 public:
00533 virtual EMData * align(EMData * this_img, EMData * to_img,
00534 const string & cmp_name="dot", const Dict& cmp_params = Dict()) const;
00535 virtual EMData * align(EMData * this_img, EMData * to_img) const
00536 {
00537 return align(this_img, to_img, "dot", Dict());
00538 }
00539 virtual string get_name() const
00540 {
00541 return NAME;
00542 }
00543
00544 virtual string get_desc() const
00545 {
00546 return "Performs two rotational alignments, one using the original image and one using the hand-flipped image. Decides which alignment is better using a comparitor and returns it";
00547 }
00548
00549 static Aligner *NEW()
00550 {
00551 return new RotateFlipAligner();
00552 }
00553
00554 virtual TypeDict get_param_types() const
00555 {
00556 return static_get_param_types();
00557 }
00558
00559 static TypeDict static_get_param_types() {
00560 TypeDict d;
00561
00562 d.put("imask", EMObject::INT);
00563 d.put("rfp_mode", EMObject::INT,"Either 0,1 or 2. A temporary flag for testing the rotational foot print");
00564 return d;
00565 }
00566
00567 static const string NAME;
00568 };
00569
00576 class RotateFlipAlignerIterative:public Aligner
00577 {
00578 public:
00579 virtual EMData * align(EMData * this_img, EMData * to_img,
00580 const string & cmp_name="dot", const Dict& cmp_params = Dict()) const;
00581 virtual EMData * align(EMData * this_img, EMData * to_img) const
00582 {
00583 return align(this_img, to_img, "dot", Dict());
00584 }
00585 virtual string get_name() const
00586 {
00587 return NAME;
00588 }
00589
00590 virtual string get_desc() const
00591 {
00592 return "Performs two rotational alignments, iterative style, one using the original image and one using the hand-flipped image. Decides which alignment is better using a comparitor and returns it";
00593 }
00594
00595 static Aligner *NEW()
00596 {
00597 return new RotateFlipAlignerIterative();
00598 }
00599
00600 virtual TypeDict get_param_types() const
00601 {
00602 return static_get_param_types();
00603 }
00604
00605 static TypeDict static_get_param_types() {
00606 TypeDict d;
00607 d.put("r1", EMObject::INT, "Inner ring, pixels");
00608 d.put("r2", EMObject::INT, "Outer ring, pixels");
00609 return d;
00610 }
00611
00612 static const string NAME;
00613 };
00614
00621 class RotateTranslateFlipAligner:public Aligner
00622 {
00623 public:
00624 virtual EMData * align(EMData * this_img, EMData * to_img,
00625 const string & cmp_name="dot", const Dict& cmp_params = Dict()) const;
00626 virtual EMData * align(EMData * this_img, EMData * to_img) const
00627 {
00628 return align(this_img, to_img, "sqeuclidean", Dict());
00629 }
00630
00631 virtual string get_name() const
00632 {
00633 return NAME;
00634 }
00635
00636 virtual string get_desc() const
00637 {
00638 return " Does two 'rotate_translate' alignments, one to accommodate for possible handedness change. Decided which alignment is better using a comparitor and returns the aligned image as the solution";
00639 }
00640
00641 static Aligner *NEW()
00642 {
00643 return new RotateTranslateFlipAligner();
00644 }
00645
00646 virtual TypeDict get_param_types() const
00647 {
00648 return static_get_param_types();
00649 }
00650
00651 static TypeDict static_get_param_types() {
00652 TypeDict d;
00653
00654 d.put("flip", EMObject::EMDATA);
00655 d.put("usedot", EMObject::INT);
00656 d.put("maxshift", EMObject::INT, "Maximum translation in pixels");
00657 d.put("rfp_mode", EMObject::INT,"Either 0,1 or 2. A temporary flag for testing the rotational foot print");
00658 d.put("useflcf", EMObject::INT,"Use Fast Local Correlation Function rather than CCF for translational alignment");
00659 return d;
00660 }
00661
00662 static const string NAME;
00663 };
00664
00674 class RotateTranslateFlipAlignerIterative:public Aligner
00675 {
00676 public:
00677 virtual EMData * align(EMData * this_img, EMData * to_img,
00678 const string & cmp_name="dot", const Dict& cmp_params = Dict()) const;
00679 virtual EMData * align(EMData * this_img, EMData * to_img) const
00680 {
00681 return align(this_img, to_img, "sqeuclidean", Dict());
00682 }
00683
00684 virtual string get_name() const
00685 {
00686 return NAME;
00687 }
00688
00689 virtual string get_desc() const
00690 {
00691 return " Does two 'rotate_translate.iterative' alignments, one to accommodate for possible handedness change. Decided which alignment is better using a comparitor and returns the aligned image as the solution";
00692 }
00693
00694 static Aligner *NEW()
00695 {
00696 return new RotateTranslateFlipAlignerIterative();
00697 }
00698
00699 virtual TypeDict get_param_types() const
00700 {
00701 return static_get_param_types();
00702 }
00703
00704 static TypeDict static_get_param_types() {
00705 TypeDict d;
00706 d.put("flip", EMObject::EMDATA);
00707 d.put("r1", EMObject::INT, "Inner ring, pixels");
00708 d.put("r2", EMObject::INT, "Outer ring, pixels");
00709 d.put("maxiter", EMObject::INT, "Maximum number of iterations");
00710 d.put("maxshift", EMObject::INT, "Maximum translation in pixels");
00711 return d;
00712 }
00713
00714 static const string NAME;
00715 };
00716
00726 class RotateTranslateFlipAlignerPawel:public Aligner
00727 {
00728 public:
00729 virtual EMData * align(EMData * this_img, EMData * to_img,
00730 const string & cmp_name="dot", const Dict& cmp_params = Dict()) const;
00731
00732 virtual EMData * align(EMData * this_img, EMData * to_img) const
00733 {
00734 return align(this_img, to_img, "sqeuclidean", Dict());
00735 }
00736
00737 virtual string get_name() const
00738 {
00739 return NAME;
00740 }
00741
00742 virtual string get_desc() const
00743 {
00744 return "Performs rotational alignment, translation align, and flip by resampling to polar coordinates in real space.";
00745 }
00746
00747 static Aligner *NEW()
00748 {
00749 return new RotateTranslateFlipAlignerPawel();
00750 }
00751
00752 virtual TypeDict get_param_types() const
00753 {
00754 TypeDict d;
00755
00756 d.put("tx", EMObject::INT, "Maximum x translation in pixels, Default = 0");
00757 d.put("ty", EMObject::INT, "Maximum y translation in pixels, Default = 0");
00758 d.put("r1", EMObject::INT, "Inner ring, pixels");
00759 d.put("r2", EMObject::INT, "Outer ring, pixels");
00760 return d;
00761 }
00762
00763 static const string NAME;
00764 };
00765
00770 class RTFExhaustiveAligner:public Aligner
00771 {
00772 public:
00773 virtual EMData * align(EMData * this_img, EMData * to_img,
00774 const string & cmp_name="dot", const Dict& cmp_params = Dict()) const;
00775 virtual EMData * align(EMData * this_img, EMData * to_img) const
00776 {
00777 return align(this_img, to_img, "sqeuclidean", Dict());
00778 }
00779
00780 virtual string get_name() const
00781 {
00782 return NAME;
00783 }
00784
00785 virtual string get_desc() const
00786 {
00787 return "Experimental full 2D alignment with handedness check using semi-exhaustive search (not necessarily better than RTFBest)";
00788 }
00789
00790 static Aligner *NEW()
00791 {
00792 return new RTFExhaustiveAligner();
00793 }
00794
00795 virtual TypeDict get_param_types() const
00796 {
00797 TypeDict d;
00798
00799 d.put("flip", EMObject::EMDATA);
00800 d.put("maxshift", EMObject::INT, "Maximum translation in pixels");
00801 return d;
00802 }
00803
00804 static const string NAME;
00805 };
00806
00814 class RTFSlowExhaustiveAligner:public Aligner
00815 {
00816 public:
00817 virtual EMData * align(EMData * this_img, EMData * to_img,
00818 const string & cmp_name, const Dict& cmp_params) const;
00819 virtual EMData * align(EMData * this_img, EMData * to_img) const
00820 {
00821 return align(this_img, to_img, "sqeuclidean", Dict());
00822 }
00823 virtual string get_name() const
00824 {
00825 return NAME;
00826 }
00827
00828 virtual string get_desc() const
00829 {
00830 return "Experimental full 2D alignment with handedness check using more exhaustive search (not necessarily better than RTFBest)";
00831 }
00832
00833 static Aligner *NEW()
00834 {
00835 return new RTFSlowExhaustiveAligner();
00836 }
00837
00838 virtual TypeDict get_param_types() const
00839 {
00840 TypeDict d;
00841 d.put("flip", EMObject::EMDATA,"Optional. This is the flipped version of the images that is being aligned. If specified it will be used for the handedness check, if not a flipped copy of the image will be made");
00842 d.put("maxshift", EMObject::INT,"The maximum length of the detectable translational shift");
00843 d.put("transtep", EMObject::FLOAT,"The translation step to take when honing the alignment, which occurs after coarse alignment");
00844 d.put("angstep", EMObject::FLOAT,"The angular step (in degrees) to take in the exhaustive search for the solution angle. Typically very small i.e. 3 or smaller.");
00845 return d;
00846 }
00847
00848 static const string NAME;
00849 };
00850
00858 class SymAlignProcessor:public Aligner
00859 {
00860 public:
00861 virtual EMData * align(EMData * this_img, EMData * to_img, const string & cmp_name="ccc", const Dict& cmp_params = Dict()) const;
00862
00863 virtual EMData * align(EMData * this_img, EMData * to_img) const
00864 {
00865 return align(this_img, to_img, "ccc", Dict());
00866 }
00867 virtual string get_name() const
00868 {
00869 return NAME;
00870 }
00871
00872 static Aligner *NEW()
00873 {
00874 return new SymAlignProcessor();
00875 }
00876
00877 virtual TypeDict get_param_types() const
00878 {
00879 TypeDict d;
00880 d.put("sym", EMObject::STRING, "The symmetry under which to do the alignment, Default=c1" );
00881 d.put("delta", EMObject::FLOAT,"Angle the separates points on the sphere. This is exclusive of the \'n\' paramater. Default is 10");
00882 d.put("dphi", EMObject::FLOAT,"The angle increment in the phi direction. Default is 10");
00883 d.put("lphi", EMObject::FLOAT,"Lower bound for phi. Default it 0");
00884 d.put("uphi", EMObject::FLOAT,"Upper bound for phi. Default it 359.9");
00885 d.put("avger", EMObject::STRING, "The sort of averager to use, Default=mean" );
00886 return d;
00887 }
00888
00889 virtual string get_desc() const
00890 {
00891 return "The image is centered and rotated to the standard orientation for the specified symmetry";
00892 }
00893
00894 static const string NAME;
00895
00896 };
00897
00900 class RefineAligner:public Aligner
00901 {
00902 public:
00903 virtual EMData * align(EMData * this_img, EMData * to_img,
00904 const string & cmp_name="dot", const Dict& cmp_params = Dict()) const;
00905
00906 virtual EMData * align(EMData * this_img, EMData * to_img) const
00907 {
00908 return align(this_img, to_img, "sqeuclidean", Dict());
00909 }
00910
00911 virtual string get_name() const
00912 {
00913 return NAME;
00914 }
00915
00916 virtual string get_desc() const
00917 {
00918 return "Refines a preliminary 2D alignment using a simplex algorithm. Subpixel precision.";
00919 }
00920
00921 static Aligner *NEW()
00922 {
00923 return new RefineAligner();
00924 }
00925
00926 virtual TypeDict get_param_types() const
00927 {
00928 TypeDict d;
00929
00930 d.put("mode", EMObject::INT, "Currently unused");
00931 d.put("xform.align2d", EMObject::TRANSFORM, "The Transform storing the starting guess. If unspecified the identity matrix is used");
00932 d.put("stepx", EMObject::FLOAT, "The x increment used to create the starting simplex. Default is 1");
00933 d.put("stepy", EMObject::FLOAT, "The y increment used to create the starting simplex. Default is 1");
00934 d.put("stepaz", EMObject::FLOAT, "The rotational increment used to create the starting simplex. Default is 5");
00935 d.put("precision", EMObject::FLOAT, "The precision which, if achieved, can stop the iterative refinement before reaching the maximum iterations. Default is 0.04.");
00936 d.put("maxiter", EMObject::INT,"The maximum number of iterations that can be performed by the Simplex minimizer");
00937 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.");
00938 d.put("stepscale", EMObject::FLOAT, "If set to any non-zero value, scale will be included in the alignment, and this will be the initial step. Images should be edgenormalized. If the scale goes beyond +-30% alignment will fail.");
00939 return d;
00940 }
00941
00942 static const string NAME;
00943 };
00944
00951 class SymAlignProcessorQuat : public Aligner
00952 {
00953 public:
00954 virtual EMData * align(EMData * this_img, EMData * to_img,
00955 const string & cmp_name="ccc", const Dict& cmp_params = Dict()) const;
00956
00957 virtual EMData * align(EMData * this_img, EMData * to_img) const
00958 {
00959 return align(this_img, to_img, "ccc", Dict());
00960 }
00961
00962 virtual string get_name() const
00963 {
00964 return NAME;
00965 }
00966 static Aligner *NEW()
00967 {
00968 return new SymAlignProcessorQuat();
00969 }
00970 string get_desc() const
00971 {
00972 return "Finds the symmetry axis using the simplex algorithm.";
00973 }
00974 virtual TypeDict get_param_types() const
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 }
00991 static const string NAME;
00992 };
00993
01012 class Refine3DAlignerGrid:public Aligner
01013 {
01014 public:
01015 virtual EMData * align(EMData * this_img, EMData * to_img,
01016 const string & cmp_name="sqeuclidean", const Dict& cmp_params = Dict()) const;
01017
01018 virtual EMData * align(EMData * this_img, EMData * to_img) const
01019 {
01020 return align(this_img, to_img, "sqeuclidean", Dict());
01021 }
01022
01023 virtual string get_name() const
01024 {
01025 return NAME;
01026 }
01027
01028 virtual string get_desc() const
01029 {
01030 return "Refines a preliminary 3D alignment using a simplex algorithm. Subpixel precision.";
01031 }
01032
01033 static Aligner *NEW()
01034 {
01035 return new Refine3DAlignerGrid();
01036 }
01037
01038 virtual TypeDict get_param_types() const
01039 {
01040 TypeDict d;
01041 d.put("xform.align3d", EMObject::TRANSFORM,"The Transform storing the starting guess. If unspecified the identity matrix is used");
01042 d.put("delta", EMObject::FLOAT, "The angular step size. Default is 1." );
01043 d.put("range", EMObject::FLOAT, "The angular range size. Default is 10." );
01044 d.put("dotrans", EMObject::BOOL,"Do a translational search. Default is True(1)");
01045 d.put("search", EMObject::INT,"The maximum length of the detectable translational shift - if you supply this parameter you can not supply the maxshiftx, maxshifty or maxshiftz parameters. Each approach is mutually exclusive.");
01046 d.put("searchx", EMObject::INT,"The maximum length of the detectable translational shift in the x direction- if you supply this parameter you can not supply the maxshift parameters. Default is 3.");
01047 d.put("searchy", EMObject::INT,"The maximum length of the detectable translational shift in the y direction- if you supply this parameter you can not supply the maxshift parameters. Default is 3.");
01048 d.put("searchz", EMObject::INT,"The maximum length of the detectable translational shift in the z direction- if you supply this parameter you can not supply the maxshift parameters. Default is 3");
01049 d.put("verbose", EMObject::BOOL,"Turn this on to have useful information printed to standard out.");
01050 return d;
01051 }
01052
01053 static const string NAME;
01054 };
01055
01077 class Refine3DAlignerQuaternion:public Aligner
01078 {
01079 public:
01080 virtual EMData * align(EMData * this_img, EMData * to_img,
01081 const string & cmp_name="sqeuclidean", const Dict& cmp_params = Dict()) const;
01082
01083 virtual EMData * align(EMData * this_img, EMData * to_img) const
01084 {
01085 return align(this_img, to_img, "sqeuclidean", Dict());
01086 }
01087
01088 virtual string get_name() const
01089 {
01090 return NAME;
01091 }
01092
01093 virtual string get_desc() const
01094 {
01095 return "Refines a preliminary 3D alignment using a simplex algorithm. Subpixel precision.";
01096 }
01097
01098 static Aligner *NEW()
01099 {
01100 return new Refine3DAlignerQuaternion();
01101 }
01102
01103 virtual TypeDict get_param_types() const
01104 {
01105 TypeDict d;
01106 d.put("xform.align3d", EMObject::TRANSFORM,"The Transform storing the starting guess. If unspecified the identity matrix is used");
01107 d.put("stepx", EMObject::FLOAT, "The initial simplex step size in x. Default is 1");
01108 d.put("stepy", EMObject::FLOAT, "The initial simplex step size in y. Default is 1");
01109 d.put("stepz", EMObject::FLOAT, "The initial simplex step size in z. Default is 1." );
01110 d.put("stepn0", EMObject::FLOAT, "The initial simplex step size in the first quaternion vecotr component. Default is 1." );
01111 d.put("stepn1", EMObject::FLOAT, "The initial simplex step size in the second quaternion vecotr component. Default is 1." );
01112 d.put("stepn2", EMObject::FLOAT, "The initial simplex step size in the third quaternion vecotr component. Default is 1." );
01113 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.");
01114 d.put("precision", EMObject::FLOAT, "The precision which, if achieved, can stop the iterative refinement before reaching the maximum iterations. Default is 0.01." );
01115 d.put("maxiter", EMObject::INT, "The maximum number of iterations that can be performed by the Simplex minimizer. Default is 100.");
01116 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.");
01117 return d;
01118 }
01119
01120 static const string NAME;
01121 };
01122
01146 class RT3DGridAligner:public Aligner
01147 {
01148 public:
01151 virtual EMData * align(EMData * this_img, EMData * to_img,
01152 const string & cmp_name="ccc.tomo", const Dict& cmp_params = Dict()) const;
01155 virtual EMData * align(EMData * this_img, EMData * to_img) const
01156 {
01157 return align(this_img, to_img, "ccc.tomo", Dict());
01158 }
01159
01160
01163 virtual vector<Dict> xform_align_nbest(EMData * this_img, EMData * to_img, const unsigned int nsoln, const string & cmp_name, const Dict& cmp_params) const;
01164
01165 virtual string get_name() const
01166 {
01167 return NAME;
01168 }
01169
01170 virtual string get_desc() const
01171 {
01172 return "3D rotational and translational alignment using specified ranges and maximum shifts";
01173 }
01174
01175 static Aligner *NEW()
01176 {
01177 return new RT3DGridAligner();
01178 }
01179
01180 virtual TypeDict get_param_types() const
01181 {
01182 TypeDict d;
01183 d.put("daz", EMObject::FLOAT,"The angle increment in the azimuth direction. Default is 10");
01184 d.put("az0", EMObject::FLOAT,"Lower bound for the azimuth direction. Default it 0");
01185 d.put("az1", EMObject::FLOAT,"Upper bound for the azimuth direction. Default it 180.0");
01186 d.put("dphi", EMObject::FLOAT,"The angle increment in the phi direction. Default is 10");
01187 d.put("phi0", EMObject::FLOAT,"Lower bound for the phi direction. Default it 0");
01188 d.put("phi1", EMObject::FLOAT,"Upper bound for the phi direction. Default it 360.0");
01189 d.put("dalt", EMObject::FLOAT,"The angle increment in the altitude direction. Default is 10");
01190 d.put("alt0", EMObject::FLOAT,"Lower bound for the altitude direction. Default it 0");
01191 d.put("alt1", EMObject::FLOAT,"Upper bound for the altitude direction. Default it 360.0");
01192 d.put("dotrans", EMObject::BOOL,"Do a translational search. Default is True(1)");
01193 d.put("search", EMObject::INT,"The maximum length of the detectable translational shift - if you supply this parameter you can not supply the maxshiftx, maxshifty or maxshiftz parameters. Each approach is mutually exclusive.");
01194 d.put("searchx", EMObject::INT,"The maximum length of the detectable translational shift in the x direction- if you supply this parameter you can not supply the maxshift parameters. Default is 3.");
01195 d.put("searchy", EMObject::INT,"The maximum length of the detectable translational shift in the y direction- if you supply this parameter you can not supply the maxshift parameters. Default is 3.");
01196 d.put("searchz", EMObject::INT,"The maximum length of the detectable translational shift in the z direction- if you supply this parameter you can not supply the maxshift parameters. Default is 3");
01197 d.put("verbose", EMObject::BOOL,"Turn this on to have useful information printed to standard out.");
01198 return d;
01199 }
01200
01201 static const string NAME;
01202 };
01203
01229 class RT3DSphereAligner:public Aligner
01230 {
01231 public:
01234 virtual EMData * align(EMData * this_img, EMData * to_img,
01235 const string & cmp_name= "sqeuclidean", const Dict& cmp_params = Dict()) const;
01238 virtual EMData * align(EMData * this_img, EMData * to_img) const
01239 {
01240 return align(this_img, to_img, "sqeuclidean", Dict());
01241 }
01242
01243
01246 virtual vector<Dict> xform_align_nbest(EMData * this_img, EMData * to_img, const unsigned int nsoln, const string & cmp_name, const Dict& cmp_params) const;
01247
01248 virtual string get_name() const
01249 {
01250 return NAME;
01251 }
01252
01253 virtual string get_desc() const
01254 {
01255 return "3D rotational and translational alignment using spherical sampling. Can reduce the search space if symmetry is supplied";
01256 }
01257
01258 static Aligner *NEW()
01259 {
01260 return new RT3DSphereAligner();
01261 }
01262
01263 virtual TypeDict get_param_types() const
01264 {
01265 TypeDict d;
01266 d.put("sym", EMObject::STRING,"The symmtery to use as the basis of the spherical sampling. Default is c1 (asymmetry).");
01267 d.put("orientgen", EMObject::STRING,"Advanced. The orientation generation strategy. Default is eman");
01268 d.put("delta", EMObject::FLOAT,"Angle the separates points on the sphere. This is exclusive of the \'n\' paramater. Default is 10");
01269 d.put("n", EMObject::INT,"An alternative to the delta argument, this is the number of points you want generated on the sphere. Default is OFF");
01270 d.put("dphi", EMObject::FLOAT,"The angle increment in the phi direction. Default is 10");
01271 d.put("phi0", EMObject::FLOAT,"Lower bound for phi. Default it 0");
01272 d.put("phi1", EMObject::FLOAT,"Upper bound for phi. Default it 360");
01273 d.put("dotrans", EMObject::BOOL,"Do a translational search. Default is True(1)");
01274 d.put("search", EMObject::INT,"The maximum length of the detectable translational shift - if you supply this parameter you can not supply the maxshiftx, maxshifty or maxshiftz parameters. Each approach is mutually exclusive.");
01275 d.put("searchx", EMObject::INT,"The maximum length of the detectable translational shift in the x direction- if you supply this parameter you can not supply the maxshift parameters. Default is 3.");
01276 d.put("searchy", EMObject::INT,"The maximum length of the detectable translational shift in the y direction- if you supply this parameter you can not supply the maxshift parameters. Default is 3.");
01277 d.put("searchz", EMObject::INT,"The maximum length of the detectable translational shift in the z direction- if you supply this parameter you can not supply the maxshift parameters. Default is 3");
01278 d.put("verbose", EMObject::BOOL,"Turn this on to have useful information printed to standard out.");
01279 return d;
01280 }
01281
01282 static const string NAME;
01283 };
01284
01296 class RT3DSymmetryAligner:public Aligner
01297 {
01298 public:
01301 virtual EMData * align(EMData * this_img, EMData * to_img,
01302 const string & cmp_name="ccc.tomo", const Dict& cmp_params = Dict()) const;
01305 virtual EMData * align(EMData * this_img, EMData * to_img) const
01306 {
01307 return align(this_img, to_img, "ccc.tomo", Dict());
01308 }
01309
01310
01313 virtual vector<Dict> xform_align_nbest(EMData * this_img, EMData * to_img, const unsigned int nsoln, const string & cmp_name, const Dict& cmp_params) const;
01314
01315 virtual string get_name() const
01316 {
01317 return NAME;
01318 }
01319
01320 virtual string get_desc() const
01321 {
01322 return "3D symmetry aligner";
01323 }
01324
01325 static Aligner *NEW()
01326 {
01327 return new RT3DSymmetryAligner();
01328 }
01329
01330 virtual TypeDict get_param_types() const
01331 {
01332 TypeDict d;
01333 d.put("sym", EMObject::FLOAT,"The symmetry. Default is icos");
01334 d.put("verbose", EMObject::BOOL,"Turn this on to have useful information printed to standard out.");
01335 return d;
01336 }
01337
01338 static const string NAME;
01339 };
01340
01341 class FRM2DAligner:public Aligner
01342 {
01343 public:
01344 virtual EMData * align(EMData * this_img, EMData * to_img,
01345 const string& cmp_name, const Dict& cmp_params=Dict()) const;
01346
01347 virtual EMData * align(EMData * this_img, EMData * to_img) const
01348 {
01349 return align(this_img, to_img, "frc", Dict());
01350 }
01351
01352 string get_name() const
01353 {
01354 return NAME;
01355 }
01356
01357 string get_desc() const
01358 {
01359 return "FRM2D uses two rotational parameters and one translational parameter";
01360 }
01361
01362 static Aligner *NEW()
01363 {
01364 return new FRM2DAligner();
01365 }
01366 virtual TypeDict get_param_types() const
01367 {
01368 TypeDict d;
01369 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.");
01370
01371
01372 return d;
01373 }
01374
01375 static const string NAME;
01376 };
01377
01378
01379 class CUDA_Aligner
01380 {
01381 public:
01382 CUDA_Aligner(int id);
01383
01384 void finish();
01385
01386 void setup(int nima, int nx, int ny, int ring_length, int nring, int ou, float step, int kx, int ky, bool ctf);
01387
01388 void insert_image(EMData *image, int num);
01389
01390 void filter_stack(vector<float> ctf_params);
01391
01392 void sum_oe(vector<float> ctf_params, vector<float> ali_params, EMData* ave1, EMData *ave2);
01393
01394 vector<float> alignment_2d(EMData *ref_image, vector<float> sx, vector<float> sy, int silent);
01395
01396 vector<float> ali2d_single_iter(EMData *ref_image, vector<float> ali_params, float csx, float csy, int silent, float delta);
01397
01398 private:
01399 float *image_stack, *image_stack_filtered;
01400 float *ccf;
01401 int NIMA, NX, NY, RING_LENGTH, NRING, OU, KX, KY;
01402 bool CTF;
01403 float STEP;
01404 };
01405
01406 class CUDA_multiref_aligner
01407 {
01408 public:
01409 CUDA_multiref_aligner(int id);
01410
01411 void finish();
01412
01413 void setup(int nima, int nref, int nx, int ny, int ring_length, int nring, int ou, float step, int kx, int ky, bool ctf);
01414
01415 void setup_params(vector<float> all_ali_params, vector<float> all_ctf_params);
01416
01417 void insert_image(EMData *image, int num);
01418
01419 void insert_ref_image(EMData *image, int num);
01420
01421 vector<float> multiref_ali2d(int silent);
01422
01423 private:
01424 float *image_stack, *ref_image_stack, *ref_image_stack_filtered;
01425 float *ccf;
01426 float *ali_params, *ctf_params;
01427 int NIMA, NREF, NX, NY, RING_LENGTH, NRING, OU, KX, KY, MAX_IMAGE_BATCH;
01428 bool CTF;
01429 float STEP;
01430 };
01431
01432 template <> Factory < Aligner >::Factory();
01433
01434 void dump_aligners();
01435 map<string, vector<string> > dump_aligners_list();
01436 }
01437
01438 #endif