#include <reconstructor.h>
Inheritance diagram for EMAN::nnSSNR_ctfReconstructor:
Public Member Functions | |
nnSSNR_ctfReconstructor () | |
nnSSNR_ctfReconstructor (const string &symmetry, int size, int npad, float snr, int sign) | |
~nnSSNR_ctfReconstructor () | |
virtual void | setup () |
Initialize the reconstructor. | |
virtual int | insert_slice (const EMData *const slice, const Transform &euler, const float weight=1.0) |
Insert a slice into a 3D volume, in a given orientation. | |
virtual EMData * | finish (bool doift=true) |
Finish reconstruction and return the complete model. | |
virtual string | get_name () const |
Get the unique name of this class (especially for factory based instantiation access). | |
virtual string | get_desc () const |
Get a clear, concise description of this class. | |
TypeDict | get_param_types () const |
void | setup (const string &symmetry, int size, int npad, float snr, int sign) |
int | insert_padfft_slice (EMData *padded, const Transform &trans, int mult=1) |
Static Public Member Functions | |
Reconstructor * | NEW () |
Static Public Attributes | |
const string | NAME = "nnSSNR_ctf" |
Private Member Functions | |
void | buildFFTVolume () |
void | buildNormVolume () |
void | buildNorm2Volume () |
void | buildNorm3Volume () |
Private Attributes | |
EMData * | m_volume |
EMData * | m_wptr |
EMData * | m_wptr2 |
EMData * | m_wptr3 |
string | m_symmetry |
int | m_weighting |
int | m_vnx |
int | m_vny |
int | m_vnz |
int | m_npad |
int | m_nsym |
int | m_vnzp |
int | m_vnyp |
int | m_vnxp |
int | m_vnzc |
int | m_vnyc |
int | m_vnxc |
float | m_wghta |
float | m_wghtb |
int | m_sign |
float | m_snr |
int | wiener |
|
Definition at line 3752 of file reconstructor.cpp. References m_volume, m_wptr, m_wptr2, and m_wptr3. 03753 { 03754 m_volume = NULL; 03755 m_wptr = NULL; 03756 m_wptr2 = NULL; 03757 m_wptr3 = NULL; 03758 }
|
|
Definition at line 3760 of file reconstructor.cpp. References m_volume, m_wptr, m_wptr2, m_wptr3, setup(), and sign. 03761 { 03762 m_volume = NULL; 03763 m_wptr = NULL; 03764 m_wptr2 = NULL; 03765 m_wptr3 = NULL; 03766 03767 setup( symmetry, size, npad, snr, sign ); 03768 }
|
|
Definition at line 3770 of file reconstructor.cpp. 03771 { 03772 03773 //if( m_delete_volume ) checked_delete(m_volume); 03774 //if( m_delete_weight ) checked_delete( m_wptr ); 03775 //if( m_delete_weight2 ) checked_delete( m_wptr2 ); 03776 //if( m_delete_weight3 ) checked_delete( m_wptr3 ); 03777 //checked_delete( m_result ); 03778 }
|
|
Definition at line 3825 of file reconstructor.cpp. References m_npad, m_vnxc, m_vnxp, m_vnyp, m_vnzp, m_volume, EMAN::EMData::set_array_offsets(), EMAN::EMData::set_attr(), EMAN::EMData::set_complex(), EMAN::EMData::set_fftodd(), EMAN::EMData::set_fftpad(), EMAN::EMData::set_nxc(), EMAN::EMData::set_ri(), EMAN::EMData::set_size(), and EMAN::EMData::to_zero(). Referenced by setup(). 03825 { 03826 03827 int offset = 2 - m_vnxp%2; 03828 m_volume = params["fftvol"]; 03829 03830 m_volume->set_size(m_vnxp+offset,m_vnyp,m_vnzp); 03831 m_volume->to_zero(); 03832 03833 m_volume->set_fftodd(m_vnxp % 2); 03834 03835 m_volume->set_nxc(m_vnxc); 03836 m_volume->set_complex(true); 03837 m_volume->set_ri(true); //(real, imaginary) instead of polar coordinate 03838 m_volume->set_fftpad(true); 03839 m_volume->set_attr("npad", m_npad); 03840 m_volume->set_array_offsets(0,1,1); 03841 }
|
|
Definition at line 3852 of file reconstructor.cpp. References m_vnxc, m_vnyp, m_vnzp, m_wptr2, EMAN::EMData::set_array_offsets(), EMAN::EMData::set_size(), and EMAN::EMData::to_zero(). Referenced by setup(). 03852 { 03853 03854 m_wptr2 = params["weight2"]; 03855 m_wptr2->set_size(m_vnxc+1,m_vnyp,m_vnzp); 03856 m_wptr2->to_zero(); 03857 m_wptr2->set_array_offsets(0,1,1); 03858 }
|
|
Definition at line 3860 of file reconstructor.cpp. References m_vnxc, m_vnyp, m_vnzp, m_wptr3, EMAN::EMData::set_array_offsets(), EMAN::EMData::set_size(), and EMAN::EMData::to_zero(). Referenced by setup(). 03860 { 03861 03862 m_wptr3 = params["weight3"]; 03863 m_wptr3->set_size(m_vnxc+1,m_vnyp,m_vnzp); 03864 m_wptr3->to_zero(); 03865 m_wptr3->set_array_offsets(0,1,1); 03866 }
|
|
Definition at line 3844 of file reconstructor.cpp. References m_vnxc, m_vnyp, m_vnzp, m_wptr, EMAN::EMData::set_array_offsets(), EMAN::EMData::set_size(), and EMAN::EMData::to_zero(). Referenced by setup(). 03845 { 03846 m_wptr = params["weight"]; 03847 m_wptr->set_size(m_vnxc+1,m_vnyp,m_vnzp); 03848 m_wptr->to_zero(); 03849 m_wptr->set_array_offsets(0,1,1); 03850 }
|
|
Finish reconstruction and return the complete model.
Reimplemented from EMAN::Reconstructor. Definition at line 3907 of file reconstructor.cpp. References abs, EMAN::EMData::cmplx(), m_vnxc, m_vnxp, m_vnyc, m_vnyp, m_vnzc, m_vnzp, m_volume, m_weighting, m_wghta, m_wptr, m_wptr2, m_wptr3, max, max3d(), nn(), norm(), EMAN::Util::round(), EMAN::EMData::set_complex(), EMAN::EMData::set_fftodd(), EMAN::EMData::set_fftpad(), EMAN::EMData::set_nxc(), EMAN::EMData::set_ri(), EMAN::EMData::set_size(), sqrt(), EMAN::EMData::symplane2(), EMAN::EMData::to_zero(), and EMAN::EMData::update(). 03908 { 03909 /* 03910 I changed the code on 05/15/2008 so it only returns variance. 03911 Lines commented out are marked by //# 03912 The version prior to the currect changes is r1.190 03913 PAP 03914 */ 03915 /*** 03916 m_volume ctf*(P^2D->3D(F^3D)) 03917 m_wptr ctf^2 03918 m_wptr2 |P^2D->3D(F^3D)|^2 03919 m_wptr3 Kn 03920 nominator = sum_rot [ wght*signal ] 03921 denominator = sum_rot[ wght*variance ] 03922 ***/ 03923 int kz, ky; 03924 int box = 7; 03925 int kc = (box-1)/2; 03926 float alpha = 0.0; 03927 float argx, argy, argz; 03928 vector< float > pow_a( 3*kc+1, 1.0 ); 03929 float w = params["w"]; 03930 float dx2 = 1.0f/float(m_vnxc)/float(m_vnxc); 03931 float dy2 = 1.0f/float(m_vnyc)/float(m_vnyc); 03932 #ifdef _WIN32 03933 float dz2 = 1.0f/_cpp_max(float(m_vnzc),1.0f)/_cpp_max(float(m_vnzc),1.0f); 03934 int inc = Util::round(float(_cpp_max(_cpp_max(m_vnxc,m_vnyc),m_vnzc))/w); 03935 #else 03936 float dz2 = 1.0f/std::max(float(m_vnzc),1.0f)/std::max(float(m_vnzc),1.0f); 03937 int inc = Util::round(float(std::max(std::max(m_vnxc,m_vnyc),m_vnzc))/w); 03938 #endif //_WIN32 03939 03940 EMData* SSNR = params["SSNR"]; 03941 SSNR->set_size(inc+1,4,1); 03942 //#EMData* vol_ssnr = new EMData(); 03943 //#vol_ssnr->set_size(m_vnxp, m_vnyp, m_vnzp); 03944 //#vol_ssnr->to_zero(); 03945 //# new linea follow 03946 EMData* vol_ssnr = params["vol_ssnr"]; 03947 vol_ssnr->set_size(m_vnxp+ 2 - m_vnxp%2, m_vnyp ,m_vnzp); 03948 vol_ssnr->to_zero(); 03949 if ( m_vnxp % 2 == 0 ) vol_ssnr->set_fftodd(0); 03950 else vol_ssnr->set_fftodd(1); 03951 vol_ssnr->set_nxc(m_vnxc); 03952 vol_ssnr->set_complex(true); 03953 vol_ssnr->set_ri(true); 03954 vol_ssnr->set_fftpad(false); 03955 //# 03956 float *nom = new float[inc+1]; 03957 float *denom = new float[inc+1]; 03958 int *ka = new int[inc+1]; 03959 int *nn = new int[inc+1]; 03960 float wght = 1.f; 03961 for (int i = 0; i <= inc; i++) { 03962 nom[i] = 0.0f; 03963 denom[i] = 0.0f; 03964 nn[i] = 0; 03965 ka[i] = 0; 03966 } 03967 m_volume->symplane2(m_wptr, m_wptr2, m_wptr3); 03968 if ( m_weighting == ESTIMATE ) { 03969 int vol = box*box*box; 03970 for( unsigned int i=1; i < pow_a.size(); ++i ) pow_a[i] = pow_a[i-1] * exp(m_wghta); 03971 pow_a[3*kc] = 0.0; 03972 float max = max3d( kc, pow_a ); 03973 alpha = ( 1.0f - 1.0f/(float)vol ) / max; 03974 } 03975 for (int iz = 1; iz <= m_vnzp; iz++) { 03976 if ( iz-1 > m_vnzc ) kz = iz-1-m_vnzp; else kz = iz-1; 03977 argz = float(kz*kz)*dz2; 03978 for (int iy = 1; iy <= m_vnyp; iy++) { 03979 if ( iy-1 > m_vnyc ) ky = iy-1-m_vnyp; else ky = iy-1; 03980 argy = argz + float(ky*ky)*dy2; 03981 for (int ix = 0; ix <= m_vnxc; ix++) { 03982 float Kn = (*m_wptr3)(ix,iy,iz); 03983 argx = std::sqrt(argy + float(ix*ix)*dx2); 03984 int r = Util::round(float(inc)*argx); 03985 if ( r >= 0 && Kn > 4.5f ) { 03986 if ( m_weighting == ESTIMATE ) { 03987 int cx = ix; 03988 int cy = (iy<=m_vnyc) ? iy - 1 : iy - 1 - m_vnyp; 03989 int cz = (iz<=m_vnzc) ? iz - 1 : iz - 1 - m_vnzp; 03990 float sum = 0.0; 03991 for( int ii = -kc; ii <= kc; ++ii ) { 03992 int nbrcx = cx + ii; 03993 if( nbrcx >= m_vnxc ) continue; 03994 for ( int jj= -kc; jj <= kc; ++jj ) { 03995 int nbrcy = cy + jj; 03996 if( nbrcy <= -m_vnyc || nbrcy >= m_vnyc ) continue; 03997 for( int kk = -kc; kk <= kc; ++kk ) { 03998 int nbrcz = cz + jj; 03999 if ( nbrcz <= -m_vnyc || nbrcz >= m_vnyc ) continue; 04000 if( nbrcx < 0 ) { 04001 nbrcx = -nbrcx; 04002 nbrcy = -nbrcy; 04003 nbrcz = -nbrcz; 04004 } 04005 int nbrix = nbrcx; 04006 int nbriy = nbrcy >= 0 ? nbrcy + 1 : nbrcy + 1 + m_vnyp; 04007 int nbriz = nbrcz >= 0 ? nbrcz + 1 : nbrcz + 1 + m_vnzp; 04008 if( (*m_wptr)( nbrix, nbriy, nbriz ) == 0 ) { 04009 int c = 3*kc+1 - std::abs(ii) - std::abs(jj) - std::abs(kk); 04010 sum = sum + pow_a[c]; 04011 } 04012 } 04013 } 04014 } 04015 // int r = std::abs(cx) + std::abs(cy) + std::abs(cz); 04016 wght = 1.0f / ( 1.0f - alpha * sum ); 04017 } // end of ( m_weighting == ESTIMATE ) 04018 float nominator = std::norm(m_volume->cmplx(ix,iy,iz))/(*m_wptr)(ix,iy,iz); 04019 float denominator = ((*m_wptr2)(ix,iy,iz)-std::norm(m_volume->cmplx(ix,iy,iz))/(*m_wptr)(ix,iy,iz))/(Kn-1.0f); 04020 // Skip Friedel related values 04021 if( (ix>0 || (kz>=0 && (ky>=0 || kz!=0)))) { 04022 if ( r <= inc ) { 04023 nom[r] += nominator*wght; 04024 denom[r] += denominator/(*m_wptr)(ix,iy,iz)*wght; 04025 nn[r] += 2; 04026 ka[r] += int(Kn); 04027 } 04028 /* 04029 #ifdef _WIN32 04030 float tmp = _cpp_max(nominator/denominator/(*m_wptr)(ix,iy,iz)-1.0f,0.0f); 04031 #else 04032 float tmp = std::max(nominator/denominator/(*m_wptr)(ix,iy,iz)-1.0f,0.0f); 04033 #endif //_WIN32 04034 // Create SSNR as a 3D array (-n/2:n/2+n%2-1) 04035 int iix = m_vnxc + ix; int iiy = m_vnyc + ky; int iiz = m_vnzc + kz; 04036 if( iix >= 0 && iix < m_vnxp && iiy >= 0 && iiy < m_vnyp && iiz >= 0 && iiz < m_vnzp ) 04037 (*vol_ssnr)(iix, iiy, iiz) = tmp; 04038 // Friedel part 04039 iix = m_vnxc - ix; iiy = m_vnyc - ky; iiz = m_vnzc - kz; 04040 if( iix >= 0 && iix < m_vnxp && iiy >= 0 && iiy < m_vnyp && iiz >= 0 && iiz < m_vnzp ) 04041 (*vol_ssnr)(iix, iiy, iiz) = tmp; 04042 */ 04043 } 04044 (*vol_ssnr)(2*ix, iy-1, iz-1) = denominator*wght; 04045 } // end of Kn>4.5 or whatever 04046 } 04047 } 04048 } 04049 for (int i = 0; i <= inc; i++) { 04050 (*SSNR)(i,0,0) = nom[i]; 04051 (*SSNR)(i,1,0) = denom[i]; 04052 (*SSNR)(i,2,0) = static_cast<float>(nn[i]); 04053 (*SSNR)(i,3,0) = static_cast<float>(ka[i]); 04054 } 04055 vol_ssnr->update(); 04056 04057 delete[] nom; 04058 delete[] denom; 04059 delete[] nn; 04060 delete[] ka; 04061 04062 return 0; 04063 }
|
|
Get a clear, concise description of this class.
Implements EMAN::FactoryBase. Definition at line 1430 of file reconstructor.h. 01431 { 01432 return "Reconstruction by nearest neighbor with 3D SSNR with CTF"; 01433 }
|
|
Get the unique name of this class (especially for factory based instantiation access).
Implements EMAN::FactoryBase. Definition at line 1425 of file reconstructor.h. 01426 {
01427 return NAME;
01428 }
|
|
Implements EMAN::FactoryBase. Definition at line 1440 of file reconstructor.h. References EMAN::TypeDict::put(). 01441 { 01442 TypeDict d; 01443 d.put("size", EMObject::INT); 01444 d.put("npad", EMObject::INT); 01445 d.put("symmetry", EMObject::STRING); 01446 d.put("fftvol", EMObject::EMDATA); 01447 d.put("fftwvol", EMObject::EMDATA); 01448 d.put("weight", EMObject::EMDATA); 01449 d.put("weight2", EMObject::EMDATA); 01450 d.put("weight3", EMObject::EMDATA); 01451 d.put("SSNR", EMObject::EMDATA); 01452 d.put("vol_ssnr", EMObject::EMDATA); 01453 d.put("w", EMObject::FLOAT); 01454 d.put("sign", EMObject::INT); 01455 d.put("snr", EMObject::FLOAT); 01456 return d; 01457 }
|
|
Definition at line 3893 of file reconstructor.cpp. References Assert, EMAN::Transform::get_sym(), m_symmetry, m_volume, m_wptr, m_wptr2, m_wptr3, mult(), EMAN::EMData::nn_SSNR_ctf(), and t. 03894 { 03895 Assert( padfft != NULL ); 03896 03897 // insert slice for all symmetry related positions 03898 for (int isym=0; isym < m_nsym; isym++) { 03899 Transform tsym = t.get_sym(m_symmetry, isym); 03900 m_volume->nn_SSNR_ctf(m_wptr, m_wptr2, m_wptr3, padfft, tsym, mult); 03901 } 03902 03903 return 0; 03904 }
|
|
Insert a slice into a 3D volume, in a given orientation.
Reimplemented from EMAN::Reconstructor. |
|
Definition at line 1435 of file reconstructor.h. 01436 { 01437 return new nnSSNR_ctfReconstructor(); 01438 }
|
|
Definition at line 3792 of file reconstructor.cpp. References buildFFTVolume(), buildNorm2Volume(), buildNorm3Volume(), buildNormVolume(), EMAN::Transform::get_nsym(), m_npad, m_nsym, m_sign, m_snr, m_symmetry, m_vnx, m_vnxc, m_vnxp, m_vny, m_vnyc, m_vnyp, m_vnz, m_vnzc, m_vnzp, m_weighting, m_wghta, m_wghtb, and wiener. 03793 { 03794 03795 m_weighting = ESTIMATE; 03796 m_wghta = 0.2f; 03797 m_wghtb = 0.004f; 03798 wiener = 1; 03799 03800 m_symmetry = symmetry; 03801 m_npad = npad; 03802 m_nsym = Transform::get_nsym(m_symmetry); 03803 03804 m_sign = sign; 03805 m_snr = snr; 03806 03807 m_vnx = size; 03808 m_vny = size; 03809 m_vnz = size; 03810 03811 m_vnxp = size*npad; 03812 m_vnyp = size*npad; 03813 m_vnzp = size*npad; 03814 03815 m_vnxc = m_vnxp/2; 03816 m_vnyc = m_vnyp/2; 03817 m_vnzc = m_vnzp/2; 03818 03819 buildFFTVolume(); 03820 buildNormVolume(); 03821 buildNorm2Volume(); 03822 buildNorm3Volume(); 03823 }
|
|
Initialize the reconstructor.
Implements EMAN::Reconstructor. Definition at line 3780 of file reconstructor.cpp. References EMAN::Dict::has_key(), and sign. Referenced by nnSSNR_ctfReconstructor(). 03781 { 03782 int size = params["size"]; 03783 int npad = params["npad"]; 03784 int sign = params["sign"]; 03785 float snr = params["snr"]; 03786 string symmetry; 03787 if( params.has_key("symmetry") ) symmetry = params["symmetry"].to_str(); 03788 else symmetry = "c1"; 03789 03790 setup( symmetry, size, npad, snr, sign ); 03791 }
|
|
Definition at line 1472 of file reconstructor.h. Referenced by buildFFTVolume(), and setup(). |
|
Definition at line 1473 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1482 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1483 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1469 of file reconstructor.h. Referenced by insert_padfft_slice(), and setup(). |
|
Definition at line 1471 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1475 of file reconstructor.h. Referenced by buildFFTVolume(), buildNorm2Volume(), buildNorm3Volume(), buildNormVolume(), finish(), and setup(). |
|
Definition at line 1474 of file reconstructor.h. Referenced by buildFFTVolume(), finish(), and setup(). |
|
Definition at line 1471 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1475 of file reconstructor.h. |
|
Definition at line 1474 of file reconstructor.h. Referenced by buildFFTVolume(), buildNorm2Volume(), buildNorm3Volume(), buildNormVolume(), finish(), and setup(). |
|
Definition at line 1471 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1475 of file reconstructor.h. |
|
Definition at line 1474 of file reconstructor.h. Referenced by buildFFTVolume(), buildNorm2Volume(), buildNorm3Volume(), buildNormVolume(), finish(), and setup(). |
|
Definition at line 1465 of file reconstructor.h. Referenced by buildFFTVolume(), finish(), insert_padfft_slice(), and nnSSNR_ctfReconstructor(). |
|
Definition at line 1470 of file reconstructor.h. |
|
Definition at line 1480 of file reconstructor.h. |
|
Definition at line 1481 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1466 of file reconstructor.h. Referenced by buildNormVolume(), finish(), insert_padfft_slice(), and nnSSNR_ctfReconstructor(). |
|
Definition at line 1467 of file reconstructor.h. Referenced by buildNorm2Volume(), finish(), insert_padfft_slice(), and nnSSNR_ctfReconstructor(). |
|
Definition at line 1468 of file reconstructor.h. Referenced by buildNorm3Volume(), finish(), insert_padfft_slice(), and nnSSNR_ctfReconstructor(). |
|
Definition at line 87 of file reconstructor.cpp. |
|
Definition at line 1484 of file reconstructor.h. Referenced by setup(). |