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
00853 class RefineAligner:public Aligner
00854 {
00855 public:
00856 virtual EMData * align(EMData * this_img, EMData * to_img,
00857 const string & cmp_name="dot", const Dict& cmp_params = Dict()) const;
00858
00859 virtual EMData * align(EMData * this_img, EMData * to_img) const
00860 {
00861 return align(this_img, to_img, "sqeuclidean", Dict());
00862 }
00863
00864 virtual string get_name() const
00865 {
00866 return NAME;
00867 }
00868
00869 virtual string get_desc() const
00870 {
00871 return "Refines a preliminary 2D alignment using a simplex algorithm. Subpixel precision.";
00872 }
00873
00874 static Aligner *NEW()
00875 {
00876 return new RefineAligner();
00877 }
00878
00879 virtual TypeDict get_param_types() const
00880 {
00881 TypeDict d;
00882
00883 d.put("mode", EMObject::INT, "Currently unused");
00884 d.put("xform.align2d", EMObject::TRANSFORM, "The Transform storing the starting guess. If unspecified the identity matrix is used");
00885 d.put("stepx", EMObject::FLOAT, "The x increment used to create the starting simplex. Default is 1");
00886 d.put("stepy", EMObject::FLOAT, "The y increment used to create the starting simplex. Default is 1");
00887 d.put("stepaz", EMObject::FLOAT, "The rotational increment used to create the starting simplex. Default is 5");
00888 d.put("precision", EMObject::FLOAT, "The precision which, if achieved, can stop the iterative refinement before reaching the maximum iterations. Default is 0.04.");
00889 d.put("maxiter", EMObject::INT,"The maximum number of iterations that can be performed by the Simplex minimizer");
00890 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.");
00891 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.");
00892 return d;
00893 }
00894
00895 static const string NAME;
00896 };
00897
00916 class Refine3DAlignerGrid:public Aligner
00917 {
00918 public:
00919 virtual EMData * align(EMData * this_img, EMData * to_img,
00920 const string & cmp_name="sqeuclidean", const Dict& cmp_params = Dict()) const;
00921
00922 virtual EMData * align(EMData * this_img, EMData * to_img) const
00923 {
00924 return align(this_img, to_img, "sqeuclidean", Dict());
00925 }
00926
00927 virtual string get_name() const
00928 {
00929 return NAME;
00930 }
00931
00932 virtual string get_desc() const
00933 {
00934 return "Refines a preliminary 3D alignment using a simplex algorithm. Subpixel precision.";
00935 }
00936
00937 static Aligner *NEW()
00938 {
00939 return new Refine3DAlignerGrid();
00940 }
00941
00942 virtual TypeDict get_param_types() const
00943 {
00944 TypeDict d;
00945 d.put("xform.align3d", EMObject::TRANSFORM,"The Transform storing the starting guess. If unspecified the identity matrix is used");
00946 d.put("delta", EMObject::FLOAT, "The angular step size. Default is 1." );
00947 d.put("range", EMObject::FLOAT, "The angular range size. Default is 10." );
00948 d.put("dotrans", EMObject::BOOL,"Do a translational search. Default is True(1)");
00949 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.");
00950 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.");
00951 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.");
00952 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");
00953 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.");
00954 d.put("verbose", EMObject::BOOL,"Turn this on to have useful information printed to standard out.");
00955 return d;
00956 }
00957
00958 static const string NAME;
00959 };
00960
00982 class Refine3DAlignerQuaternion:public Aligner
00983 {
00984 public:
00985 virtual EMData * align(EMData * this_img, EMData * to_img,
00986 const string & cmp_name="sqeuclidean", const Dict& cmp_params = Dict()) const;
00987
00988 virtual EMData * align(EMData * this_img, EMData * to_img) const
00989 {
00990 return align(this_img, to_img, "sqeuclidean", Dict());
00991 }
00992
00993 virtual string get_name() const
00994 {
00995 return NAME;
00996 }
00997
00998 virtual string get_desc() const
00999 {
01000 return "Refines a preliminary 3D alignment using a simplex algorithm. Subpixel precision.";
01001 }
01002
01003 static Aligner *NEW()
01004 {
01005 return new Refine3DAlignerQuaternion();
01006 }
01007
01008 virtual TypeDict get_param_types() const
01009 {
01010 TypeDict d;
01011 d.put("xform.align3d", EMObject::TRANSFORM,"The Transform storing the starting guess. If unspecified the identity matrix is used");
01012 d.put("stepx", EMObject::FLOAT, "The initial simplex step size in x. Default is 1");
01013 d.put("stepy", EMObject::FLOAT, "The initial simplex step size in y. Default is 1");
01014 d.put("stepz", EMObject::FLOAT, "The initial simplex step size in z. Default is 1." );
01015 d.put("stepn0", EMObject::FLOAT, "The initial simplex step size in the first quaternion vecotr component. Default is 1." );
01016 d.put("stepn1", EMObject::FLOAT, "The initial simplex step size in the second quaternion vecotr component. Default is 1." );
01017 d.put("stepn2", EMObject::FLOAT, "The initial simplex step size in the third quaternion vecotr component. Default is 1." );
01018 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.");
01019 d.put("precision", EMObject::FLOAT, "The precision which, if achieved, can stop the iterative refinement before reaching the maximum iterations. Default is 0.01." );
01020 d.put("maxiter", EMObject::INT, "The maximum number of iterations that can be performed by the Simplex minimizer. Default is 100.");
01021 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.");
01022 return d;
01023 }
01024
01025 static const string NAME;
01026 };
01027
01051 class RT3DGridAligner:public Aligner
01052 {
01053 public:
01056 virtual EMData * align(EMData * this_img, EMData * to_img,
01057 const string & cmp_name="ccc.tomo", const Dict& cmp_params = Dict()) const;
01060 virtual EMData * align(EMData * this_img, EMData * to_img) const
01061 {
01062 return align(this_img, to_img, "ccc.tomo", Dict());
01063 }
01064
01065
01068 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;
01069
01070 virtual string get_name() const
01071 {
01072 return NAME;
01073 }
01074
01075 virtual string get_desc() const
01076 {
01077 return "3D rotational and translational alignment using specified ranges and maximum shifts";
01078 }
01079
01080 static Aligner *NEW()
01081 {
01082 return new RT3DGridAligner();
01083 }
01084
01085 virtual TypeDict get_param_types() const
01086 {
01087 TypeDict d;
01088 d.put("daz", EMObject::FLOAT,"The angle increment in the azimuth direction. Default is 10");
01089 d.put("az0", EMObject::FLOAT,"Lower bound for the azimuth direction. Default it 0");
01090 d.put("az1", EMObject::FLOAT,"Upper bound for the azimuth direction. Default it 180.0");
01091 d.put("dphi", EMObject::FLOAT,"The angle increment in the phi direction. Default is 10");
01092 d.put("phi0", EMObject::FLOAT,"Lower bound for the phi direction. Default it 0");
01093 d.put("phi1", EMObject::FLOAT,"Upper bound for the phi direction. Default it 360.0");
01094 d.put("dalt", EMObject::FLOAT,"The angle increment in the altitude direction. Default is 10");
01095 d.put("alt0", EMObject::FLOAT,"Lower bound for the altitude direction. Default it 0");
01096 d.put("alt1", EMObject::FLOAT,"Upper bound for the altitude direction. Default it 360.0");
01097 d.put("dotrans", EMObject::BOOL,"Do a translational search. Default is True(1)");
01098 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.");
01099 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.");
01100 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.");
01101 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");
01102 d.put("verbose", EMObject::BOOL,"Turn this on to have useful information printed to standard out.");
01103 return d;
01104 }
01105
01106 static const string NAME;
01107 };
01108
01134 class RT3DSphereAligner:public Aligner
01135 {
01136 public:
01139 virtual EMData * align(EMData * this_img, EMData * to_img,
01140 const string & cmp_name= "sqeuclidean", const Dict& cmp_params = Dict()) const;
01143 virtual EMData * align(EMData * this_img, EMData * to_img) const
01144 {
01145 return align(this_img, to_img, "sqeuclidean", Dict());
01146 }
01147
01148
01151 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;
01152
01153 virtual string get_name() const
01154 {
01155 return NAME;
01156 }
01157
01158 virtual string get_desc() const
01159 {
01160 return "3D rotational and translational alignment using spherical sampling. Can reduce the search space if symmetry is supplied";
01161 }
01162
01163 static Aligner *NEW()
01164 {
01165 return new RT3DSphereAligner();
01166 }
01167
01168 virtual TypeDict get_param_types() const
01169 {
01170 TypeDict d;
01171 d.put("sym", EMObject::STRING,"The symmtery to use as the basis of the spherical sampling. Default is c1 (asymmetry).");
01172 d.put("orientgen", EMObject::STRING,"Advanced. The orientation generation strategy. Default is eman");
01173 d.put("delta", EMObject::FLOAT,"Angle the separates points on the sphere. This is exclusive of the \'n\' paramater. Default is 10");
01174 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");
01175 d.put("dphi", EMObject::FLOAT,"The angle increment in the phi direction. Default is 10");
01176 d.put("phi0", EMObject::FLOAT,"Lower bound for phi. Default it 0");
01177 d.put("phi1", EMObject::FLOAT,"Upper bound for phi. Default it 360");
01178 d.put("dotrans", EMObject::BOOL,"Do a translational search. Default is True(1)");
01179 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.");
01180 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.");
01181 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.");
01182 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");
01183 d.put("verbose", EMObject::BOOL,"Turn this on to have useful information printed to standard out.");
01184 return d;
01185 }
01186
01187 static const string NAME;
01188 };
01189
01201 class RT3DSymmetryAligner:public Aligner
01202 {
01203 public:
01206 virtual EMData * align(EMData * this_img, EMData * to_img,
01207 const string & cmp_name="ccc.tomo", const Dict& cmp_params = Dict()) const;
01210 virtual EMData * align(EMData * this_img, EMData * to_img) const
01211 {
01212 return align(this_img, to_img, "ccc.tomo", Dict());
01213 }
01214
01215
01218 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;
01219
01220 virtual string get_name() const
01221 {
01222 return NAME;
01223 }
01224
01225 virtual string get_desc() const
01226 {
01227 return "3D symmetry aligner";
01228 }
01229
01230 static Aligner *NEW()
01231 {
01232 return new RT3DSymmetryAligner();
01233 }
01234
01235 virtual TypeDict get_param_types() const
01236 {
01237 TypeDict d;
01238 d.put("sym", EMObject::FLOAT,"The symmetry. Default is icos");
01239 d.put("verbose", EMObject::BOOL,"Turn this on to have useful information printed to standard out.");
01240 return d;
01241 }
01242
01243 static const string NAME;
01244 };
01245
01246 class FRM2DAligner:public Aligner
01247 {
01248 public:
01249 virtual EMData * align(EMData * this_img, EMData * to_img,
01250 const string& cmp_name, const Dict& cmp_params=Dict()) const;
01251
01252 virtual EMData * align(EMData * this_img, EMData * to_img) const
01253 {
01254 return align(this_img, to_img, "frc", Dict());
01255 }
01256
01257 string get_name() const
01258 {
01259 return NAME;
01260 }
01261
01262 string get_desc() const
01263 {
01264 return "FRM2D uses two rotational parameters and one translational parameter";
01265 }
01266
01267 static Aligner *NEW()
01268 {
01269 return new FRM2DAligner();
01270 }
01271 virtual TypeDict get_param_types() const
01272 {
01273 TypeDict d;
01274 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.");
01275
01276
01277 return d;
01278 }
01279
01280 static const string NAME;
01281 };
01282
01283
01284 class CUDA_Aligner
01285 {
01286 public:
01287 CUDA_Aligner(int id);
01288
01289 void finish();
01290
01291 void setup(int nima, int nx, int ny, int ring_length, int nring, int ou, float step, int kx, int ky, bool ctf);
01292
01293 void insert_image(EMData *image, int num);
01294
01295 void filter_stack(vector<float> ctf_params);
01296
01297 void sum_oe(vector<float> ctf_params, vector<float> ali_params, EMData* ave1, EMData *ave2);
01298
01299 vector<float> alignment_2d(EMData *ref_image, vector<float> sx, vector<float> sy, int silent);
01300
01301 vector<float> ali2d_single_iter(EMData *ref_image, vector<float> ali_params, float csx, float csy, int silent, float delta);
01302
01303 private:
01304 float *image_stack, *image_stack_filtered;
01305 float *ccf;
01306 int NIMA, NX, NY, RING_LENGTH, NRING, OU, KX, KY;
01307 bool CTF;
01308 float STEP;
01309 };
01310
01311 class CUDA_multiref_aligner
01312 {
01313 public:
01314 CUDA_multiref_aligner(int id);
01315
01316 void finish();
01317
01318 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);
01319
01320 void setup_params(vector<float> all_ali_params, vector<float> all_ctf_params);
01321
01322 void insert_image(EMData *image, int num);
01323
01324 void insert_ref_image(EMData *image, int num);
01325
01326 vector<float> multiref_ali2d(int silent);
01327
01328 private:
01329 float *image_stack, *ref_image_stack, *ref_image_stack_filtered;
01330 float *ccf;
01331 float *ali_params, *ctf_params;
01332 int NIMA, NREF, NX, NY, RING_LENGTH, NRING, OU, KX, KY, MAX_IMAGE_BATCH;
01333 bool CTF;
01334 float STEP;
01335 };
01336
01337 template <> Factory < Aligner >::Factory();
01338
01339 void dump_aligners();
01340 map<string, vector<string> > dump_aligners_list();
01341 }
01342
01343 #endif