#include <reconstructor.h>
Inheritance diagram for EMAN::nn4_ctfReconstructor:
Public Member Functions | |
nn4_ctfReconstructor () | |
nn4_ctfReconstructor (const string &symmetry, int size, int npad, float snr, int sign) | |
virtual | ~nn4_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 *padfft, const Transform &trans, int mult=1) |
int | insert_buffed_slice (const EMData *buffer, int mult) |
Static Public Member Functions | |
static Reconstructor * | NEW () |
Static Public Attributes | |
static const string | NAME = "nn4_ctf" |
Private Member Functions | |
void | buildFFTVolume () |
void | buildNormVolume () |
Private Attributes | |
EMData * | m_volume |
EMData * | m_result |
EMData * | m_wptr |
bool | m_delete_volume |
bool | m_delete_weight |
int | m_vnx |
int | m_vny |
int | m_vnz |
int | m_vnzp |
int | m_vnyp |
int | m_vnxp |
int | m_vnxc |
int | m_vnyc |
int | m_vnzc |
int | m_npad |
int | m_sign |
int | m_varsnr |
int | m_weighting |
float | m_wghta |
float | m_wghtb |
float | m_snr |
string | m_symmetry |
int | m_nsym |
Definition at line 897 of file reconstructor.h.
|
Definition at line 2599 of file reconstructor.cpp. References m_result, m_volume, and m_wptr. Referenced by NEW().
|
|
Definition at line 2606 of file reconstructor.cpp. References setup().
|
|
Definition at line 2611 of file reconstructor.cpp. References checked_delete(), m_delete_volume, m_delete_weight, m_result, m_volume, and m_wptr. 02612 { 02613 if( m_delete_volume ) checked_delete(m_volume); 02614 02615 if( m_delete_weight ) checked_delete( m_wptr ); 02616 02617 checked_delete( m_result ); 02618 }
|
|
|
Definition at line 2699 of file reconstructor.cpp. References EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::Dict::has_key(), m_delete_weight, m_vnxc, m_vnyp, m_vnzp, m_wptr, EMAN::FactoryBase::params, EMAN::EMData::set_array_offsets(), EMAN::EMData::set_size(), and EMAN::EMData::to_zero(). Referenced by setup(). 02700 { 02701 if( params.has_key("weight") ) 02702 { 02703 m_wptr = params["weight"]; 02704 m_delete_weight = false; 02705 } else { 02706 m_wptr = new EMData(); 02707 m_delete_weight = true; 02708 } 02709 02710 if( m_wptr->get_xsize() != m_vnxc+1 && 02711 m_wptr->get_ysize() != m_vnyp && 02712 m_wptr->get_zsize() != m_vnzp ) 02713 { 02714 m_wptr->set_size(m_vnxc+1,m_vnyp,m_vnzp); 02715 m_wptr->to_zero(); 02716 } 02717 02718 m_wptr->set_array_offsets(0,1,1); 02719 02720 }
|
|
Finish reconstruction and return the complete model.
Reimplemented from EMAN::Reconstructor. Definition at line 2802 of file reconstructor.cpp. References abs, circumference(), EMAN::EMData::copy(), EMAN::EMData::depad(), EMAN::EMData::do_ift_inplace(), ESTIMATE, m_result, m_sign, m_snr, m_varsnr, m_vnxc, m_vnyc, m_vnyp, m_vnzc, m_vnzp, m_volume, m_weighting, m_wghta, m_wptr, max, max3d(), EMAN::EMData::set_array_offsets(), sqrt(), and EMAN::EMData::symplane0_ctf(). 02803 { 02804 m_volume->set_array_offsets(0, 1, 1); 02805 m_wptr->set_array_offsets(0, 1, 1); 02806 m_volume->symplane0_ctf(m_wptr); 02807 02808 int box = 7; 02809 int vol = box*box*box; 02810 int kc = (box-1)/2; 02811 vector< float > pow_a( 3*kc+1, 1.0 ); 02812 for( unsigned int i=1; i < pow_a.size(); ++i ) pow_a[i] = pow_a[i-1] * exp(m_wghta); 02813 pow_a[3*kc]=0.0; 02814 02815 02816 float max = max3d( kc, pow_a ); 02817 float alpha = ( 1.0f - 1.0f/(float)vol ) / max; 02818 float osnr = 1.0f/m_snr; 02819 02820 // normalize 02821 int ix,iy,iz; 02822 for (iz = 1; iz <= m_vnzp; iz++) { 02823 for (iy = 1; iy <= m_vnyp; iy++) { 02824 for (ix = 0; ix <= m_vnxc; ix++) { 02825 if ( (*m_wptr)(ix,iy,iz) > 0.0f) {//(*v) should be treated as complex!! 02826 int iyp = (iy<=m_vnyc) ? iy - 1 : iy-m_vnyp-1; 02827 int izp = (iz<=m_vnzc) ? iz - 1 : iz-m_vnzp-1; 02828 float tmp=0.0; 02829 if( m_varsnr ) 02830 { 02831 float freq = sqrt( (float)(ix*ix+iyp*iyp+izp*izp) ); 02832 tmp = (-2*((ix+iy+iz)%2)+1)/((*m_wptr)(ix,iy,iz)+freq*osnr)*m_sign; 02833 } 02834 else 02835 { 02836 tmp = (-2*((ix+iy+iz)%2)+1)/((*m_wptr)(ix,iy,iz)+osnr)*m_sign; 02837 } 02838 02839 if( m_weighting == ESTIMATE ) { 02840 int cx = ix; 02841 int cy = (iy<=m_vnyc) ? iy - 1 : iy - 1 - m_vnyp; 02842 int cz = (iz<=m_vnzc) ? iz - 1 : iz - 1 - m_vnzp; 02843 float sum = 0.0; 02844 for( int ii = -kc; ii <= kc; ++ii ) { 02845 int nbrcx = cx + ii; 02846 if( nbrcx >= m_vnxc ) continue; 02847 for( int jj= -kc; jj <= kc; ++jj ) { 02848 int nbrcy = cy + jj; 02849 if( nbrcy <= -m_vnyc || nbrcy >= m_vnyc ) continue; 02850 for( int kk = -kc; kk <= kc; ++kk ) { 02851 int nbrcz = cz + jj; 02852 if( nbrcz <= -m_vnyc || nbrcz >= m_vnyc ) continue; 02853 if( nbrcx < 0 ) { 02854 nbrcx = -nbrcx; 02855 nbrcy = -nbrcy; 02856 nbrcz = -nbrcz; 02857 } 02858 02859 int nbrix = nbrcx; 02860 int nbriy = nbrcy >= 0 ? nbrcy + 1 : nbrcy + 1 + m_vnyp; 02861 int nbriz = nbrcz >= 0 ? nbrcz + 1 : nbrcz + 1 + m_vnzp; 02862 if( (*m_wptr)( nbrix, nbriy, nbriz ) == 0.0 ) { 02863 int c = 3*kc+1 - std::abs(ii) - std::abs(jj) - std::abs(kk); 02864 sum = sum + pow_a[c]; 02865 // if(ix%20==0 && iy%20==0 && iz%20==0) 02866 // std::cout << boost::format( "%4d %4d %4d %4d %10.3f" ) % nbrix % nbriy % nbriz % c % sum << std::endl; 02867 } 02868 } 02869 } 02870 } 02871 float wght = 1.0f / ( 1.0f - alpha * sum ); 02872 /* 02873 if(ix%10==0 && iy%10==0) 02874 { 02875 std::cout << boost::format( "%4d %4d %4d " ) % ix % iy %iz; 02876 std::cout << boost::format( "%10.3f %10.3f %10.3f " ) % tmp % wght % sum; 02877 std:: << boost::format( "%10.3f %10.3e " ) % pow_b[r] % alpha; 02878 std::cout << std::endl; 02879 } 02880 */ 02881 tmp = tmp * wght; 02882 } 02883 (*m_volume)(2*ix,iy,iz) *= tmp; 02884 (*m_volume)(2*ix+1,iy,iz) *= tmp; 02885 } 02886 } 02887 } 02888 } 02889 02890 // back fft 02891 m_volume->do_ift_inplace(); 02892 m_volume->depad(); 02893 circumference( m_volume ); 02894 m_volume->set_array_offsets( 0, 0, 0 ); 02895 m_result = m_volume->copy(); 02896 return m_result; 02897 }
|
|
Get a clear, concise description of this class.
Implements EMAN::FactoryBase. Definition at line 926 of file reconstructor.h.
|
|
Get the unique name of this class (especially for factory based instantiation access).
Implements EMAN::FactoryBase. Definition at line 921 of file reconstructor.h. References NAME. 00922 { 00923 return NAME; 00924 }
|
|
Implements EMAN::FactoryBase. Definition at line 937 of file reconstructor.h. References EMAN::EMObject::EMDATA, EMAN::EMObject::FLOAT, EMAN::EMObject::INT, EMAN::TypeDict::put(), and EMAN::EMObject::STRING. 00938 { 00939 TypeDict d; 00940 d.put("size", EMObject::INT); 00941 d.put("npad", EMObject::INT); 00942 d.put("sign", EMObject::INT); 00943 d.put("symmetry", EMObject::STRING); 00944 d.put("snr", EMObject::FLOAT); 00945 d.put("fftvol", EMObject::EMDATA); 00946 d.put("weight", EMObject::EMDATA); 00947 d.put("weighting", EMObject::INT); 00948 d.put("varsnr", EMObject::INT); 00949 return d; 00950 }
|
|
Definition at line 2761 of file reconstructor.cpp. References EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), m_volume, and m_wptr. Referenced by insert_slice(). 02762 { 02763 const float* bufdata = buffed->get_data(); 02764 float* cdata = m_volume->get_data(); 02765 float* wdata = m_wptr->get_data(); 02766 02767 int npoint = buffed->get_xsize()/4; 02768 for( int i=0; i < npoint; ++i ) { 02769 02770 int pos2 = int( bufdata[4*i] ); 02771 int pos1 = pos2 * 2; 02772 cdata[pos1 ] += bufdata[4*i+1]*mult; 02773 cdata[pos1+1] += bufdata[4*i+2]*mult; 02774 wdata[pos2 ] += bufdata[4*i+3]*mult; 02775 /* 02776 std::cout << "pos1, pos2, ctfv1, ctfv2, ctf2: "; 02777 std::cout << pos1 << " " << bufdata[5*i+1] << " " << bufdata[5*i+2] << " "; 02778 std::cout << pos2 << " " << bufdata[5*i+4] << std::endl; 02779 */ 02780 } 02781 return 0; 02782 }
|
|
Definition at line 2784 of file reconstructor.cpp. References Assert, EMAN::EMData::get_attr(), EMAN::Transform::get_sym(), m_nsym, m_symmetry, m_volume, m_wptr, EMAN::EMData::nn_ctf(), and EMAN::EMData::nn_ctf_applied(). Referenced by insert_slice(). 02785 { 02786 Assert( padfft != NULL ); 02787 float tmp = padfft->get_attr("ctf_applied"); 02788 int ctf_applied = (int) tmp; 02789 02790 for( int isym=0; isym < m_nsym; isym++) { 02791 Transform tsym = t.get_sym( m_symmetry, isym ); 02792 02793 if(ctf_applied) m_volume->nn_ctf_applied(m_wptr, padfft, tsym, mult); 02794 else m_volume->nn_ctf(m_wptr, padfft, tsym, mult); 02795 } 02796 02797 return 0; 02798 02799 }
|
|
Insert a slice into a 3D volume, in a given orientation.
Reimplemented from EMAN::Reconstructor. Definition at line 2722 of file reconstructor.cpp. References Assert, checked_delete(), EMAN::EMData::get_attr_default(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), insert_buffed_slice(), insert_padfft_slice(), LOGERR, m_npad, m_vnx, mult(), and EMAN::padfft_slice(). 02723 { 02724 // sanity checks 02725 if (!slice) { 02726 LOGERR("try to insert NULL slice"); 02727 return 1; 02728 } 02729 02730 int buffed = slice->get_attr_default( "buffed", 0 ); 02731 if( buffed > 0 ) 02732 { 02733 int mult = slice->get_attr_default( "mult", 1 ); 02734 insert_buffed_slice( slice, mult ); 02735 return 0; 02736 } 02737 02738 int padffted= slice->get_attr_default("padffted", 0); 02739 if( padffted==0 && (slice->get_xsize()!=slice->get_ysize() || slice->get_xsize()!=m_vnx) ) 02740 { 02741 // FIXME: Why doesn't this throw an exception? 02742 LOGERR("Tried to insert a slice that is the wrong size."); 02743 return 1; 02744 } 02745 02746 EMData* padfft = NULL; 02747 02748 if( padffted != 0 ) padfft = new EMData(*slice); 02749 else padfft = padfft_slice( slice, t, m_npad ); 02750 02751 int mult= slice->get_attr_default("mult", 1); 02752 02753 Assert( mult > 0 ); 02754 insert_padfft_slice( padfft, t, mult ); 02755 02756 checked_delete( padfft ); 02757 02758 return 0; 02759 }
|
|
Definition at line 931 of file reconstructor.h. References nn4_ctfReconstructor(). 00932 { 00933 return new nn4_ctfReconstructor(); 00934 }
|
|
Definition at line 2637 of file reconstructor.cpp. References buildFFTVolume(), buildNormVolume(), ESTIMATE, EMAN::Transform::get_nsym(), EMAN::Dict::has_key(), 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, NONE, and EMAN::FactoryBase::params. 02638 { 02639 m_weighting = ESTIMATE; 02640 if( params.has_key("weighting") ) { 02641 int tmp = int( params["weighting"] ); 02642 if( tmp==0 ) m_weighting = NONE; 02643 } 02644 02645 02646 02647 m_wghta = 0.2f; 02648 m_wghtb = 0.004f; 02649 02650 m_symmetry = symmetry; 02651 m_npad = npad; 02652 m_sign = sign; 02653 m_nsym = Transform::get_nsym(m_symmetry); 02654 02655 m_snr = snr; 02656 02657 m_vnx = size; 02658 m_vny = size; 02659 m_vnz = size; 02660 02661 m_vnxp = size*npad; 02662 m_vnyp = size*npad; 02663 m_vnzp = size*npad; 02664 02665 m_vnxc = m_vnxp/2; 02666 m_vnyc = m_vnyp/2; 02667 m_vnzc = m_vnzp/2; 02668 02669 buildFFTVolume(); 02670 buildNormVolume(); 02671 }
|
|
Initialize the reconstructor.
Implements EMAN::Reconstructor. Definition at line 2620 of file reconstructor.cpp. References EMAN::Dict::has_key(), m_varsnr, EMAN::FactoryBase::params, and sign. Referenced by nn4_ctfReconstructor(). 02621 { 02622 if( ! params.has_key("size") ) throw std::logic_error("Error: image size is not given"); 02623 02624 int size = params["size"]; 02625 int npad = params.has_key("npad") ? int(params["npad"]) : 4; 02626 // int sign = params.has_key("sign") ? int(params["sign"]) : 1; 02627 int sign = 1; 02628 string symmetry = params.has_key("symmetry")? params["symmetry"].to_str() : "c1"; 02629 02630 float snr = params["snr"]; 02631 02632 m_varsnr = params.has_key("varsnr") ? int(params["varsnr"]) : 0; 02633 setup( symmetry, size, npad, snr, sign ); 02634 02635 }
|
|
Definition at line 964 of file reconstructor.h. Referenced by buildFFTVolume(), and ~nn4_ctfReconstructor(). |
|
Definition at line 965 of file reconstructor.h. Referenced by buildNormVolume(), and ~nn4_ctfReconstructor(). |
|
Definition at line 969 of file reconstructor.h. Referenced by buildFFTVolume(), insert_slice(), and setup(). |
|
Definition at line 976 of file reconstructor.h. Referenced by insert_padfft_slice(), and setup(). |
|
Definition at line 962 of file reconstructor.h. Referenced by finish(), nn4_ctfReconstructor(), and ~nn4_ctfReconstructor(). |
|
Definition at line 970 of file reconstructor.h. |
|
Definition at line 974 of file reconstructor.h. |
|
Definition at line 975 of file reconstructor.h. Referenced by insert_padfft_slice(), and setup(). |
|
Definition at line 971 of file reconstructor.h. |
|
Definition at line 966 of file reconstructor.h. Referenced by insert_slice(), and setup(). |
|
Definition at line 968 of file reconstructor.h. Referenced by buildNormVolume(), finish(), and setup(). |
|
Definition at line 967 of file reconstructor.h. Referenced by buildFFTVolume(), and setup(). |
|
Definition at line 966 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 968 of file reconstructor.h. |
|
Definition at line 967 of file reconstructor.h. Referenced by buildFFTVolume(), buildNormVolume(), finish(), and setup(). |
|
Definition at line 966 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 968 of file reconstructor.h. |
|
Definition at line 967 of file reconstructor.h. Referenced by buildFFTVolume(), buildNormVolume(), finish(), and setup(). |
|
Definition at line 961 of file reconstructor.h. Referenced by buildFFTVolume(), finish(), insert_buffed_slice(), insert_padfft_slice(), nn4_ctfReconstructor(), and ~nn4_ctfReconstructor(). |
|
Definition at line 972 of file reconstructor.h. |
|
Definition at line 973 of file reconstructor.h. |
|
Definition at line 973 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 963 of file reconstructor.h. Referenced by buildNormVolume(), finish(), insert_buffed_slice(), insert_padfft_slice(), nn4_ctfReconstructor(), and ~nn4_ctfReconstructor(). |
|
Definition at line 958 of file reconstructor.h. Referenced by get_name(). |