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_reconstructor_h__
00037 #define eman_reconstructor_h__ 1
00038 #include <fstream>
00039 #include <boost/shared_ptr.hpp>
00040 #include "emdata.h"
00041 #include "exception.h"
00042 #include "emobject.h"
00043 #include "interp.h"
00044
00045 using std::vector;
00046 using std::map;
00047 using std::string;
00048 using boost::shared_ptr;
00049
00050 using std::cout;
00051 using std::cerr;
00052 using std::endl;
00053
00054 #include <utility>
00055 using std::pair;
00056
00057 #include "reconstructor_tools.h"
00058
00059 namespace EMAN
00060 {
00061
00062 class Transform;
00063 class EMData;
00064
00110 class Reconstructor : public FactoryBase
00111 {
00112 public:
00113 Reconstructor() {}
00114 virtual ~Reconstructor() {}
00117 virtual void setup() = 0;
00118
00126 virtual void setup_seed(EMData* seed,float seed_weight) {throw;}
00127
00136 virtual EMData* preprocess_slice( const EMData* const slice, const Transform& t = Transform() ) { EMData *ret=slice->copy(); ret->set_attr("reconstruct_preproc",(int)1); return ret; }
00137
00146 virtual int insert_slice(const EMData* const slice, const Transform & euler,const float weight=1.0) {throw;}
00147
00161 virtual int determine_slice_agreement(EMData* slice, const Transform &euler, const float weight=1.0, bool sub=true ) { throw; }
00162
00167 virtual EMData *finish(bool doift=true) { throw; }
00168
00171 virtual void clear() {throw; }
00172
00175 void print_params() const
00176 {
00177 std::cout << "Printing reconstructor params" << std::endl;
00178 for ( Dict::const_iterator it = params.begin(); it != params.end(); ++it )
00179 {
00180 std::cout << (it->first) << " " << (it->second).to_str() << std::endl;
00181 }
00182 std::cout << "Done printing reconstructor params" << std::endl;
00183 }
00184
00185
00186 EMObject& operator[]( const string& key ) { return params[key]; }
00187
00188 private:
00189
00190 Reconstructor(const Reconstructor& that);
00191 Reconstructor& operator=(const Reconstructor& );
00192
00193 };
00194
00206 class ReconstructorVolumeData
00207 {
00208 public:
00212 inline ReconstructorVolumeData() : image(0), tmp_data(0), nx(0), ny(0), nz(0), subnx(0), subny(0), subnz(0), subx0(0), suby0(0), subz0(0) {}
00213
00216 virtual ~ReconstructorVolumeData() { free_memory(); }
00217
00220 const EMData* get_emdata() { return image; }
00221 protected:
00222
00224 EMData* image;
00226 EMData* tmp_data;
00227
00228
00229 int nx,nx2;
00230 int ny,ny2;
00231 int nz,nz2;
00232
00233 int subnx;
00234 int subny;
00235 int subnz;
00236
00237 int subx0;
00238 int suby0;
00239 int subz0;
00240
00241 protected:
00247 void free_memory()
00248 {
00249 if (image != 0) {delete image; image = 0;}
00250 if ( tmp_data != 0 ) { delete tmp_data; tmp_data = 0; }
00251 }
00252
00258 virtual void normalize_threed(const bool sqrt_damp=false,const bool wiener=false);
00259
00263 virtual void zero_memory()
00264 {
00265 if (tmp_data != 0 ) tmp_data->to_zero();
00266 if (image != 0 ) image->to_zero();
00267 }
00268
00269 private:
00271 ReconstructorVolumeData(const ReconstructorVolumeData& that);
00273 ReconstructorVolumeData& operator=(const ReconstructorVolumeData& );
00274
00275 };
00276
00282 class FourierReconstructorSimple2D : public Reconstructor, public ReconstructorVolumeData
00283 {
00284 public:
00285 FourierReconstructorSimple2D() {}
00286
00287 virtual ~FourierReconstructorSimple2D() { }
00288
00289 virtual void setup();
00290
00291 virtual int insert_slice(const EMData* const slice, const Transform & euler,const float weight=1.0);
00292
00293 virtual EMData *finish(bool doift=true);
00294
00295 virtual string get_name() const { return NAME; }
00296
00297 virtual string get_desc() const { return "performs 2D reconstruction"; }
00298
00299 static Reconstructor *NEW()
00300 {
00301 return new FourierReconstructorSimple2D();
00302 }
00303
00304
00305 virtual TypeDict get_param_types() const
00306 {
00307 TypeDict d;
00308 d.put("nx", EMObject::INT, "Necessary. The x dimension of the input images.");
00309
00310 return d;
00311 }
00312
00313 static const string NAME;
00314 };
00315
00316
00317
00368 class FourierReconstructor : public Reconstructor, public ReconstructorVolumeData
00369 {
00370 public:
00374 FourierReconstructor() { load_default_settings(); }
00375
00379 virtual ~FourierReconstructor() { free_memory(); }
00380
00384 virtual void setup();
00385
00394 virtual void setup_seed(EMData* seed,float seed_weight);
00395
00404 virtual EMData* preprocess_slice( const EMData* const slice, const Transform& t = Transform() );
00405
00415 virtual int insert_slice(const EMData* const slice, const Transform & euler,const float weight=1.0);
00416
00417
00434 virtual int determine_slice_agreement(EMData* slice, const Transform &euler, const float weight=1.0, bool sub=true );
00435
00442 virtual EMData *finish(bool doift=true);
00443
00446 virtual void clear();
00447
00450 virtual string get_name() const
00451 {
00452 return NAME;
00453 }
00454
00457 virtual string get_desc() const
00458 {
00459 return "Reconstruction via direct Fourier methods using one of a variety of different kernels, most of which are Gaussian based";
00460 }
00461
00465 static Reconstructor *NEW()
00466 {
00467 return new FourierReconstructor();
00468 }
00469
00473 virtual TypeDict get_param_types() const
00474 {
00475 TypeDict d;
00476 d.put("size", EMObject::INTARRAY, "Required. The dimensions of the real-space output volume, including any padding (must be handled by the calling application). Assumed that apix x/y/z identical.");
00477 d.put("sym", EMObject::STRING, "Optional. The symmetry of the reconstructed volume, c?, d?, oct, tet, icos, h?. Default is c1, ie - an asymmetric object");
00478 d.put("mode", EMObject::STRING, "Optional. Fourier pixel insertion mode name (nearest_neighbor, gauss_2, gauss_3, gauss_5, gauss_5_slow, gypergeom_5, experimental) gauss_2 is the default.");
00479 d.put("sqrtnorm", EMObject::BOOL, "Optional. When normalizing, additionally divides by the sqrt of the normalization factor to damp exaggerated features. Is this justifyable ? No idea (yet). Default is false.");
00480 d.put("verbose", EMObject::BOOL, "Optional. Toggles writing useful information to standard out. Default is false.");
00481 d.put("quiet", EMObject::BOOL, "Optional. If false, print verbose information.");
00482 d.put("subvolume",EMObject::INTARRAY, "Optional. (xorigin,yorigin,zorigin,xsize,ysize,zsize) all in Fourier pixels. Useful for parallelism.");
00483 d.put("savenorm",EMObject::STRING, "Debug. Will cause the normalization volume to be written directly to the specified file when finish() is called.");
00484 return d;
00485 }
00486
00487 static const string NAME;
00488
00489 protected:
00492 virtual void load_default_settings();
00493
00497 virtual void free_memory();
00498
00501 virtual void load_inserter();
00502
00508 virtual void do_insert_slice_work(const EMData* const input_slice, const Transform & euler,const float weight);
00509
00514 virtual void do_compare_slice_work(EMData* input_slice, const Transform & euler,float weight);
00515
00520 virtual bool pixel_at(const float& xx, const float& yy, const float& zz, float *dt);
00521
00523 FourierPixelInserter3D* inserter;
00524
00525 private:
00528 FourierReconstructor( const FourierReconstructor& that );
00531 FourierReconstructor& operator=( const FourierReconstructor& );
00532
00533 };
00534
00535
00536
00547 class WienerFourierReconstructor : public FourierReconstructor
00548 {
00549 public:
00553 WienerFourierReconstructor() {};
00554
00558 virtual ~WienerFourierReconstructor() { }
00559
00560
00570 virtual int insert_slice(const EMData* const slice, const Transform & euler,const float weight=1.0);
00571
00572
00589 virtual int determine_slice_agreement(EMData* slice, const Transform &euler, const float weight=1.0, bool sub=true );
00590
00597 virtual EMData *finish(bool doift=true);
00598
00601 virtual string get_name() const
00602 {
00603 return NAME;
00604 }
00605
00608 virtual string get_desc() const
00609 {
00610 return "Reconstruction via direct Fourier methods using one of a variety of different kernels, most of which are Gaussian based. This version also incorporates a nonisotropic Wiener filter based on SNR estimates stored in the class-average headers by the ctf.auto averager.";
00611 }
00612
00616 static Reconstructor *NEW()
00617 {
00618 return new WienerFourierReconstructor();
00619 }
00620
00621 static const string NAME;
00622
00623 protected:
00624
00625 virtual void do_insert_slice_work(const EMData* const input_slice, const Transform & euler,const float weight);
00626
00631 virtual void do_compare_slice_work(EMData* input_slice, const Transform & euler,float weight);
00632
00637 virtual bool pixel_at(const float& xx, const float& yy, const float& zz, float *dt);
00638
00640
00641
00642 private:
00645 WienerFourierReconstructor( const WienerFourierReconstructor& that );
00648 WienerFourierReconstructor& operator=( const WienerFourierReconstructor& );
00649
00650 };
00651
00659 class BackProjectionReconstructor:public Reconstructor, public ReconstructorVolumeData
00660 {
00661 public:
00662 BackProjectionReconstructor() { load_default_settings(); }
00663
00664 virtual ~BackProjectionReconstructor() {}
00665
00666 virtual void setup();
00667
00676 virtual int insert_slice(const EMData* const slice, const Transform & euler,const float weight=1.0);
00677
00678 virtual EMData *finish(bool doift=true);
00679
00680 virtual string get_name() const
00681 {
00682 return NAME;
00683 }
00684
00685 virtual string get_desc() const
00686 {
00687 return "Simple (unfiltered) back-projection reconstruction. Weighting by contributing particles in the class average is optional and default behaviour";
00688 }
00689
00690 static Reconstructor *NEW()
00691 {
00692 return new BackProjectionReconstructor();
00693 }
00694
00695 virtual TypeDict get_param_types() const
00696 {
00697 TypeDict d;
00698 d.put("size", EMObject::INT, "Necessary. The x and y dimensions of the input images.");
00699 d.put("weight", EMObject::FLOAT, "Optional. A temporary value set prior to slice insertion, indicative of the inserted slice's weight. Default sis 1.");
00700 d.put("sym", EMObject::STRING, "Optional. The symmetry to impose on the final reconstruction. Default is c1");
00701 d.put("zsample", EMObject::INT, "Optional. The z dimensions of the reconstructed volume.");
00702 return d;
00703 }
00704
00705 static const string NAME;
00706
00707 private:
00708
00709 BackProjectionReconstructor( const BackProjectionReconstructor& that);
00710
00711 BackProjectionReconstructor& operator=( const BackProjectionReconstructor& );
00712
00713 void load_default_settings()
00714 {
00715 params["weight"] = 1.0;
00716 params["use_weights"] = true;
00717 params["size"] = 0;
00718 params["sym"] = "c1";
00719 params["zsample"] = 0;
00720 }
00721
00722 EMData* preprocess_slice(const EMData* const slice, const Transform& t);
00723 };
00724
00725
00729 EMData* padfft_slice( const EMData* const slice, const Transform& t, int npad );
00730
00731 class nn4Reconstructor:public Reconstructor
00732 {
00733 public:
00734 nn4Reconstructor();
00735
00736 nn4Reconstructor( const string& symmetry, int size, int npad );
00737
00738 virtual ~nn4Reconstructor();
00739
00740 virtual void setup();
00741
00750 virtual int insert_slice(const EMData* const slice, const Transform & euler,const float weight=1.0);
00751
00752 virtual EMData *finish(bool doift=true);
00753
00754 virtual string get_name() const
00755 {
00756 return NAME;
00757 }
00758
00759 virtual string get_desc() const
00760 {
00761 return "Direct Fourier inversion routine";
00762 }
00763
00764 static Reconstructor *NEW()
00765 {
00766 return new nn4Reconstructor();
00767 }
00768
00769 virtual TypeDict get_param_types() const
00770 {
00771 TypeDict d;
00772 d.put("size", EMObject::INT);
00773 d.put("npad", EMObject::INT);
00774 d.put("sign", EMObject::INT);
00775 d.put("ndim", EMObject::INT);
00776 d.put("snr", EMObject::FLOAT);
00777 d.put("symmetry", EMObject::STRING);
00778 d.put("snr", EMObject::FLOAT);
00779 d.put("fftvol", EMObject::EMDATA);
00780 d.put("weight", EMObject::EMDATA);
00781 d.put("weighting", EMObject::INT);
00782 return d;
00783 }
00784
00785 void setup( const string& symmetry, int size, int npad );
00786
00787 int insert_padfft_slice( EMData* padded, const Transform& trans, int mult=1 );
00788
00789 static const string NAME;
00790
00791 private:
00792 EMData* m_volume;
00793 EMData* m_wptr;
00794 string m_symmetry;
00795 int m_weighting;
00796 int m_vnx, m_vny, m_vnz;
00797 int m_npad;
00798 int m_nsym;
00799 int m_ndim;
00800 int m_vnzp, m_vnyp, m_vnxp;
00801 int m_vnzc, m_vnyc, m_vnxc;
00802 void buildFFTVolume();
00803 void buildNormVolume();
00804 float m_wghta;
00805 float m_wghtb;
00806 float m_osnr;
00807 void load_default_settings()
00808 {
00809
00810 }
00811 };
00812
00813
00819 class nn4_rectReconstructor:public Reconstructor
00820 {
00821 public:
00822 nn4_rectReconstructor();
00823
00824 nn4_rectReconstructor( const string& symmetry, int size, int npad );
00825
00826 virtual ~nn4_rectReconstructor();
00827
00828 virtual void setup();
00829
00838 virtual int insert_slice(const EMData* const slice, const Transform & euler,const float weight=1.0);
00839
00840 virtual EMData *finish(bool doift=true);
00841
00842 virtual string get_name() const
00843 {
00844 return NAME;
00845 }
00846
00847 virtual string get_desc() const
00848 {
00849 return "Direct Fourier inversion routine";
00850 }
00851
00852 static Reconstructor *NEW()
00853 {
00854 return new nn4_rectReconstructor();
00855 }
00856
00857 virtual TypeDict get_param_types() const
00858 {
00859 TypeDict d;
00860 d.put("sizeprojection", EMObject::INT);
00861 d.put("sizex", EMObject::INT);
00862 d.put("sizey", EMObject::INT);
00863 d.put("sizez", EMObject::INT);
00864 d.put("xratio", EMObject::FLOAT);
00865 d.put("yratio", EMObject::FLOAT);
00866 d.put("npad", EMObject::INT);
00867 d.put("sign", EMObject::INT);
00868 d.put("ndim", EMObject::INT);
00869 d.put("snr", EMObject::FLOAT);
00870 d.put("symmetry", EMObject::STRING);
00871 d.put("snr", EMObject::FLOAT);
00872 d.put("fftvol", EMObject::EMDATA);
00873 d.put("weight", EMObject::EMDATA);
00874 d.put("weighting", EMObject::INT);
00875 return d;
00876 }
00877
00878 void setup( const string& symmetry, int size, int npad );
00879
00880 int insert_padfft_slice( EMData* padded, const Transform& trans, int mult=1 );
00881
00882 static const string NAME;
00883
00884 private:
00885 EMData* m_volume;
00886 EMData* m_wptr;
00887 string m_symmetry;
00888 int m_weighting;
00889 int m_vnx, m_vny, m_vnz;
00890 int m_npad;
00891 int m_nsym;
00892 int m_ndim;
00893 int m_vnzp, m_vnyp, m_vnxp;
00894 int m_vnzc, m_vnyc, m_vnxc;
00895 int m_count;
00896 float m_xratio,m_yratio,m_zratio;
00897 float m_xscale,m_yscale;
00898 int m_sizeofprojection;
00899 void buildFFTVolume();
00900 void buildNormVolume();
00901 float m_wghta;
00902 float m_wghtb;
00903 float m_osnr;
00904 void load_default_settings()
00905 {
00906
00907 }
00908 };
00909
00910
00911
00912
00913
00914
00915 class nnSSNR_Reconstructor:public Reconstructor
00916 {
00917
00918 public:
00919 nnSSNR_Reconstructor();
00920
00921 nnSSNR_Reconstructor( const string& symmetry, int size, int npad);
00922
00923 ~nnSSNR_Reconstructor();
00924
00925 virtual void setup();
00926
00935 virtual int insert_slice(const EMData* const slice, const Transform & euler,const float weight=1.0);
00936
00937 virtual EMData *finish(bool doift=true);
00938
00939 virtual string get_name() const
00940 {
00941 return NAME;
00942 }
00943
00944 virtual string get_desc() const
00945 {
00946 return "Reconstruction by nearest neighbor with 3D SSNR";
00947 }
00948
00949 static Reconstructor *NEW()
00950 {
00951 return new nnSSNR_Reconstructor();
00952 }
00953
00954 virtual TypeDict get_param_types() const
00955 {
00956 TypeDict d;
00957 d.put("size", EMObject::INT);
00958 d.put("npad", EMObject::INT);
00959 d.put("symmetry", EMObject::STRING);
00960 d.put("fftvol", EMObject::EMDATA);
00961 d.put("weight", EMObject::EMDATA);
00962 d.put("weight2", EMObject::EMDATA);
00963 d.put("SSNR", EMObject::EMDATA);
00964 d.put("vol_ssnr", EMObject::EMDATA);
00965 d.put("w", EMObject::FLOAT);
00966 return d;
00967 }
00968
00969 void setup( const string& symmetry, int size, int npad);
00970
00971 int insert_padfft_slice( EMData* padded, const Transform& trans, int mult=1 );
00972
00973 static const string NAME;
00974
00975 private:
00976 EMData* m_volume;
00977 EMData* m_wptr;
00978 EMData* m_wptr2;
00979 string m_symmetry;
00980 int m_weighting;
00981 int m_vnx, m_vny, m_vnz;
00982 int m_npad;
00983 int m_nsym;
00984 int m_vnzp, m_vnyp, m_vnxp;
00985 int m_vnzc, m_vnyc, m_vnxc;
00986 void buildFFTVolume();
00987 void buildNormVolume();
00988 void buildNorm2Volume();
00989 float m_wghta;
00990 float m_wghtb;
00991 };
00992
00993
00997 class nn4_ctfReconstructor:public Reconstructor
00998 {
00999 public:
01000 nn4_ctfReconstructor();
01001
01002 nn4_ctfReconstructor( const string& symmetry, int size, int npad, float snr, int sign );
01003
01004 virtual ~nn4_ctfReconstructor();
01005
01006 virtual void setup();
01007
01017 virtual int insert_slice(const EMData* const slice, const Transform & euler,const float weight=1.0);
01018
01019 virtual EMData *finish(bool doift=true);
01020
01021 virtual string get_name() const
01022 {
01023 return NAME;
01024 }
01025
01026 virtual string get_desc() const
01027 {
01028 return "Direct Fourier inversion reconstruction routine";
01029 }
01030
01031 static Reconstructor *NEW()
01032 {
01033 return new nn4_ctfReconstructor();
01034 }
01035
01036
01037 TypeDict get_param_types() const
01038 {
01039 TypeDict d;
01040 d.put("size", EMObject::INT);
01041 d.put("npad", EMObject::INT);
01042 d.put("sign", EMObject::INT);
01043 d.put("symmetry", EMObject::STRING);
01044 d.put("snr", EMObject::FLOAT);
01045 d.put("fftvol", EMObject::EMDATA);
01046 d.put("weight", EMObject::EMDATA);
01047 d.put("weighting", EMObject::INT);
01048 d.put("varsnr", EMObject::INT);
01049 return d;
01050 }
01051
01052 void setup( const string& symmetry, int size, int npad, float snr, int sign );
01053
01054 int insert_padfft_slice( EMData* padfft, const Transform& trans, int mult=1);
01055
01056 int insert_buffed_slice( const EMData* buffer, int mult );
01057
01058 static const string NAME;
01059
01060 private:
01061 EMData* m_volume;
01062 EMData* m_wptr;
01063 int m_vnx, m_vny, m_vnz;
01064 int m_vnzp, m_vnyp, m_vnxp;
01065 int m_vnxc, m_vnyc, m_vnzc;
01066 int m_npad;
01067 int m_sign;
01068 int m_varsnr;
01069 int m_weighting;
01070 float m_wghta, m_wghtb;
01071 float m_snr;
01072 string m_symmetry;
01073 int m_nsym;
01074
01075 void buildFFTVolume();
01076 void buildNormVolume();
01077
01078 };
01079
01080
01084 class nn4_ctf_rectReconstructor:public Reconstructor
01085 {
01086 public:
01087 nn4_ctf_rectReconstructor();
01088
01089 nn4_ctf_rectReconstructor( const string& symmetry, int size, int npad, float snr, int sign );
01090
01091 virtual ~nn4_ctf_rectReconstructor();
01092
01093 virtual void setup();
01094
01104 virtual int insert_slice(const EMData* const slice, const Transform & euler, const float weight=1.0);
01105
01106 virtual EMData *finish(bool doift=true);
01107
01108 virtual string get_name() const
01109 {
01110 return NAME;
01111 }
01112
01113 virtual string get_desc() const
01114 {
01115 return "Direct Fourier inversion reconstruction routine";
01116 }
01117
01118 static Reconstructor *NEW()
01119 {
01120 return new nn4_ctf_rectReconstructor();
01121 }
01122
01123
01124 TypeDict get_param_types() const
01125 {
01126 TypeDict d;
01127 d.put("sizeprojection", EMObject::INT);
01128 d.put("sizex", EMObject::INT);
01129 d.put("sizey", EMObject::INT);
01130 d.put("sizez", EMObject::INT);
01131 d.put("xratio", EMObject::FLOAT);
01132 d.put("yratio", EMObject::FLOAT);
01133 d.put("size", EMObject::INT);
01134 d.put("npad", EMObject::INT);
01135 d.put("sign", EMObject::INT);
01136 d.put("symmetry", EMObject::STRING);
01137 d.put("snr", EMObject::FLOAT);
01138 d.put("fftvol", EMObject::EMDATA);
01139 d.put("weight", EMObject::EMDATA);
01140 d.put("weighting", EMObject::INT);
01141 d.put("varsnr", EMObject::INT);
01142 return d;
01143 }
01144
01145 void setup( const string& symmetry, int size, int npad, float snr, int sign );
01146
01147 int insert_padfft_slice( EMData* padfft, const Transform& trans, int mult=1);
01148
01149 int insert_buffed_slice( const EMData* buffer, int mult );
01150
01151 static const string NAME;
01152
01153 private:
01154 EMData* m_volume;
01155 EMData* m_wptr;
01156 int m_vnx, m_vny, m_vnz;
01157 int m_vnzp, m_vnyp, m_vnxp;
01158 int m_vnxc, m_vnyc, m_vnzc;
01159 int m_count;
01160 float m_xratio, m_yratio, m_zratio;
01161 float m_xscale, m_yscale;
01162 int m_sizeofprojection;
01163 int m_npad;
01164 int m_sign;
01165 int m_varsnr;
01166 int m_weighting;
01167 float m_wghta, m_wghtb;
01168 float m_snr;
01169 string m_symmetry;
01170 int m_nsym;
01171
01172 void buildFFTVolume();
01173 void buildNormVolume();
01174 };
01175
01176
01177
01178
01179
01180
01181
01182 class nnSSNR_ctfReconstructor:public Reconstructor
01183 {
01184
01185 public:
01186 nnSSNR_ctfReconstructor();
01187
01188 nnSSNR_ctfReconstructor( const string& symmetry, int size, int npad, float snr, int sign);
01189
01190 ~nnSSNR_ctfReconstructor();
01191
01192 virtual void setup();
01193
01203 virtual int insert_slice(const EMData* const slice, const Transform & euler,const float weight=1.0);
01204
01205
01206 virtual EMData *finish(bool doift=true);
01207
01208 virtual string get_name() const
01209 {
01210 return NAME;
01211 }
01212
01213 virtual string get_desc() const
01214 {
01215 return "Reconstruction by nearest neighbor with 3D SSNR with CTF";
01216 }
01217
01218 static Reconstructor *NEW()
01219 {
01220 return new nnSSNR_ctfReconstructor();
01221 }
01222
01223 TypeDict get_param_types() const
01224 {
01225 TypeDict d;
01226 d.put("size", EMObject::INT);
01227 d.put("npad", EMObject::INT);
01228 d.put("symmetry", EMObject::STRING);
01229 d.put("fftvol", EMObject::EMDATA);
01230 d.put("fftwvol", EMObject::EMDATA);
01231 d.put("weight", EMObject::EMDATA);
01232 d.put("weight2", EMObject::EMDATA);
01233 d.put("weight3", EMObject::EMDATA);
01234 d.put("SSNR", EMObject::EMDATA);
01235 d.put("vol_ssnr", EMObject::EMDATA);
01236 d.put("w", EMObject::FLOAT);
01237 d.put("sign", EMObject::INT);
01238 d.put("snr", EMObject::FLOAT);
01239 return d;
01240 }
01241 void setup( const string& symmetry, int size, int npad, float snr, int sign);
01242
01243 int insert_padfft_slice( EMData* padded, const Transform& trans, int mult=1 );
01244
01245 static const string NAME;
01246
01247 private:
01248 EMData* m_volume;
01249 EMData* m_wptr;
01250 EMData* m_wptr2;
01251 EMData* m_wptr3;
01252 string m_symmetry;
01253 int m_weighting;
01254 int m_vnx, m_vny, m_vnz;
01255 int m_npad;
01256 int m_nsym;
01257 int m_vnzp, m_vnyp, m_vnxp;
01258 int m_vnzc, m_vnyc, m_vnxc;
01259 void buildFFTVolume();
01260 void buildNormVolume();
01261 void buildNorm2Volume();
01262 void buildNorm3Volume();
01263 float m_wghta;
01264 float m_wghtb;
01265 int m_sign;
01266 float m_snr;
01267 int wiener;
01268 };
01269
01270 template <> Factory < Reconstructor >::Factory();
01271
01272 void dump_reconstructors();
01273 map<string, vector<string> > dump_reconstructors_list();
01274
01275
01276 struct point_t
01277 {
01278 int pos2;
01279 float real;
01280 float imag;
01281 float ctf2;
01282 };
01283
01284
01285 class newfile_store
01286 {
01287 public:
01288 newfile_store( const string& prefix, int npad, bool ctf );
01289
01290 virtual ~newfile_store();
01291
01292 void add_image( EMData* data, const Transform& tf );
01293
01294 void add_tovol( EMData* fftvol, EMData* wgtvol, const vector<int>& mults, int pbegin, int pend );
01295
01296 void get_image( int id, EMData* buf );
01297
01298 void read( int nprj );
01299
01300 void restart( );
01301
01302 private:
01303 int m_npad;
01304
01305 bool m_ctf;
01306
01307 string m_bin_file;
01308 string m_txt_file;
01309
01310 shared_ptr<std::ofstream> m_bin_of;
01311 shared_ptr<std::ofstream> m_txt_of;
01312 shared_ptr<std::ifstream> m_bin_if;
01313 vector< std::istream::off_type > m_offsets;
01314
01315 vector< point_t > m_points;
01316 };
01317
01318 class file_store
01319 {
01320 public:
01321 file_store(const string& filename, int npad, int write, bool CTF);
01322
01323 virtual ~file_store();
01324
01325 void add_image(EMData* data, const Transform& tf);
01326
01327 void get_image(int id, EMData* padfft);
01328
01329 void restart();
01330 private:
01331 shared_ptr<std::ifstream> m_ihandle;
01332 shared_ptr<std::ofstream> m_bin_ohandle;
01333 shared_ptr<std::ofstream> m_txt_ohandle;
01334 string m_bin_file;
01335 string m_txt_file;
01336 int m_ctf;
01337 int m_npad;
01338 int m_prev;
01339 int m_x_out;
01340 int m_y_out;
01341 int m_z_out;
01342 int m_write;
01343 std::istream::off_type m_totsize;
01344 float m_Cs;
01345 float m_pixel;
01346 float m_voltage;
01347 float m_ctf_applied;
01348 float m_amp_contrast;
01349 vector< float > m_defocuses;
01350 vector< float > m_phis;
01351 vector< float > m_thetas;
01352 vector< float > m_psis;
01353 };
01354
01355 }
01356
01357 #endif
01358
01359