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 vector<Dict> solns;
00146 return solns;
00147 }
00148
00149 protected:
00150 mutable Dict params;
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163 };
00164
00173 class TranslationalAligner:public Aligner
00174 {
00175 public:
00176 virtual EMData * align(EMData * this_img, EMData * to_img,
00177 const string & cmp_name="dot", const Dict& cmp_params = Dict()) const;
00178
00179 virtual EMData * align(EMData * this_img, EMData * to_img) const
00180 {
00181 return align(this_img, to_img, "dot", Dict());
00182 }
00183
00184 virtual string get_name() const
00185 {
00186 return NAME;
00187 }
00188
00189 virtual string get_desc() const
00190 {
00191 return "Translational 2D and 3D alignment by cross-correlation";
00192 }
00193
00194 static Aligner *NEW()
00195 {
00196 return new TranslationalAligner();
00197 }
00198
00199 virtual TypeDict get_param_types() const
00200 {
00201 TypeDict d;
00202 d.put("intonly", EMObject::INT,"Integer pixel translations only");
00203 d.put("useflcf", EMObject::INT,"Use Fast Local Correlation Function rather than CCF");
00204 d.put("maxshift", EMObject::INT,"Maximum translation in pixels");
00205 d.put("masked", EMObject::INT,"Treat zero pixels in 'this' as a mask for normalization (default false)");
00206 d.put("nozero", EMObject::INT,"Zero translation not permitted (useful for CCD images)");
00207 return d;
00208 }
00209
00210 static const string NAME;
00211 };
00212
00217 class RotationalAligner:public Aligner
00218 {
00219 public:
00220 virtual EMData * align(EMData * this_img, EMData * to_img,
00221 const string & cmp_name = "dot", const Dict& cmp_params = Dict()) const;
00222
00223 virtual EMData * align(EMData * this_img, EMData * to_img) const
00224 {
00225 return align(this_img, to_img, "dot", Dict());
00226 }
00227
00228 virtual string get_name() const
00229 {
00230 return NAME;
00231 }
00232
00233 virtual string get_desc() const
00234 {
00235 return "Performs rotational alignment,works accurately if the image is precentered, normally called internally in combination with translational and flip alignment";
00236 }
00237
00238 static Aligner *NEW()
00239 {
00240 return new RotationalAligner();
00241 }
00242
00243 static EMData * align_180_ambiguous(EMData * this_img, EMData * to_img, int rfp_mode = 0);
00244
00245 virtual TypeDict get_param_types() const
00246 {
00247 TypeDict d;
00248 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.");
00249 return d;
00250 }
00251
00252 static const string NAME;
00253 };
00254
00260 class RotationalAlignerIterative:public Aligner
00261 {
00262 public:
00263 virtual EMData * align(EMData * this_img, EMData * to_img,
00264 const string & cmp_name = "dot", const Dict& cmp_params = Dict()) const;
00265
00266 virtual EMData * align(EMData * this_img, EMData * to_img) const
00267 {
00268 return align(this_img, to_img, "dot", Dict());
00269 }
00270
00271 virtual string get_name() const
00272 {
00273 return NAME;
00274 }
00275
00276 virtual string get_desc() const
00277 {
00278 return "Performs rotational alignment using the SPIDER method";
00279 }
00280
00281 static Aligner *NEW()
00282 {
00283 return new RotationalAlignerIterative();
00284 }
00285
00286 virtual TypeDict get_param_types() const
00287 {
00288 TypeDict d;
00289 d.put("r1", EMObject::INT, "Inner ring, pixels");
00290 d.put("r2", EMObject::INT, "Outer ring, pixels");
00291 return d;
00292 }
00293
00294 static const string NAME;
00295 };
00296
00299 class RotatePrecenterAligner:public Aligner
00300 {
00301 public:
00302 virtual EMData * align(EMData * this_img, EMData * to_img,
00303 const string & cmp_name = "dot", const Dict& cmp_params = Dict()) const;
00304
00305 virtual EMData * align(EMData * this_img, EMData * to_img) const
00306 {
00307 return align(this_img, to_img, "dot", Dict());
00308 }
00309
00310 virtual string get_name() const
00311 {
00312 return NAME;
00313 }
00314
00315 virtual string get_desc() const
00316 {
00317 return "Performs rotational alignment and works accurately if the image is precentered";
00318 }
00319
00320 static Aligner *NEW()
00321 {
00322 return new RotatePrecenterAligner();
00323 }
00324
00325 virtual TypeDict get_param_types() const
00326 {
00327 TypeDict d;
00328 return d;
00329 }
00330
00331 static const string NAME;
00332 };
00333
00340 class RotateTranslateAligner:public Aligner
00341 {
00342 public:
00343 virtual EMData * align(EMData * this_img, EMData * to_img,
00344 const string & cmp_name="dot", const Dict& cmp_params = Dict()) const;
00345
00346 virtual EMData * align(EMData * this_img, EMData * to_img) const
00347 {
00348 return align(this_img, to_img, "sqeuclidean", Dict());
00349 }
00350
00351 virtual string get_name() const
00352 {
00353 return NAME;
00354 }
00355
00356 virtual string get_desc() const
00357 {
00358 return "Performs rotational alignment and follows this with translational alignment.";
00359 }
00360
00361 static Aligner *NEW()
00362 {
00363 return new RotateTranslateAligner();
00364 }
00365
00366 virtual TypeDict get_param_types() const
00367 {
00368 TypeDict d;
00369
00370 d.put("maxshift", EMObject::INT, "Maximum translation in pixels");
00371 d.put("nozero", EMObject::INT,"Zero translation not permitted (useful for CCD images)");
00372 d.put("rfp_mode", EMObject::INT,"Either 0,1 or 2. A temporary flag for testing the rotational foot print");
00373 d.put("useflcf", EMObject::INT,"Use Fast Local Correlation Function rather than CCF for translational alignment");
00374 return d;
00375 }
00376
00377 static const string NAME;
00378 };
00379
00388 class RotateTranslateAlignerIterative:public Aligner
00389 {
00390 public:
00391 virtual EMData * align(EMData * this_img, EMData * to_img,
00392 const string & cmp_name="dot", const Dict& cmp_params = Dict()) const;
00393
00394 virtual EMData * align(EMData * this_img, EMData * to_img) const
00395 {
00396 return align(this_img, to_img, "sqeuclidean", Dict());
00397 }
00398
00399 virtual string get_name() const
00400 {
00401 return NAME;
00402 }
00403
00404 virtual string get_desc() const
00405 {
00406 return "Performs rotational alignment and follows this with translational alignment using the iterative method.";
00407 }
00408
00409 static Aligner *NEW()
00410 {
00411 return new RotateTranslateAlignerIterative();
00412 }
00413
00414 virtual TypeDict get_param_types() const
00415 {
00416 TypeDict d;
00417
00418 d.put("maxshift", EMObject::INT, "Maximum translation in pixels");
00419 d.put("r1", EMObject::INT, "Inner ring, pixels");
00420 d.put("r2", EMObject::INT, "Outer ring, pixels");
00421 d.put("maxiter", EMObject::INT, "Maximum number of iterations");
00422 d.put("nozero", EMObject::INT,"Zero translation not permitted (useful for CCD images)");
00423 d.put("useflcf", EMObject::INT,"Use Fast Local Correlation Function rather than CCF for translational alignment");
00424 return d;
00425 }
00426
00427 static const string NAME;
00428 };
00429
00434 class RotateTranslateBestAligner:public Aligner
00435 {
00436 public:
00437 virtual EMData * align(EMData * this_img, EMData * to_img,
00438 const string & cmp_name="dot", const Dict& cmp_params = Dict()) const;
00439
00440 virtual EMData * align(EMData * this_img, EMData * to_img) const
00441 {
00442 return align(this_img, to_img, "frc", Dict());
00443 }
00444
00445 virtual string get_name() const
00446 {
00447 return NAME;
00448 }
00449
00450 virtual string get_desc() const
00451 {
00452 return "Full 2D alignment using 'Rotational' and 'Translational', also incorporates 2D 'Refine' alignments.";
00453 }
00454
00455 static Aligner *NEW()
00456 {
00457 return new RotateTranslateBestAligner();
00458 }
00459
00460 virtual TypeDict get_param_types() const
00461 {
00462 TypeDict d;
00463 d.put("maxshift", EMObject::INT, "Maximum translation in pixels");
00464 d.put("snr", EMObject::FLOATARRAY, "signal to noise ratio array");
00465 return d;
00466 }
00467
00468 static const string NAME;
00469 };
00470
00476 class RotateFlipAligner:public Aligner
00477 {
00478 public:
00479 virtual EMData * align(EMData * this_img, EMData * to_img,
00480 const string & cmp_name="dot", const Dict& cmp_params = Dict()) const;
00481 virtual EMData * align(EMData * this_img, EMData * to_img) const
00482 {
00483 return align(this_img, to_img, "dot", Dict());
00484 }
00485 virtual string get_name() const
00486 {
00487 return NAME;
00488 }
00489
00490 virtual string get_desc() const
00491 {
00492 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";
00493 }
00494
00495 static Aligner *NEW()
00496 {
00497 return new RotateFlipAligner();
00498 }
00499
00500 virtual TypeDict get_param_types() const
00501 {
00502 return static_get_param_types();
00503 }
00504
00505 static TypeDict static_get_param_types() {
00506 TypeDict d;
00507
00508 d.put("imask", EMObject::INT);
00509 d.put("rfp_mode", EMObject::INT,"Either 0,1 or 2. A temporary flag for testing the rotational foot print");
00510 return d;
00511 }
00512
00513 static const string NAME;
00514 };
00515
00522 class RotateFlipAlignerIterative:public Aligner
00523 {
00524 public:
00525 virtual EMData * align(EMData * this_img, EMData * to_img,
00526 const string & cmp_name="dot", const Dict& cmp_params = Dict()) const;
00527 virtual EMData * align(EMData * this_img, EMData * to_img) const
00528 {
00529 return align(this_img, to_img, "dot", Dict());
00530 }
00531 virtual string get_name() const
00532 {
00533 return NAME;
00534 }
00535
00536 virtual string get_desc() const
00537 {
00538 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";
00539 }
00540
00541 static Aligner *NEW()
00542 {
00543 return new RotateFlipAlignerIterative();
00544 }
00545
00546 virtual TypeDict get_param_types() const
00547 {
00548 return static_get_param_types();
00549 }
00550
00551 static TypeDict static_get_param_types() {
00552 TypeDict d;
00553 d.put("r1", EMObject::INT, "Inner ring, pixels");
00554 d.put("r2", EMObject::INT, "Outer ring, pixels");
00555 return d;
00556 }
00557
00558 static const string NAME;
00559 };
00560
00568 class RotateTranslateFlipAligner:public Aligner
00569 {
00570 public:
00571 virtual EMData * align(EMData * this_img, EMData * to_img,
00572 const string & cmp_name="dot", const Dict& cmp_params = Dict()) const;
00573 virtual EMData * align(EMData * this_img, EMData * to_img) const
00574 {
00575 return align(this_img, to_img, "sqeuclidean", Dict());
00576 }
00577
00578 virtual string get_name() const
00579 {
00580 return NAME;
00581 }
00582
00583 virtual string get_desc() const
00584 {
00585 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";
00586 }
00587
00588 static Aligner *NEW()
00589 {
00590 return new RotateTranslateFlipAligner();
00591 }
00592
00593 virtual TypeDict get_param_types() const
00594 {
00595 return static_get_param_types();
00596 }
00597
00598 static TypeDict static_get_param_types() {
00599 TypeDict d;
00600
00601 d.put("flip", EMObject::EMDATA);
00602 d.put("usedot", EMObject::INT);
00603 d.put("maxshift", EMObject::INT, "Maximum translation in pixels");
00604 d.put("rfp_mode", EMObject::INT,"Either 0,1 or 2. A temporary flag for testing the rotational foot print");
00605 d.put("useflcf", EMObject::INT,"Use Fast Local Correlation Function rather than CCF for translational alignment");
00606 return d;
00607 }
00608
00609 static const string NAME;
00610 };
00611
00620 class RotateTranslateFlipAlignerIterative:public Aligner
00621 {
00622 public:
00623 virtual EMData * align(EMData * this_img, EMData * to_img,
00624 const string & cmp_name="dot", const Dict& cmp_params = Dict()) const;
00625 virtual EMData * align(EMData * this_img, EMData * to_img) const
00626 {
00627 return align(this_img, to_img, "sqeuclidean", Dict());
00628 }
00629
00630 virtual string get_name() const
00631 {
00632 return NAME;
00633 }
00634
00635 virtual string get_desc() const
00636 {
00637 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";
00638 }
00639
00640 static Aligner *NEW()
00641 {
00642 return new RotateTranslateFlipAlignerIterative();
00643 }
00644
00645 virtual TypeDict get_param_types() const
00646 {
00647 return static_get_param_types();
00648 }
00649
00650 static TypeDict static_get_param_types() {
00651 TypeDict d;
00652 d.put("flip", EMObject::EMDATA);
00653 d.put("r1", EMObject::INT, "Inner ring, pixels");
00654 d.put("r2", EMObject::INT, "Outer ring, pixels");
00655 d.put("maxiter", EMObject::INT, "Maximum number of iterations");
00656 d.put("maxshift", EMObject::INT, "Maximum translation in pixels");
00657 return d;
00658 }
00659
00660 static const string NAME;
00661 };
00662
00667 class RTFExhaustiveAligner:public Aligner
00668 {
00669 public:
00670 virtual EMData * align(EMData * this_img, EMData * to_img,
00671 const string & cmp_name="dot", const Dict& cmp_params = Dict()) const;
00672 virtual EMData * align(EMData * this_img, EMData * to_img) const
00673 {
00674 return align(this_img, to_img, "sqeuclidean", Dict());
00675 }
00676
00677 virtual string get_name() const
00678 {
00679 return NAME;
00680 }
00681
00682 virtual string get_desc() const
00683 {
00684 return "Experimental full 2D alignment with handedness check using semi-exhaustive search (not necessarily better than RTFBest)";
00685 }
00686
00687 static Aligner *NEW()
00688 {
00689 return new RTFExhaustiveAligner();
00690 }
00691
00692 virtual TypeDict get_param_types() const
00693 {
00694 TypeDict d;
00695
00696 d.put("flip", EMObject::EMDATA);
00697 d.put("maxshift", EMObject::INT, "Maximum translation in pixels");
00698 return d;
00699 }
00700
00701 static const string NAME;
00702 };
00703
00711 class RTFSlowExhaustiveAligner:public Aligner
00712 {
00713 public:
00714 virtual EMData * align(EMData * this_img, EMData * to_img,
00715 const string & cmp_name, const Dict& cmp_params) const;
00716 virtual EMData * align(EMData * this_img, EMData * to_img) const
00717 {
00718 return align(this_img, to_img, "sqeuclidean", Dict());
00719 }
00720 virtual string get_name() const
00721 {
00722 return NAME;
00723 }
00724
00725 virtual string get_desc() const
00726 {
00727 return "Experimental full 2D alignment with handedness check using more exhaustive search (not necessarily better than RTFBest)";
00728 }
00729
00730 static Aligner *NEW()
00731 {
00732 return new RTFSlowExhaustiveAligner();
00733 }
00734
00735 virtual TypeDict get_param_types() const
00736 {
00737 TypeDict d;
00738 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");
00739 d.put("maxshift", EMObject::INT,"The maximum length of the detectable translational shift");
00740 d.put("transtep", EMObject::FLOAT,"The translation step to take when honing the alignment, which occurs after coarse alignment");
00741 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.");
00742 return d;
00743 }
00744
00745 static const string NAME;
00746 };
00747
00750 class RefineAligner:public Aligner
00751 {
00752 public:
00753 virtual EMData * align(EMData * this_img, EMData * to_img,
00754 const string & cmp_name="dot", const Dict& cmp_params = Dict()) const;
00755
00756 virtual EMData * align(EMData * this_img, EMData * to_img) const
00757 {
00758 return align(this_img, to_img, "sqeuclidean", Dict());
00759 }
00760
00761 virtual string get_name() const
00762 {
00763 return NAME;
00764 }
00765
00766 virtual string get_desc() const
00767 {
00768 return "Refines a preliminary 2D alignment using a simplex algorithm. Subpixel precision.";
00769 }
00770
00771 static Aligner *NEW()
00772 {
00773 return new RefineAligner();
00774 }
00775
00776 virtual TypeDict get_param_types() const
00777 {
00778 TypeDict d;
00779
00780 d.put("mode", EMObject::INT, "Currently unused");
00781 d.put("xform.align2d", EMObject::TRANSFORM, "The Transform storing the starting guess. If unspecified the identity matrix is used");
00782 d.put("stepx", EMObject::FLOAT, "The x increment used to create the starting simplex. Default is 1");
00783 d.put("stepy", EMObject::FLOAT, "The y increment used to create the starting simplex. Default is 1");
00784 d.put("stepaz", EMObject::FLOAT, "The rotational increment used to create the starting simplex. Default is 5");
00785 d.put("precision", EMObject::FLOAT, "The precision which, if achieved, can stop the iterative refinement before reaching the maximum iterations. Default is 0.04.");
00786 d.put("maxiter", EMObject::INT,"The maximum number of iterations that can be performed by the Simplex minimizer");
00787 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.");
00788 return d;
00789 }
00790
00791 static const string NAME;
00792 };
00793
00794
00795
00796
00797
00798
00799
00800
00801
00809 class Refine3DAligner:public Aligner
00810 {
00811 public:
00812 virtual EMData * align(EMData * this_img, EMData * to_img,
00813 const string & cmp_name="sqeuclidean", const Dict& cmp_params = Dict()) const;
00814
00815 virtual EMData * align(EMData * this_img, EMData * to_img) const
00816 {
00817 return align(this_img, to_img, "sqeuclidean", Dict());
00818 }
00819
00820 virtual string get_name() const
00821 {
00822 return NAME;
00823 }
00824
00825 virtual string get_desc() const
00826 {
00827 return "Refines a preliminary 3D alignment using a simplex algorithm. Subpixel precision.";
00828 }
00829
00830 static Aligner *NEW()
00831 {
00832 return new Refine3DAligner();
00833 }
00834
00835 virtual TypeDict get_param_types() const
00836 {
00837 TypeDict d;
00838 d.put("xform.align3d", EMObject::TRANSFORM,"The Transform storing the starting guess. If unspecified the identity matrix is used");
00839 d.put("stepx", EMObject::FLOAT, "The x increment used to create the starting simplex. Default is 1");
00840 d.put("stepy", EMObject::FLOAT, "The y increment used to create the starting simplex. Default is 1");
00841 d.put("stepz", EMObject::FLOAT, "The z increment used to create the starting simplex. Default is 1." );
00842 d.put("stepaz", EMObject::FLOAT, "The az increment used to create the starting simplex. Default is 5." );
00843 d.put("stepalt", EMObject::FLOAT, "The alt increment used to create the starting simplex. Default is 5." );
00844 d.put("stepphi", EMObject::FLOAT, "The phi incremenent used to create the starting simplex. Default is 5." );
00845 d.put("precision", EMObject::FLOAT, "The precision which, if achieved, can stop the iterative refinement before reaching the maximum iterations. Default is 0.04." );
00846 d.put("maxiter", EMObject::INT, "The maximum number of iterations that can be performed by the Simplex minimizer. Default is 60.");
00847 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.");
00848 return d;
00849 }
00850
00851 static const string NAME;
00852 };
00853
00860 class RT3DGridAligner:public Aligner
00861 {
00862 public:
00865 virtual EMData * align(EMData * this_img, EMData * to_img,
00866 const string & cmp_name="ccc.tomo", const Dict& cmp_params = Dict()) const;
00869 virtual EMData * align(EMData * this_img, EMData * to_img) const
00870 {
00871 return align(this_img, to_img, "ccc.tomo", Dict());
00872 }
00873
00874
00877 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;
00878
00879 virtual string get_name() const
00880 {
00881 return NAME;
00882 }
00883
00884 virtual string get_desc() const
00885 {
00886 return "3D rotational and translational alignment using specified ranges and maximum shifts";
00887 }
00888
00889 static Aligner *NEW()
00890 {
00891 return new RT3DGridAligner();
00892 }
00893
00894 virtual TypeDict get_param_types() const
00895 {
00896 TypeDict d;
00897 d.put("daz", EMObject::FLOAT,"The angle increment in the azimuth direction. Default is 10");
00898 d.put("laz", EMObject::FLOAT,"Lower bound for the azimuth direction. Default it 0");
00899 d.put("uaz", EMObject::FLOAT,"Upper bound for the azimuth direction. Default it 179.9");
00900 d.put("dphi", EMObject::FLOAT,"The angle increment in the phi direction. Default is 10");
00901 d.put("lphi", EMObject::FLOAT,"Lower bound for the phi direction. Default it 0");
00902 d.put("uphi", EMObject::FLOAT,"Upper bound for the phi direction. Default it 359.9");
00903 d.put("dalt", EMObject::FLOAT,"The angle increment in the altitude direction. Default is 10");
00904 d.put("lalt", EMObject::FLOAT,"Lower bound for the altitude direction. Default it 0");
00905 d.put("ualt", EMObject::FLOAT,"Upper bound for the altitude direction. Default it 359.9");
00906 d.put("dotrans", EMObject::BOOL,"Do a translational search. Default is True(1)");
00907 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.");
00908 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.");
00909 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.");
00910 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");
00911 d.put("verbose", EMObject::BOOL,"Turn this on to have useful information printed to standard out.");
00912 return d;
00913 }
00914
00915 static const string NAME;
00916 };
00917
00924 class RT3DSphereAligner:public Aligner
00925 {
00926 public:
00929 virtual EMData * align(EMData * this_img, EMData * to_img,
00930 const string & cmp_name= "sqeuclidean", const Dict& cmp_params = Dict()) const;
00933 virtual EMData * align(EMData * this_img, EMData * to_img) const
00934 {
00935 return align(this_img, to_img, "sqeuclidean", Dict());
00936 }
00937
00938
00941 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;
00942
00943 virtual string get_name() const
00944 {
00945 return NAME;
00946 }
00947
00948 virtual string get_desc() const
00949 {
00950 return "3D rotational and translational alignment using spherical sampling. Can reduce the search space if symmetry is supplied";
00951 }
00952
00953 static Aligner *NEW()
00954 {
00955 return new RT3DSphereAligner();
00956 }
00957
00958 virtual TypeDict get_param_types() const
00959 {
00960 TypeDict d;
00961 d.put("sym", EMObject::STRING,"The symmtery to use as the basis of the spherical sampling. Default is c1 (asymmetry).");
00962 d.put("orientgen", EMObject::STRING,"Advanced. The orientation generation strategy. Default is eman");
00963 d.put("delta", EMObject::FLOAT,"Angle the separates points on the sphere. This is exclusive of the \'n\' paramater. Default is 10");
00964 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");
00965 d.put("dphi", EMObject::FLOAT,"The angle increment in the phi direction. Default is 10");
00966 d.put("lphi", EMObject::FLOAT,"Lower bound for phi. Default it 0");
00967 d.put("uphi", EMObject::FLOAT,"Upper bound for phi. Default it 359.9");
00968 d.put("dotrans", EMObject::BOOL,"Do a translational search. Default is True(1)");
00969 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.");
00970 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.");
00971 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.");
00972 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");
00973 d.put("verbose", EMObject::BOOL,"Turn this on to have useful information printed to standard out.");
00974 return d;
00975 }
00976
00977 static const string NAME;
00978 };
00979
00980
00981 class FRM2DAligner:public Aligner
00982 {
00983 public:
00984 virtual EMData * align(EMData * this_img, EMData * to_img,
00985 const string& cmp_name, const Dict& cmp_params=Dict()) const;
00986
00987 virtual EMData * align(EMData * this_img, EMData * to_img) const
00988 {
00989 return align(this_img, to_img, "frc", Dict());
00990 }
00991
00992 string get_name() const
00993 {
00994 return NAME;
00995 }
00996
00997 string get_desc() const
00998 {
00999 return "FRM2D uses two rotational parameters and one translational parameter";
01000 }
01001
01002 static Aligner *NEW()
01003 {
01004 return new FRM2DAligner();
01005 }
01006 virtual TypeDict get_param_types() const
01007 {
01008 TypeDict d;
01009 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.");
01010
01011
01012 return d;
01013 }
01014
01015 static const string NAME;
01016 };
01017
01018
01019 class CUDA_Aligner
01020 {
01021 public:
01022 CUDA_Aligner();
01023
01024 void finish();
01025
01026 void setup(int nima, int nx, int ny, int ring_length, int nring, int ou, float step, int kx, int ky, bool ctf);
01027
01028 void insert_image(EMData *image, int num);
01029
01030 void filter_stack(vector<float> ctf_params, int id);
01031
01032 void sum_oe(vector<float> ctf_params, vector<float> ali_params, EMData* ave1, EMData *ave2, int id);
01033
01034 vector<float> alignment_2d(EMData *ref_image, vector<float> sx, vector<float> sy, int id, int silent);
01035
01036 vector<float> ali2d_single_iter(EMData *ref_image, vector<float> ali_params, float csx, float csy, int id, int silent, float delta);
01037
01038 private:
01039 float *image_stack, *image_stack_filtered;
01040 float *ccf;
01041 int NIMA, NX, NY, RING_LENGTH, NRING, OU, KX, KY;
01042 bool CTF;
01043 float STEP;
01044 };
01045
01046 class CUDA_multiref_aligner
01047 {
01048 public:
01049 CUDA_multiref_aligner();
01050
01051 void finish();
01052
01053 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);
01054
01055 void setup_params(vector<float> all_ali_params, vector<float> all_ctf_params);
01056
01057 void insert_image(EMData *image, int num);
01058
01059 void insert_ref_image(EMData *image, int num);
01060
01061 vector<float> multiref_ali2d(int gpuid, int silent);
01062
01063 private:
01064 float *image_stack, *ref_image_stack, *ref_image_stack_filtered;
01065 float *ccf;
01066 float *ali_params, *ctf_params;
01067 int NIMA, NREF, NX, NY, RING_LENGTH, NRING, OU, KX, KY, MAX_IMAGE_BATCH;
01068 bool CTF;
01069 float STEP;
01070 };
01071
01072 template <> Factory < Aligner >::Factory();
01073
01074 void dump_aligners();
01075 map<string, vector<string> > dump_aligners_list();
01076 }
01077
01078 #endif