#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 3730 of file reconstructor.cpp. References m_volume, m_wptr, m_wptr2, and m_wptr3. 03731 { 03732 m_volume = NULL; 03733 m_wptr = NULL; 03734 m_wptr2 = NULL; 03735 m_wptr3 = NULL; 03736 }
|
|
Definition at line 3738 of file reconstructor.cpp. References m_volume, m_wptr, m_wptr2, m_wptr3, setup(), and sign. 03739 { 03740 m_volume = NULL; 03741 m_wptr = NULL; 03742 m_wptr2 = NULL; 03743 m_wptr3 = NULL; 03744 03745 setup( symmetry, size, npad, snr, sign ); 03746 }
|
|
Definition at line 3748 of file reconstructor.cpp. 03749 { 03750 03751 //if( m_delete_volume ) checked_delete(m_volume); 03752 //if( m_delete_weight ) checked_delete( m_wptr ); 03753 //if( m_delete_weight2 ) checked_delete( m_wptr2 ); 03754 //if( m_delete_weight3 ) checked_delete( m_wptr3 ); 03755 //checked_delete( m_result ); 03756 }
|
|
Definition at line 3803 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(). 03803 { 03804 03805 int offset = 2 - m_vnxp%2; 03806 m_volume = params["fftvol"]; 03807 03808 m_volume->set_size(m_vnxp+offset,m_vnyp,m_vnzp); 03809 m_volume->to_zero(); 03810 03811 m_volume->set_fftodd(m_vnxp % 2); 03812 03813 m_volume->set_nxc(m_vnxc); 03814 m_volume->set_complex(true); 03815 m_volume->set_ri(true); //(real, imaginary) instead of polar coordinate 03816 m_volume->set_fftpad(true); 03817 m_volume->set_attr("npad", m_npad); 03818 m_volume->set_array_offsets(0,1,1); 03819 }
|
|
Definition at line 3830 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(). 03830 { 03831 03832 m_wptr2 = params["weight2"]; 03833 m_wptr2->set_size(m_vnxc+1,m_vnyp,m_vnzp); 03834 m_wptr2->to_zero(); 03835 m_wptr2->set_array_offsets(0,1,1); 03836 }
|
|
Definition at line 3838 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(). 03838 { 03839 03840 m_wptr3 = params["weight3"]; 03841 m_wptr3->set_size(m_vnxc+1,m_vnyp,m_vnzp); 03842 m_wptr3->to_zero(); 03843 m_wptr3->set_array_offsets(0,1,1); 03844 }
|
|
Definition at line 3822 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(). 03823 { 03824 m_wptr = params["weight"]; 03825 m_wptr->set_size(m_vnxc+1,m_vnyp,m_vnzp); 03826 m_wptr->to_zero(); 03827 m_wptr->set_array_offsets(0,1,1); 03828 }
|
|
Finish reconstruction and return the complete model.
Reimplemented from EMAN::Reconstructor. Definition at line 3885 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(). 03886 { 03887 /* 03888 I changed the code on 05/15 so it only returns variance. 03889 Lines commented out are marked by //# 03890 The version prior to the currect changes is r1.190 03891 PAP 03892 */ 03893 /*** 03894 m_volume ctf*(P^2D->3D(F^3D)) 03895 m_wptr ctf^2 03896 m_wptr2 |P^2D->3D(F^3D)|^2 03897 m_wptr3 Kn 03898 nominator = sum_rot [ wght*signal ] 03899 denominator = sum_rot[ wght*variance ] 03900 ***/ 03901 int kz, ky; 03902 int box = 7; 03903 int kc = (box-1)/2; 03904 float alpha = 0.0; 03905 float argx, argy, argz; 03906 vector< float > pow_a( 3*kc+1, 1.0 ); 03907 float w = params["w"]; 03908 float dx2 = 1.0f/float(m_vnxc)/float(m_vnxc); 03909 float dy2 = 1.0f/float(m_vnyc)/float(m_vnyc); 03910 #ifdef _WIN32 03911 float dz2 = 1.0f/_cpp_max(float(m_vnzc),1.0f)/_cpp_max(float(m_vnzc),1.0f); 03912 int inc = Util::round(float(_cpp_max(_cpp_max(m_vnxc,m_vnyc),m_vnzc))/w); 03913 #else 03914 float dz2 = 1.0f/std::max(float(m_vnzc),1.0f)/std::max(float(m_vnzc),1.0f); 03915 int inc = Util::round(float(std::max(std::max(m_vnxc,m_vnyc),m_vnzc))/w); 03916 #endif //_WIN32 03917 03918 EMData* SSNR = params["SSNR"]; 03919 SSNR->set_size(inc+1,4,1); 03920 //#EMData* vol_ssnr = new EMData(); 03921 //#vol_ssnr->set_size(m_vnxp, m_vnyp, m_vnzp); 03922 //#vol_ssnr->to_zero(); 03923 //# new linea follow 03924 EMData* vol_ssnr = params["vol_ssnr"]; 03925 vol_ssnr->set_size(m_vnxp+ 2 - m_vnxp%2, m_vnyp ,m_vnzp); 03926 vol_ssnr->to_zero(); 03927 if ( m_vnxp % 2 == 0 ) vol_ssnr->set_fftodd(0); 03928 else vol_ssnr->set_fftodd(1); 03929 vol_ssnr->set_nxc(m_vnxc); 03930 vol_ssnr->set_complex(true); 03931 vol_ssnr->set_ri(true); 03932 vol_ssnr->set_fftpad(false); 03933 //# 03934 float *nom = new float[inc+1]; 03935 float *denom = new float[inc+1]; 03936 int *ka = new int[inc+1]; 03937 int *nn = new int[inc+1]; 03938 float wght = 1.f; 03939 for (int i = 0; i <= inc; i++) { 03940 nom[i] = 0.0f; 03941 denom[i] = 0.0f; 03942 nn[i] = 0; 03943 ka[i] = 0; 03944 } 03945 m_volume->symplane2(m_wptr, m_wptr2, m_wptr3); 03946 if ( m_weighting == ESTIMATE ) { 03947 int vol = box*box*box; 03948 for( unsigned int i=1; i < pow_a.size(); ++i ) pow_a[i] = pow_a[i-1] * exp(m_wghta); 03949 pow_a[3*kc] = 0.0; 03950 float max = max3d( kc, pow_a ); 03951 alpha = ( 1.0f - 1.0f/(float)vol ) / max; 03952 } 03953 for (int iz = 1; iz <= m_vnzp; iz++) { 03954 if ( iz-1 > m_vnzc ) kz = iz-1-m_vnzp; else kz = iz-1; 03955 argz = float(kz*kz)*dz2; 03956 for (int iy = 1; iy <= m_vnyp; iy++) { 03957 if ( iy-1 > m_vnyc ) ky = iy-1-m_vnyp; else ky = iy-1; 03958 argy = argz + float(ky*ky)*dy2; 03959 for (int ix = 0; ix <= m_vnxc; ix++) { 03960 float Kn = (*m_wptr3)(ix,iy,iz); 03961 argx = std::sqrt(argy + float(ix*ix)*dx2); 03962 int r = Util::round(float(inc)*argx); 03963 if ( r >= 0 && Kn > 4.5f ) { 03964 if ( m_weighting == ESTIMATE ) { 03965 int cx = ix; 03966 int cy = (iy<=m_vnyc) ? iy - 1 : iy - 1 - m_vnyp; 03967 int cz = (iz<=m_vnzc) ? iz - 1 : iz - 1 - m_vnzp; 03968 float sum = 0.0; 03969 for( int ii = -kc; ii <= kc; ++ii ) { 03970 int nbrcx = cx + ii; 03971 if( nbrcx >= m_vnxc ) continue; 03972 for ( int jj= -kc; jj <= kc; ++jj ) { 03973 int nbrcy = cy + jj; 03974 if( nbrcy <= -m_vnyc || nbrcy >= m_vnyc ) continue; 03975 for( int kk = -kc; kk <= kc; ++kk ) { 03976 int nbrcz = cz + jj; 03977 if ( nbrcz <= -m_vnyc || nbrcz >= m_vnyc ) continue; 03978 if( nbrcx < 0 ) { 03979 nbrcx = -nbrcx; 03980 nbrcy = -nbrcy; 03981 nbrcz = -nbrcz; 03982 } 03983 int nbrix = nbrcx; 03984 int nbriy = nbrcy >= 0 ? nbrcy + 1 : nbrcy + 1 + m_vnyp; 03985 int nbriz = nbrcz >= 0 ? nbrcz + 1 : nbrcz + 1 + m_vnzp; 03986 if( (*m_wptr)( nbrix, nbriy, nbriz ) == 0 ) { 03987 int c = 3*kc+1 - std::abs(ii) - std::abs(jj) - std::abs(kk); 03988 sum = sum + pow_a[c]; 03989 } 03990 } 03991 } 03992 } 03993 // int r = std::abs(cx) + std::abs(cy) + std::abs(cz); 03994 wght = 1.0f / ( 1.0f - alpha * sum ); 03995 } // end of ( m_weighting == ESTIMATE ) 03996 float nominator = std::norm(m_volume->cmplx(ix,iy,iz))/(*m_wptr)(ix,iy,iz); 03997 float denominator = ((*m_wptr2)(ix,iy,iz)-std::norm(m_volume->cmplx(ix,iy,iz))/(*m_wptr)(ix,iy,iz))/(Kn-1.0f); 03998 // Skip Friedel related values 03999 if( (ix>0 || (kz>=0 && (ky>=0 || kz!=0)))) { 04000 if ( r <= inc ) { 04001 nom[r] += nominator*wght; 04002 denom[r] += denominator/(*m_wptr)(ix,iy,iz)*wght; 04003 nn[r] += 2; 04004 ka[r] += int(Kn); 04005 } 04006 /* 04007 #ifdef _WIN32 04008 float tmp = _cpp_max(nominator/denominator/(*m_wptr)(ix,iy,iz)-1.0f,0.0f); 04009 #else 04010 float tmp = std::max(nominator/denominator/(*m_wptr)(ix,iy,iz)-1.0f,0.0f); 04011 #endif //_WIN32 04012 // Create SSNR as a 3D array (-n/2:n/2+n%2-1) 04013 int iix = m_vnxc + ix; int iiy = m_vnyc + ky; int iiz = m_vnzc + kz; 04014 if( iix >= 0 && iix < m_vnxp && iiy >= 0 && iiy < m_vnyp && iiz >= 0 && iiz < m_vnzp ) 04015 (*vol_ssnr)(iix, iiy, iiz) = tmp; 04016 // Friedel part 04017 iix = m_vnxc - ix; iiy = m_vnyc - ky; iiz = m_vnzc - kz; 04018 if( iix >= 0 && iix < m_vnxp && iiy >= 0 && iiy < m_vnyp && iiz >= 0 && iiz < m_vnzp ) 04019 (*vol_ssnr)(iix, iiy, iiz) = tmp; 04020 */ 04021 } 04022 (*vol_ssnr)(2*ix, iy-1, iz-1) = denominator*wght; 04023 } // end of Kn>4.5 or whatever 04024 } 04025 } 04026 } 04027 for (int i = 0; i <= inc; i++) { 04028 (*SSNR)(i,0,0) = nom[i]; 04029 (*SSNR)(i,1,0) = denom[i]; 04030 (*SSNR)(i,2,0) = static_cast<float>(nn[i]); 04031 (*SSNR)(i,3,0) = static_cast<float>(ka[i]); 04032 } 04033 vol_ssnr->update(); 04034 04035 delete[] nom; 04036 delete[] denom; 04037 delete[] nn; 04038 delete[] ka; 04039 04040 return 0; 04041 }
|
|
Get a clear, concise description of this class.
Implements EMAN::FactoryBase. Definition at line 1213 of file reconstructor.h. 01214 { 01215 return "Reconstruction by nearest neighbor with 3D SSNR with CTF"; 01216 }
|
|
Get the unique name of this class (especially for factory based instantiation access).
Implements EMAN::FactoryBase. Definition at line 1208 of file reconstructor.h. 01209 {
01210 return NAME;
01211 }
|
|
Implements EMAN::FactoryBase. Definition at line 1223 of file reconstructor.h. References EMAN::TypeDict::put(). 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 }
|
|
Definition at line 3871 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. 03872 { 03873 Assert( padfft != NULL ); 03874 03875 // insert slice for all symmetry related positions 03876 for (int isym=0; isym < m_nsym; isym++) { 03877 Transform tsym = t.get_sym(m_symmetry, isym); 03878 m_volume->nn_SSNR_ctf(m_wptr, m_wptr2, m_wptr3, padfft, tsym, mult); 03879 } 03880 03881 return 0; 03882 }
|
|
Insert a slice into a 3D volume, in a given orientation.
Reimplemented from EMAN::Reconstructor. |
|
Definition at line 1218 of file reconstructor.h. 01219 { 01220 return new nnSSNR_ctfReconstructor(); 01221 }
|
|
Definition at line 3770 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. 03771 { 03772 03773 m_weighting = ESTIMATE; 03774 m_wghta = 0.2f; 03775 m_wghtb = 0.004f; 03776 wiener = 1; 03777 03778 m_symmetry = symmetry; 03779 m_npad = npad; 03780 m_nsym = Transform::get_nsym(m_symmetry); 03781 03782 m_sign = sign; 03783 m_snr = snr; 03784 03785 m_vnx = size; 03786 m_vny = size; 03787 m_vnz = size; 03788 03789 m_vnxp = size*npad; 03790 m_vnyp = size*npad; 03791 m_vnzp = size*npad; 03792 03793 m_vnxc = m_vnxp/2; 03794 m_vnyc = m_vnyp/2; 03795 m_vnzc = m_vnzp/2; 03796 03797 buildFFTVolume(); 03798 buildNormVolume(); 03799 buildNorm2Volume(); 03800 buildNorm3Volume(); 03801 }
|
|
Initialize the reconstructor.
Implements EMAN::Reconstructor. Definition at line 3758 of file reconstructor.cpp. References EMAN::Dict::has_key(), and sign. Referenced by nnSSNR_ctfReconstructor(). 03759 { 03760 int size = params["size"]; 03761 int npad = params["npad"]; 03762 int sign = params["sign"]; 03763 float snr = params["snr"]; 03764 string symmetry; 03765 if( params.has_key("symmetry") ) symmetry = params["symmetry"].to_str(); 03766 else symmetry = "c1"; 03767 03768 setup( symmetry, size, npad, snr, sign ); 03769 }
|
|
Definition at line 1255 of file reconstructor.h. Referenced by buildFFTVolume(), and setup(). |
|
Definition at line 1256 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1265 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1266 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1252 of file reconstructor.h. Referenced by insert_padfft_slice(), and setup(). |
|
Definition at line 1254 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1258 of file reconstructor.h. Referenced by buildFFTVolume(), buildNorm2Volume(), buildNorm3Volume(), buildNormVolume(), finish(), and setup(). |
|
Definition at line 1257 of file reconstructor.h. Referenced by buildFFTVolume(), finish(), and setup(). |
|
Definition at line 1254 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1258 of file reconstructor.h. |
|
Definition at line 1257 of file reconstructor.h. Referenced by buildFFTVolume(), buildNorm2Volume(), buildNorm3Volume(), buildNormVolume(), finish(), and setup(). |
|
Definition at line 1254 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1258 of file reconstructor.h. |
|
Definition at line 1257 of file reconstructor.h. Referenced by buildFFTVolume(), buildNorm2Volume(), buildNorm3Volume(), buildNormVolume(), finish(), and setup(). |
|
Definition at line 1248 of file reconstructor.h. Referenced by buildFFTVolume(), finish(), insert_padfft_slice(), and nnSSNR_ctfReconstructor(). |
|
Definition at line 1253 of file reconstructor.h. |
|
Definition at line 1263 of file reconstructor.h. |
|
Definition at line 1264 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1249 of file reconstructor.h. Referenced by buildNormVolume(), finish(), insert_padfft_slice(), and nnSSNR_ctfReconstructor(). |
|
Definition at line 1250 of file reconstructor.h. Referenced by buildNorm2Volume(), finish(), insert_padfft_slice(), and nnSSNR_ctfReconstructor(). |
|
Definition at line 1251 of file reconstructor.h. Referenced by buildNorm3Volume(), finish(), insert_padfft_slice(), and nnSSNR_ctfReconstructor(). |
|
Definition at line 86 of file reconstructor.cpp. |
|
Definition at line 1267 of file reconstructor.h. Referenced by setup(). |