#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_wptr |
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 |
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 1301 of file reconstructor.h.
|
Definition at line 3442 of file reconstructor.cpp. References m_volume, and m_wptr.
|
|
Definition at line 3448 of file reconstructor.cpp. 03449 { 03450 setup( symmetry, size, npad, snr, sign ); 03451 }
|
|
Definition at line 3453 of file reconstructor.cpp. 03454 { 03455 //if( m_delete_volume ) checked_delete(m_volume); 03456 03457 //if( m_delete_weight ) checked_delete( m_wptr ); 03458 03459 //checked_delete( m_result ); 03460 }
|
|
Definition at line 3535 of file reconstructor.cpp. References EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), m_npad, m_vnxp, m_vnyp, m_vnzp, m_volume, EMAN::EMData::set_array_offsets(), EMAN::EMData::set_attr(), EMAN::EMData::set_complex(), EMAN::EMData::set_fftpad(), EMAN::EMData::set_nxc(), EMAN::EMData::set_ri(), EMAN::EMData::set_size(), and EMAN::EMData::to_zero(). Referenced by setup(). 03535 { 03536 int offset = 2 - m_vnxp%2; 03537 03538 m_volume = params["fftvol"]; 03539 03540 if( m_volume->get_xsize() != m_vnxp+offset && m_volume->get_ysize() != m_vnyp && m_volume->get_zsize() != m_vnzp ) { 03541 m_volume->set_size(m_vnxp+offset,m_vnyp,m_vnzp); 03542 m_volume->to_zero(); 03543 } 03544 03545 m_volume->set_nxc(m_vnxp/2); 03546 m_volume->set_complex(true); 03547 m_volume->set_ri(true); 03548 m_volume->set_fftpad(true); 03549 m_volume->set_attr("npad", m_npad); 03550 m_volume->set_array_offsets(0,1,1); 03551 }
|
|
Definition at line 3553 of file reconstructor.cpp. References EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), 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(). 03554 { 03555 m_wptr = params["weight"]; 03556 03557 if( m_wptr->get_xsize() != m_vnxc+1 && m_wptr->get_ysize() != m_vnyp && m_wptr->get_zsize() != m_vnzp ) { 03558 m_wptr->set_size(m_vnxc+1,m_vnyp,m_vnzp); 03559 m_wptr->to_zero(); 03560 } 03561 03562 m_wptr->set_array_offsets(0,1,1); 03563 03564 }
|
|
Finish reconstruction and return the complete model.
Reimplemented from EMAN::Reconstructor. Definition at line 3648 of file reconstructor.cpp. References abs, circumf_rect(), EMAN::EMData::depad(), EMAN::EMData::do_ift_inplace(), EMAN::EMData::get_attr(), 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(). 03649 { 03650 m_volume->set_array_offsets(0, 1, 1); 03651 m_wptr->set_array_offsets(0, 1, 1); 03652 m_volume->symplane0_rect(m_wptr); 03653 03654 int box = 7; 03655 int vol = box*box*box; 03656 int kc = (box-1)/2; 03657 vector< float > pow_a( 3*kc+1, 1.0 ); 03658 for( unsigned int i=1; i < pow_a.size(); ++i ) pow_a[i] = pow_a[i-1] * exp(m_wghta); 03659 pow_a[3*kc]=0.0; 03660 03661 03662 float max = max3d( kc, pow_a ); 03663 float alpha = ( 1.0f - 1.0f/(float)vol ) / max; 03664 float osnr = 1.0f/m_snr; 03665 03666 // normalize 03667 int ix,iy,iz; 03668 for (iz = 1; iz <= m_vnzp; iz++) { 03669 for (iy = 1; iy <= m_vnyp; iy++) { 03670 for (ix = 0; ix <= m_vnxc; ix++) { 03671 if ( (*m_wptr)(ix,iy,iz) > 0.0f) {//(*v) should be treated as complex!! 03672 int iyp = (iy<=m_vnyc) ? iy - 1 : iy-m_vnyp-1; 03673 int izp = (iz<=m_vnzc) ? iz - 1 : iz-m_vnzp-1; 03674 float tmp=0.0; 03675 if( m_varsnr ) 03676 { 03677 float freq = sqrt( (float)(ix*ix/(m_xratio*m_xratio)+iyp*iyp/(m_zratio*m_yratio)+izp*izp) ); 03678 tmp = (-2*((ix+iy+iz)%2)+1)/((*m_wptr)(ix,iy,iz)+freq*osnr)*m_sign; 03679 } 03680 else 03681 { 03682 tmp = (-2*((ix+iy+iz)%2)+1)/((*m_wptr)(ix,iy,iz)+osnr)*m_sign; 03683 } 03684 03685 if( m_weighting == ESTIMATE ) { 03686 int cx = ix; 03687 int cy = (iy<=m_vnyc) ? iy - 1 : iy - 1 - m_vnyp; 03688 int cz = (iz<=m_vnzc) ? iz - 1 : iz - 1 - m_vnzp; 03689 float sum = 0.0; 03690 for( int ii = -kc; ii <= kc; ++ii ) { 03691 int nbrcx = cx + ii; 03692 if( nbrcx >= m_vnxc ) continue; 03693 for( int jj= -kc; jj <= kc; ++jj ) { 03694 int nbrcy = cy + jj; 03695 if( nbrcy <= -m_vnyc || nbrcy >= m_vnyc ) continue; 03696 for( int kk = -kc; kk <= kc; ++kk ) { 03697 int nbrcz = cz + jj; 03698 if( nbrcz <= -m_vnyc || nbrcz >= m_vnyc ) continue; 03699 if( nbrcx < 0 ) { 03700 nbrcx = -nbrcx; 03701 nbrcy = -nbrcy; 03702 nbrcz = -nbrcz; 03703 } 03704 03705 int nbrix = nbrcx; 03706 int nbriy = nbrcy >= 0 ? nbrcy + 1 : nbrcy + 1 + m_vnyp; 03707 int nbriz = nbrcz >= 0 ? nbrcz + 1 : nbrcz + 1 + m_vnzp; 03708 if( (*m_wptr)( nbrix, nbriy, nbriz ) == 0.0 ) { 03709 int c = 3*kc+1 - std::abs(ii) - std::abs(jj) - std::abs(kk); 03710 sum = sum + pow_a[c]; 03711 // if(ix%20==0 && iy%20==0 && iz%20==0) 03712 // std::cout << boost::format( "%4d %4d %4d %4d %10.3f" ) % nbrix % nbriy % nbriz % c % sum << std::endl; 03713 } 03714 } 03715 } 03716 } 03717 float wght = 1.0f / ( 1.0f - alpha * sum ); 03718 /* 03719 if(ix%10==0 && iy%10==0) 03720 { 03721 std::cout << boost::format( "%4d %4d %4d " ) % ix % iy %iz; 03722 std::cout << boost::format( "%10.3f %10.3f %10.3f " ) % tmp % wght % sum; 03723 std:: << boost::format( "%10.3f %10.3e " ) % pow_b[r] % alpha; 03724 std::cout << std::endl; 03725 } 03726 */ 03727 tmp = tmp * wght; 03728 } 03729 (*m_volume)(2*ix,iy,iz) *= tmp; 03730 (*m_volume)(2*ix+1,iy,iz) *= tmp; 03731 } 03732 } 03733 } 03734 } 03735 03736 // back fft 03737 m_volume->do_ift_inplace(); 03738 int npad = m_volume->get_attr("npad"); 03739 m_volume->depad(); 03740 circumf_rect( m_volume, npad ); 03741 m_volume->set_array_offsets( 0, 0, 0 ); 03742 return 0; 03743 }
|
|
Get a clear, concise description of this class.
Implements EMAN::FactoryBase. Definition at line 1330 of file reconstructor.h. 01331 { 01332 return "Direct Fourier inversion reconstruction routine"; 01333 }
|
|
Get the unique name of this class (especially for factory based instantiation access).
Implements EMAN::FactoryBase. Definition at line 1325 of file reconstructor.h. 01326 {
01327 return NAME;
01328 }
|
|
Implements EMAN::FactoryBase. Definition at line 1341 of file reconstructor.h. References EMAN::TypeDict::put(). 01342 { 01343 TypeDict d; 01344 d.put("sizeprojection", EMObject::INT); 01345 d.put("sizex", EMObject::INT); 01346 d.put("sizey", EMObject::INT); 01347 d.put("sizez", EMObject::INT); 01348 d.put("xratio", EMObject::FLOAT); 01349 d.put("yratio", EMObject::FLOAT); 01350 d.put("zratio", EMObject::FLOAT); 01351 d.put("size", EMObject::INT); 01352 d.put("npad", EMObject::INT); 01353 d.put("sign", EMObject::INT); 01354 d.put("symmetry", EMObject::STRING); 01355 d.put("snr", EMObject::FLOAT); 01356 d.put("fftvol", EMObject::EMDATA); 01357 d.put("weight", EMObject::EMDATA); 01358 d.put("weighting", EMObject::INT); 01359 d.put("varsnr", EMObject::INT); 01360 return d; 01361 }
|
|
Definition at line 3605 of file reconstructor.cpp. References EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), m_volume, and m_wptr. 03606 { 03607 const float* bufdata = buffed->get_data(); 03608 float* cdata = m_volume->get_data(); 03609 float* wdata = m_wptr->get_data(); 03610 03611 int npoint = buffed->get_xsize()/4; 03612 for( int i=0; i < npoint; ++i ) { 03613 03614 int pos2 = int( bufdata[4*i] ); 03615 int pos1 = pos2 * 2; 03616 cdata[pos1 ] += bufdata[4*i+1]*mult; 03617 cdata[pos1+1] += bufdata[4*i+2]*mult; 03618 wdata[pos2 ] += bufdata[4*i+3]*mult; 03619 /* 03620 std::cout << "pos1, pos2, ctfv1, ctfv2, ctf2: "; 03621 std::cout << pos1 << " " << bufdata[5*i+1] << " " << bufdata[5*i+2] << " "; 03622 std::cout << pos2 << " " << bufdata[5*i+4] << std::endl; 03623 */ 03624 } 03625 return 0; 03626 }
|
|
Definition at line 3629 of file reconstructor.cpp. References Assert, EMAN::EMData::get_attr(), EMAN::Transform::get_sym_proj(), EMAN::EMData::insert_rect_slice_ctf(), EMAN::EMData::insert_rect_slice_ctf_applied(), m_npad, m_sizeofprojection, m_symmetry, m_volume, m_wptr, m_xratio, m_yratio, m_zratio, mult(), and t. 03630 { 03631 Assert( padfft != NULL ); 03632 float tmp = padfft->get_attr("ctf_applied"); 03633 int ctf_applied = (int) tmp; 03634 vector<Transform> tsym = t.get_sym_proj(m_symmetry); 03635 for (unsigned int isym=0; isym < tsym.size(); isym++) { 03636 if(ctf_applied) m_volume->insert_rect_slice_ctf_applied(m_wptr, padfft, tsym[isym], m_sizeofprojection, m_xratio,m_yratio, m_zratio, m_npad, mult); 03637 03638 else m_volume->insert_rect_slice_ctf(m_wptr, padfft, tsym[isym], m_sizeofprojection, m_xratio, m_yratio, m_zratio, m_npad, mult); 03639 03640 } 03641 03642 03643 return 0; 03644 03645 }
|
|
Insert a slice into a 3D volume, in a given orientation.
Reimplemented from EMAN::Reconstructor. |
|
Definition at line 1335 of file reconstructor.h. 01336 { 01337 return new nn4_ctf_rectReconstructor(); 01338 }
|
|
Definition at line 3478 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, m_yratio, and m_zratio. 03479 { 03480 m_weighting = ESTIMATE; 03481 if( params.has_key("weighting") ) { 03482 int tmp = int( params["weighting"] ); 03483 if( tmp==0 ) m_weighting = NONE; 03484 } 03485 03486 m_wghta = 0.2f; 03487 m_wghtb = 0.004f; 03488 03489 m_symmetry = symmetry; 03490 m_npad = npad; 03491 m_sign = sign; 03492 m_nsym = Transform::get_nsym(m_symmetry); 03493 03494 m_snr = snr; 03495 if (params.has_key("sizex")) m_vnx = params["sizex"]; 03496 else if (params.has_key("xratio")) { 03497 float temp=params["xratio"]; 03498 m_vnx=int(float(sizeprojection)*temp); 03499 } else m_vnx=sizeprojection; 03500 03501 if (params.has_key("sizey")) m_vny = params["sizey"]; 03502 else if (params.has_key("yratio")) { 03503 float temp=params["yratio"]; 03504 m_vny=int(float(sizeprojection)*temp); 03505 } 03506 else m_vny=sizeprojection; 03507 03508 if (params.has_key("sizez")) m_vnz = params["sizez"]; 03509 else if (params.has_key("zratio")) { 03510 float temp=params["zratio"]; 03511 m_vnz=int(float(sizeprojection)*temp); 03512 } 03513 else m_vnz=sizeprojection; 03514 03515 03516 m_xratio=float(m_vnx)/float(sizeprojection); 03517 m_yratio=float(m_vny)/float(sizeprojection); 03518 m_zratio=float(m_vnz)/float(sizeprojection); 03519 03520 //std::cout<<"xratio=="<<m_xratio<<"yratio=="<<m_yratio<<std::endl; 03521 //std::cout<<"sx=="<<m_vnx<<"sy=="<<m_vny<<"sz=="<<m_vnz<<std::endl; 03522 03523 m_vnxp = m_vnx*npad; 03524 m_vnyp = m_vny*npad; 03525 m_vnzp = m_vnz*npad; 03526 03527 m_vnxc = m_vnxp/2; 03528 m_vnyc = m_vnyp/2; 03529 m_vnzc = m_vnzp/2; 03530 03531 buildFFTVolume(); 03532 buildNormVolume(); 03533 }
|
|
Initialize the reconstructor.
Implements EMAN::Reconstructor. Definition at line 3462 of file reconstructor.cpp. References EMAN::Dict::has_key(), m_sizeofprojection, m_varsnr, and sign. Referenced by nn4_ctf_rectReconstructor(). 03463 { 03464 if( ! params.has_key("sizeprojection") ) throw std::logic_error("Error: projection size is not given"); 03465 m_sizeofprojection = params["sizeprojection"]; 03466 int npad = params.has_key("npad") ? int(params["npad"]) : 4; 03467 // int sign = params.has_key("sign") ? int(params["sign"]) : 1; 03468 int sign = 1; 03469 string symmetry = params.has_key("symmetry")? params["symmetry"].to_str() : "c1"; 03470 03471 float snr = params["snr"]; 03472 03473 m_varsnr = params.has_key("varsnr") ? int(params["varsnr"]) : 0; 03474 setup( symmetry, m_sizeofprojection, npad, snr, sign ); 03475 03476 }
|
|
Definition at line 1377 of file reconstructor.h. |
|
Definition at line 1380 of file reconstructor.h. Referenced by buildFFTVolume(), insert_padfft_slice(), and setup(). |
|
Definition at line 1387 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1381 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1379 of file reconstructor.h. Referenced by insert_padfft_slice(), and setup(). |
|
Definition at line 1385 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1386 of file reconstructor.h. Referenced by insert_padfft_slice(), and setup(). |
|
Definition at line 1382 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1374 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1376 of file reconstructor.h. Referenced by buildNormVolume(), and setup(). |
|
Definition at line 1375 of file reconstructor.h. Referenced by buildFFTVolume(), and setup(). |
|
Definition at line 1374 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1376 of file reconstructor.h. |
|
Definition at line 1375 of file reconstructor.h. Referenced by buildFFTVolume(), buildNormVolume(), finish(), and setup(). |
|
Definition at line 1374 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1376 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1375 of file reconstructor.h. Referenced by buildFFTVolume(), buildNormVolume(), finish(), and setup(). |
|
Definition at line 1372 of file reconstructor.h. Referenced by buildFFTVolume(), finish(), insert_buffed_slice(), insert_padfft_slice(), and nn4_ctf_rectReconstructor(). |
|
Definition at line 1383 of file reconstructor.h. |
|
Definition at line 1384 of file reconstructor.h. |
|
Definition at line 1384 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1373 of file reconstructor.h. Referenced by buildNormVolume(), finish(), insert_buffed_slice(), insert_padfft_slice(), and nn4_ctf_rectReconstructor(). |
|
Definition at line 1378 of file reconstructor.h. Referenced by finish(), insert_padfft_slice(), and setup(). |
|
Definition at line 1378 of file reconstructor.h. Referenced by finish(), insert_padfft_slice(), and setup(). |
|
Definition at line 1378 of file reconstructor.h. Referenced by finish(), insert_padfft_slice(), and setup(). |
|
Definition at line 86 of file reconstructor.cpp. |