#include <reconstructor.h>
Inheritance diagram for EMAN::nn4_ctf_rectReconstructor:
Public Member Functions | |
nn4_ctf_rectReconstructor () | |
nn4_ctf_rectReconstructor (const string &symmetry, int size, int npad, float snr, int sign) | |
virtual | ~nn4_ctf_rectReconstructor () |
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 | |
Reconstructor * | NEW () |
Static Public Attributes | |
const string | NAME = "nn4_ctf_rect" |
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_count |
float | m_xratio |
float | m_yratio |
float | m_zratio |
float | m_xscale |
float | m_yscale |
int | m_sizeofprojection |
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 1095 of file reconstructor.h.
|
Definition at line 3480 of file reconstructor.cpp. References m_result, m_volume, and m_wptr.
|
|
Definition at line 3487 of file reconstructor.cpp. 03488 { 03489 setup( symmetry, size, npad, snr, sign ); 03490 }
|
|
Definition at line 3492 of file reconstructor.cpp. References checked_delete(), m_result, m_volume, and m_wptr. 03493 { 03494 if( m_delete_volume ) checked_delete(m_volume); 03495 03496 if( m_delete_weight ) checked_delete( m_wptr ); 03497 03498 checked_delete( m_result ); 03499 }
|
|
|
Definition at line 3598 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::EMData::set_array_offsets(), EMAN::EMData::set_size(), and EMAN::EMData::to_zero(). Referenced by setup(). 03599 { 03600 if( params.has_key("weight") ) { 03601 m_wptr = params["weight"]; 03602 m_delete_weight = false; 03603 } else { 03604 m_wptr = new EMData(); 03605 m_delete_weight = true; 03606 } 03607 03608 if( m_wptr->get_xsize() != m_vnxc+1 && m_wptr->get_ysize() != m_vnyp && m_wptr->get_zsize() != m_vnzp ) { 03609 m_wptr->set_size(m_vnxc+1,m_vnyp,m_vnzp); 03610 m_wptr->to_zero(); 03611 } 03612 03613 m_wptr->set_array_offsets(0,1,1); 03614 03615 }
|
|
Finish reconstruction and return the complete model.
Reimplemented from EMAN::Reconstructor. Definition at line 3696 of file reconstructor.cpp. References abs, circumf_rect(), EMAN::EMData::copy(), EMAN::EMData::depad(), EMAN::EMData::do_ift_inplace(), EMAN::EMData::get_attr(), m_result, m_vnyc, m_vnyp, m_vnzp, m_volume, m_weighting, m_wghta, m_wptr, m_xratio, m_yratio, m_zratio, max, max3d(), EMAN::EMData::set_array_offsets(), sqrt(), and EMAN::EMData::symplane0_rect(). 03697 { 03698 m_volume->set_array_offsets(0, 1, 1); 03699 m_wptr->set_array_offsets(0, 1, 1); 03700 m_volume->symplane0_rect(m_wptr); 03701 03702 int box = 7; 03703 int vol = box*box*box; 03704 int kc = (box-1)/2; 03705 vector< float > pow_a( 3*kc+1, 1.0 ); 03706 for( unsigned int i=1; i < pow_a.size(); ++i ) pow_a[i] = pow_a[i-1] * exp(m_wghta); 03707 pow_a[3*kc]=0.0; 03708 03709 03710 float max = max3d( kc, pow_a ); 03711 float alpha = ( 1.0f - 1.0f/(float)vol ) / max; 03712 float osnr = 1.0f/m_snr; 03713 03714 // normalize 03715 int ix,iy,iz; 03716 for (iz = 1; iz <= m_vnzp; iz++) { 03717 for (iy = 1; iy <= m_vnyp; iy++) { 03718 for (ix = 0; ix <= m_vnxc; ix++) { 03719 if ( (*m_wptr)(ix,iy,iz) > 0.0f) {//(*v) should be treated as complex!! 03720 int iyp = (iy<=m_vnyc) ? iy - 1 : iy-m_vnyp-1; 03721 int izp = (iz<=m_vnzc) ? iz - 1 : iz-m_vnzp-1; 03722 float tmp=0.0; 03723 if( m_varsnr ) 03724 { 03725 float freq = sqrt( (float)(ix*ix/(m_xratio*m_xratio)+iyp*iyp/(m_zratio*m_yratio)+izp*izp) ); 03726 tmp = (-2*((ix+iy+iz)%2)+1)/((*m_wptr)(ix,iy,iz)+freq*osnr)*m_sign; 03727 } 03728 else 03729 { 03730 tmp = (-2*((ix+iy+iz)%2)+1)/((*m_wptr)(ix,iy,iz)+osnr)*m_sign; 03731 } 03732 03733 if( m_weighting == ESTIMATE ) { 03734 int cx = ix; 03735 int cy = (iy<=m_vnyc) ? iy - 1 : iy - 1 - m_vnyp; 03736 int cz = (iz<=m_vnzc) ? iz - 1 : iz - 1 - m_vnzp; 03737 float sum = 0.0; 03738 for( int ii = -kc; ii <= kc; ++ii ) { 03739 int nbrcx = cx + ii; 03740 if( nbrcx >= m_vnxc ) continue; 03741 for( int jj= -kc; jj <= kc; ++jj ) { 03742 int nbrcy = cy + jj; 03743 if( nbrcy <= -m_vnyc || nbrcy >= m_vnyc ) continue; 03744 for( int kk = -kc; kk <= kc; ++kk ) { 03745 int nbrcz = cz + jj; 03746 if( nbrcz <= -m_vnyc || nbrcz >= m_vnyc ) continue; 03747 if( nbrcx < 0 ) { 03748 nbrcx = -nbrcx; 03749 nbrcy = -nbrcy; 03750 nbrcz = -nbrcz; 03751 } 03752 03753 int nbrix = nbrcx; 03754 int nbriy = nbrcy >= 0 ? nbrcy + 1 : nbrcy + 1 + m_vnyp; 03755 int nbriz = nbrcz >= 0 ? nbrcz + 1 : nbrcz + 1 + m_vnzp; 03756 if( (*m_wptr)( nbrix, nbriy, nbriz ) == 0.0 ) { 03757 int c = 3*kc+1 - std::abs(ii) - std::abs(jj) - std::abs(kk); 03758 sum = sum + pow_a[c]; 03759 // if(ix%20==0 && iy%20==0 && iz%20==0) 03760 // std::cout << boost::format( "%4d %4d %4d %4d %10.3f" ) % nbrix % nbriy % nbriz % c % sum << std::endl; 03761 } 03762 } 03763 } 03764 } 03765 float wght = 1.0f / ( 1.0f - alpha * sum ); 03766 /* 03767 if(ix%10==0 && iy%10==0) 03768 { 03769 std::cout << boost::format( "%4d %4d %4d " ) % ix % iy %iz; 03770 std::cout << boost::format( "%10.3f %10.3f %10.3f " ) % tmp % wght % sum; 03771 std:: << boost::format( "%10.3f %10.3e " ) % pow_b[r] % alpha; 03772 std::cout << std::endl; 03773 } 03774 */ 03775 tmp = tmp * wght; 03776 } 03777 (*m_volume)(2*ix,iy,iz) *= tmp; 03778 (*m_volume)(2*ix+1,iy,iz) *= tmp; 03779 } 03780 } 03781 } 03782 } 03783 03784 // back fft 03785 m_volume->do_ift_inplace(); 03786 int npad = m_volume->get_attr("npad"); 03787 m_volume->depad(); 03788 circumf_rect( m_volume, npad ); 03789 m_volume->set_array_offsets( 0, 0, 0 ); 03790 m_result = m_volume->copy(); 03791 return m_result; 03792 }
|
|
Get a clear, concise description of this class.
Implements EMAN::FactoryBase. Definition at line 1124 of file reconstructor.h. 01125 { 01126 return "Direct Fourier inversion reconstruction routine"; 01127 }
|
|
Get the unique name of this class (especially for factory based instantiation access).
Implements EMAN::FactoryBase. Definition at line 1119 of file reconstructor.h. 01120 {
01121 return NAME;
01122 }
|
|
Implements EMAN::FactoryBase. Definition at line 1135 of file reconstructor.h. References EMAN::TypeDict::put(). 01136 { 01137 TypeDict d; 01138 d.put("sizeprojection", EMObject::INT); 01139 d.put("sizex", EMObject::INT); 01140 d.put("sizey", EMObject::INT); 01141 d.put("sizez", EMObject::INT); 01142 d.put("xratio", EMObject::FLOAT); 01143 d.put("yratio", EMObject::FLOAT); 01144 d.put("size", EMObject::INT); 01145 d.put("npad", EMObject::INT); 01146 d.put("sign", EMObject::INT); 01147 d.put("symmetry", EMObject::STRING); 01148 d.put("snr", EMObject::FLOAT); 01149 d.put("fftvol", EMObject::EMDATA); 01150 d.put("weight", EMObject::EMDATA); 01151 d.put("weighting", EMObject::INT); 01152 d.put("varsnr", EMObject::INT); 01153 return d; 01154 }
|
|
Definition at line 3656 of file reconstructor.cpp. References EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), m_volume, and m_wptr. 03657 { 03658 const float* bufdata = buffed->get_data(); 03659 float* cdata = m_volume->get_data(); 03660 float* wdata = m_wptr->get_data(); 03661 03662 int npoint = buffed->get_xsize()/4; 03663 for( int i=0; i < npoint; ++i ) { 03664 03665 int pos2 = int( bufdata[4*i] ); 03666 int pos1 = pos2 * 2; 03667 cdata[pos1 ] += bufdata[4*i+1]*mult; 03668 cdata[pos1+1] += bufdata[4*i+2]*mult; 03669 wdata[pos2 ] += bufdata[4*i+3]*mult; 03670 /* 03671 std::cout << "pos1, pos2, ctfv1, ctfv2, ctf2: "; 03672 std::cout << pos1 << " " << bufdata[5*i+1] << " " << bufdata[5*i+2] << " "; 03673 std::cout << pos2 << " " << bufdata[5*i+4] << std::endl; 03674 */ 03675 } 03676 return 0; 03677 }
|
|
Definition at line 3680 of file reconstructor.cpp. References Assert, EMAN::EMData::get_attr(), EMAN::EMData::insert_rect_slice_ctf(), EMAN::EMData::insert_rect_slice_ctf_applied(), m_npad, m_sizeofprojection, m_volume, m_wptr, m_xratio, m_yratio, mult(), and t. 03681 { 03682 Assert( padfft != NULL ); 03683 float tmp = padfft->get_attr("ctf_applied"); 03684 int ctf_applied = (int) tmp; 03685 03686 if (ctf_applied) m_volume->insert_rect_slice_ctf_applied(m_wptr, padfft, t, m_sizeofprojection, m_xratio,m_yratio, m_npad, mult); 03687 else m_volume->insert_rect_slice_ctf(m_wptr, padfft, t, m_sizeofprojection, m_xratio, m_yratio, m_npad, mult); 03688 03689 03690 03691 return 0; 03692 03693 }
|
|
Insert a slice into a 3D volume, in a given orientation.
Reimplemented from EMAN::Reconstructor. |
|
Definition at line 1129 of file reconstructor.h. 01130 { 01131 return new nn4_ctf_rectReconstructor(); 01132 }
|
|
Definition at line 3517 of file reconstructor.cpp. References buildFFTVolume(), buildNormVolume(), 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, m_xratio, and m_yratio. 03518 { 03519 m_weighting = ESTIMATE; 03520 if( params.has_key("weighting") ) { 03521 int tmp = int( params["weighting"] ); 03522 if( tmp==0 ) m_weighting = NONE; 03523 } 03524 03525 03526 03527 m_wghta = 0.2f; 03528 m_wghtb = 0.004f; 03529 03530 m_symmetry = symmetry; 03531 m_npad = npad; 03532 m_sign = sign; 03533 m_nsym = Transform::get_nsym(m_symmetry); 03534 03535 m_snr = snr; 03536 if( params.has_key("sizex") ) m_vnx = params["sizex"]; 03537 else if(params.has_key("xratio")) 03538 { 03539 float temp=params["xratio"]; 03540 m_vnx=int(float(sizeprojection)*temp); 03541 } 03542 else m_vnx=sizeprojection; 03543 03544 if( params.has_key("sizey") ) m_vny = params["sizey"]; 03545 else if (params.has_key("yratio")) 03546 { 03547 float temp=params["yratio"]; 03548 m_vny=int(float(sizeprojection)*temp); 03549 } 03550 else m_vny=sizeprojection; 03551 03552 if( params.has_key("sizez") ) 03553 m_vnz = params["sizez"]; 03554 else 03555 m_vnz =sizeprojection; 03556 03557 m_xratio=float(m_vnx)/float(sizeprojection); 03558 m_yratio=float(m_vny)/float(sizeprojection); 03559 03560 //std::cout<<"xratio=="<<m_xratio<<"yratio=="<<m_yratio<<std::endl; 03561 //std::cout<<"sx=="<<m_vnx<<"sy=="<<m_vny<<"sz=="<<m_vnz<<std::endl; 03562 03563 m_vnxp = m_vnx*npad; 03564 m_vnyp = m_vny*npad; 03565 m_vnzp = m_vnz*npad; 03566 03567 m_vnxc = m_vnxp/2; 03568 m_vnyc = m_vnyp/2; 03569 m_vnzc = m_vnzp/2; 03570 03571 buildFFTVolume(); 03572 buildNormVolume(); 03573 }
|
|
Initialize the reconstructor.
Implements EMAN::Reconstructor. Definition at line 3501 of file reconstructor.cpp. References EMAN::Dict::has_key(), m_sizeofprojection, m_varsnr, and sign. Referenced by nn4_ctf_rectReconstructor(). 03502 { 03503 if( ! params.has_key("sizeprojection") ) throw std::logic_error("Error: projection size is not given"); 03504 m_sizeofprojection = params["sizeprojection"]; 03505 int npad = params.has_key("npad") ? int(params["npad"]) : 4; 03506 // int sign = params.has_key("sign") ? int(params["sign"]) : 1; 03507 int sign = 1; 03508 string symmetry = params.has_key("symmetry")? params["symmetry"].to_str() : "c1"; 03509 03510 float snr = params["snr"]; 03511 03512 m_varsnr = params.has_key("varsnr") ? int(params["varsnr"]) : 0; 03513 setup( symmetry, m_sizeofprojection, npad, snr, sign ); 03514 03515 }
|
|
Definition at line 1173 of file reconstructor.h. |
|
Definition at line 1168 of file reconstructor.h. Referenced by buildFFTVolume(). |
|
Definition at line 1169 of file reconstructor.h. Referenced by buildNormVolume(). |
|
Definition at line 1177 of file reconstructor.h. Referenced by buildFFTVolume(), insert_padfft_slice(), and setup(). |
|
Definition at line 1184 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1166 of file reconstructor.h. Referenced by finish(), nn4_ctf_rectReconstructor(), and ~nn4_ctf_rectReconstructor(). |
|
Definition at line 1178 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1176 of file reconstructor.h. Referenced by insert_padfft_slice(), and setup(). |
|
Definition at line 1182 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1183 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1179 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1170 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1172 of file reconstructor.h. Referenced by buildNormVolume(), and setup(). |
|
Definition at line 1171 of file reconstructor.h. Referenced by buildFFTVolume(), and setup(). |
|
Definition at line 1170 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1172 of file reconstructor.h. |
|
Definition at line 1171 of file reconstructor.h. Referenced by buildFFTVolume(), buildNormVolume(), finish(), and setup(). |
|
Definition at line 1170 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1172 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1171 of file reconstructor.h. Referenced by buildFFTVolume(), buildNormVolume(), finish(), and setup(). |
|
Definition at line 1165 of file reconstructor.h. Referenced by buildFFTVolume(), finish(), insert_buffed_slice(), insert_padfft_slice(), nn4_ctf_rectReconstructor(), and ~nn4_ctf_rectReconstructor(). |
|
Definition at line 1180 of file reconstructor.h. |
|
Definition at line 1181 of file reconstructor.h. |
|
Definition at line 1181 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1167 of file reconstructor.h. Referenced by buildNormVolume(), finish(), insert_buffed_slice(), insert_padfft_slice(), nn4_ctf_rectReconstructor(), and ~nn4_ctf_rectReconstructor(). |
|
Definition at line 1174 of file reconstructor.h. Referenced by finish(), insert_padfft_slice(), and setup(). |
|
Definition at line 1175 of file reconstructor.h. |
|
Definition at line 1174 of file reconstructor.h. Referenced by finish(), insert_padfft_slice(), and setup(). |
|
Definition at line 1175 of file reconstructor.h. |
|
Definition at line 1174 of file reconstructor.h. Referenced by finish(). |
|
Definition at line 85 of file reconstructor.cpp. |