EMAN2
emdata_sparx.h
Go to the documentation of this file.
00001 
00005 /*
00006  * Author: Pawel A.Penczek, 09/09/2006 (Pawel.A.Penczek@uth.tmc.edu)
00007  * Copyright (c) 2000-2006 The University of Texas - Houston Medical School
00008  *
00009  * This software is issued under a joint BSD/GNU license. You may use the
00010  * source code in this file under either license. However, note that the
00011  * complete EMAN2 and SPARX software packages have some GPL dependencies,
00012  * so you are responsible for compliance with the licenses of these packages
00013  * if you opt to use BSD licensing. The warranty disclaimer below holds
00014  * in either instance.
00015  *
00016  * This complete copyright notice must be included in any revised version of the
00017  * source code. Additional authorship citations may be added, but existing
00018  * author citations must be preserved.
00019  *
00020  * This program is free software; you can redistribute it and/or modify
00021  * it under the terms of the GNU General Public License as published by
00022  * the Free Software Foundation; either version 2 of the License, or
00023  * (at your option) any later version.
00024  *
00025  * This program is distributed in the hope that it will be useful,
00026  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00027  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00028  * GNU General Public License for more details.
00029  *
00030  * You should have received a copy of the GNU General Public License
00031  * along with this program; if not, write to the Free Software
00032  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00033  *
00034  */
00035 
00036 #ifndef emdata__sparx_h__
00037 #define emdata__sparx_h__
00038 
00039 public:
00047 EMData *real2FH(float OverSamplekB);
00051 EMData *copy_empty_head() const; 
00060 EMData *FH2F(int Size, float OverSamplekB, int IntensityFlag =0);
00061 
00070 EMData *FH2Real(int Size, float OverSamplekB, int IntensityFlag =0);
00071 
00072 
00077 EMData* rotavg();
00078 
00083 EMData* rotavg_i();
00084 
00090 EMData* mult_radial(EMData* radial);
00091 
00097 vector<float> cog();
00098 
00099 
00118 vector <float> calc_fourier_shell_correlation(EMData * with, float w = 1.0f);
00119 
00127 vector <float> scale_factors(EMData * with, int beg, int end);
00128 
00133 EMData* average_circ_sub() const;
00134 
00135 
00145 void onelinenn(int j, int n, int n2, EMData* wptr, EMData* bi, const Transform& tf);
00146 
00147 void onelinenn_mult(int j, int n, int n2, EMData* wptr, EMData* bi, const Transform& tf, float mult);
00148 
00157 void nn(EMData* wptr, EMData* myfft, const Transform& tf, float mult=1);
00158 void insert_rect_slice( EMData* w, EMData* myfft,const Transform& trans, int sizeofprojection, float xratio, float yratio, float zratio, int npad, float mult);
00159 
00170 void nn_SSNR(EMData* wptr, EMData* wptr2, EMData* myfft, const Transform& tf, float mult=1);
00171 
00183 /*      void nn_SSNR_ctf(EMData* wptr, EMData* wptr2, EMData* wptr3, EMData* wptr4, EMData* wptr5, EMData* myfft, EMData* m_wvolume, const Transform3D& tf, float mult=1); */
00184 void nn_SSNR_ctf(EMData* wptr, EMData* wptr2, EMData* wptr3, EMData* myfft, const Transform& tf, float mult=1);
00185 
00191 /*               void nn_wiener(EMData* wptr, EMData* wptr3, EMData* myfft, const Transform3D& tf, int mult); */
00198 void symplane0(EMData* norm);
00199 
00206 void symplane1(EMData* norm, EMData* norm2);
00207 
00215 void symplane2(EMData* norm, EMData* norm2, EMData* norm3);
00216 
00227 void onelinenn_ctf(int j, int n, int n2, EMData* w, EMData* bi, const Transform& tf, float mult);
00228 
00239 void onelinenn_ctfw(int j, int n, int n2, EMData* w, EMData* bi, EMData* sigmasq2, const Transform& tf, float weight);
00240 
00241 
00250 void nn_ctf(EMData* w, EMData* myfft, const Transform& tf, float mult);
00254 void insert_rect_slice_ctf( EMData* w, EMData* myfft,const Transform& trans, int sizeofprojection, float xratio, float yratio, float zratio, int npad, float mult);
00255 void insert_rect_slice_ctf_applied(EMData* w, EMData* myfft, const Transform& trans, int sizeofprojection, float xratio, float yratio, float zratio, int npad,float mult);
00256 
00257 
00269 void onelinenn_ctf_applied(int j, int n, int n2, EMData* w, EMData* bi, const Transform& tf, float mult);
00270 
00280 void nn_ctf_applied(EMData* w, EMData* myfft, const Transform& tf, float mult );
00281 
00287 void symplane0_ctf(EMData* w);
00288 void symplane0_rect(EMData* w);
00289 
00290 
00291 
00302 void nn_ctfw(EMData* w, EMData* myfft, EMData* sigmasq2, const Transform& tf, float weight);
00303 
00304 
00311 EMData* symvol(string symmetry);
00312 
00313 
00327 EMData* rot_scale_trans2D(float ang, float delx = 0.0f, float dely = 0.0f, float scale = 1.0f);
00328 
00345 EMData* rot_scale_trans2D_background(float ang, float delx = 0.0f, float dely = 0.0f, float scale = 1.0f);
00346 
00356 EMData* rot_scale_trans(const Transform &RA);
00357 
00370 EMData* rot_scale_trans_background(const Transform &RA);
00371 
00372 /*
00373                 To restrict the value to [0, nx)
00374 */
00375 static inline float restrict1(float x, int nx) {
00376         while ( x < 0.0f )          x += nx;
00377         while ( x >= (float)(nx) )  x -= nx;
00378         return x;
00379 }
00380 
00381 /*
00382                 To restrict the value to (-nx, nx)
00383 */
00384 static inline float restrict2(float x, int nx) {
00385         while ( x >=  (float)(nx) )  x -= nx;
00386         while ( x <= -(float)(nx) )  x += nx;
00387         return x;
00388 }
00389 
00390 
00391 
00397 //float cm_euc(EMData* sinoj, int n1, int n2, float alpha1, float alpha2);
00398 float cm_euc(EMData* sinoj, int n1, int n2);
00399 
00414 EMData* rot_scale_conv(float ang, float delx, float dely, Util::KaiserBessel& kb, float scale = 1.0);
00415 
00416 EMData* downsample(Util::sincBlackman& kb, float scale = 1.0);
00417 
00418 EMData* rot_scale_conv7(float ang, float delx, float dely, Util::KaiserBessel& kb, float scale_input);
00419 
00420 EMData* rot_scale_conv_new(float ang, float delx, float dely, Util::KaiserBessel& kb, float scale = 1.0);
00421 
00422 EMData* rot_scale_conv_new_background(float ang, float delx, float dely, Util::KaiserBessel& kb, float scale = 1.0);
00423 
00424 EMData* rot_scale_conv_new_3D(float phi, float theta, float psi, float delx, float dely, float delz, Util::KaiserBessel& kb, float scale = 1.0, bool wrap = false);
00425 
00426 EMData* rot_scale_conv_new_background_3D(float phi, float theta, float psi, float delx, float dely, float delz, Util::KaiserBessel& kb, float scale = 1.0, bool wrap = false);
00427 
00440 float  get_pixel_conv(float delx, float dely, float delz, Util::KaiserBessel& kb);
00441 float  get_pixel_filtered(float delx, float dely, float delz, Util::sincBlackman& kb);
00442 
00443 float  get_pixel_conv7(float delx, float dely, float delz, Util::KaiserBessel& kb);
00444 
00445 
00458 /*template<class Win>
00459 float getconvpt2d(float x, float y, Win win, int size = 7);*/
00460 float getconvpt2d_kbi0(float x, float y, Util::KaiserBessel::kbi0_win win, int size = 7);
00461 
00462 
00478 #if 0 // broken
00479         //template<class Win>
00480         //EMData* rotconvtrunc2d(float ang, Win win, int size = 7);
00481         //EMData* rotconvtrunc2d_kbi0(float ang, float alpha, int size) {
00482         //      Util::KaiserBessel kb(alpha, size-1);
00483         //      return rotconvtrunc2d(ang, kb.get_kbi0_win(), size);
00484         //}
00485         EMData* rotconvtrunc2d_kbi0(float ang, float alpha, int size);
00486 
00487 
00500         //template<class Win>
00501         //EMData* rotconvtrunc2d(float ang, Win win, int size = 7);
00502         //EMData* rotconvtrunc2d_kbi0(float ang, float alpha, int size) {
00503         //      Util::KaiserBessel kb(alpha, size-1);
00504         //      return rotconvtrunc2d(ang, kb.get_kbi0_win(), size);
00505         //}
00506         EMData* gridrot2d_kbi0(float ang, float alpha = 1., int size = 7) {
00507                 EMData* rot = rotconvtrunc2d_kbi0(ang, alpha, size);
00508                 Dict params;
00509                 params["dopad"] = 1;
00510                 params["alpha"] = alpha;
00511                 rot->process_inplace("filter.kaisersinhinverse", params);
00512                 return rot;
00513         }
00514 #endif // 0
00515 
00516 
00527 void fft_shuffle();
00528 
00529 void pad_corner(float *pad_image);
00530 
00531 void shuffle_pad_corner(float *pad_image);
00532 
00547 std::complex<float> extractpoint(float xin, float yin, Util::KaiserBessel& kb);
00548 
00549 
00564 EMData* extract_plane(const Transform& tf, Util::KaiserBessel& kb);
00565 EMData* extract_plane_rect(const Transform& tf, Util::KaiserBessel& kbx, Util::KaiserBessel& kby, Util::KaiserBessel& kbz);
00566 EMData* extract_plane_rect_fast(const Transform& tf, Util::KaiserBessel& kbx, Util::KaiserBessel& kby, Util::KaiserBessel& kbz);
00567 
00568 EMData* fouriergridrot2d(float ang, float scale, Util::KaiserBessel& kb);
00569 
00570 EMData* fouriergridrot_shift2d(float ang, float sx, float sy, Util::KaiserBessel& kb);
00571 
00572 
00582 void divkbsinh(const Util::KaiserBessel& kb);
00583 void divkbsinh_rect(const Util::KaiserBessel& kbx, const Util::KaiserBessel& kby, const Util::KaiserBessel& kbz);
00584 
00585 
00597 //  OBSOLETED  Dict masked_stats(const EMData* mask);
00598 
00599 
00614 vector<float> peak_search(int ml, float invert);
00615 
00620 vector<float> phase_cog();
00621 
00622 float find_3d_threshold(float mass, float pixel_size);
00623 
00624 
00628 vector<float> peak_ccf(float hf_p);
00629 
00630 /* pixel power operation function */
00631 EMData* get_pow(float n_pow);
00632 
00633 /* pixel conjugate operation function */
00634 EMData* conjg();
00635 
00636 private:
00637 //utility function for peak_search()
00638 static bool peakcmp(const Pixel& p1, const Pixel& p2);
00639 public:
00640 EMData* extractline(Util::KaiserBessel& kb,float nuxnew,float nuynew);
00641 
00652 EMData* delete_disconnected_regions(int ix=0, int iy=0, int iz=0);
00653 
00665 EMData* helicise(float pixel_size, float dp, float dphi, float section_use = 1.0f, float radius = -1.0f, float minrad = -1.0f);
00666 EMData* helicise_grid(float pixel_size, float dp, float dphi, Util::KaiserBessel& kb, float section_use = 1.0f, float radius = -1.0f, float minrad = -1.0f);
00667 
00677 void depad();
00678 
00688 void depad_corner();
00689 
00704 EMData* norm_pad(bool do_norm, int npad = 1, int valtype=0);
00705 
00706 void center_origin();
00707 
00708 void center_origin_yz();
00709 
00713 void center_origin_fft();
00714 
00715 
00716 EMData* FourInterpol(int nxni, int nyni=0, int nzni=0, bool RetReal = true);
00717 
00727 EMData* FourTruncate(int nxni, int nyni=0, int nzni=0, bool RetReal = true);
00728 //EMData* FourInterpol_i(int nxni, int nyni=0, int nzni=0, bool RetReal = true);
00729 EMData* Four_ds(int nxni, int nyni=0, int nzni=0, bool RetReal = true);
00730 EMData* Four_shuf_ds_cen_us(int nxni, int nyni=0, int nzni=0, bool RetReal = true);
00731 
00732 
00733 EMData* filter_by_image(EMData* image, bool RetReal = true);
00734 
00735 EMData* replace_amplitudes(EMData* image, bool RetReal = true);
00736 
00737 #endif  //emdata__sparx_h__