#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 3444 of file reconstructor.cpp. References m_volume, and m_wptr.
|
|
Definition at line 3450 of file reconstructor.cpp. 03451 { 03452 setup( symmetry, size, npad, snr, sign ); 03453 }
|
|
Definition at line 3455 of file reconstructor.cpp. 03456 { 03457 //if( m_delete_volume ) checked_delete(m_volume); 03458 03459 //if( m_delete_weight ) checked_delete( m_wptr ); 03460 03461 //checked_delete( m_result ); 03462 }
|
|
Definition at line 3537 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(). 03537 { 03538 int offset = 2 - m_vnxp%2; 03539 03540 m_volume = params["fftvol"]; 03541 03542 if( m_volume->get_xsize() != m_vnxp+offset && m_volume->get_ysize() != m_vnyp && m_volume->get_zsize() != m_vnzp ) { 03543 m_volume->set_size(m_vnxp+offset,m_vnyp,m_vnzp); 03544 m_volume->to_zero(); 03545 } 03546 03547 m_volume->set_nxc(m_vnxp/2); 03548 m_volume->set_complex(true); 03549 m_volume->set_ri(true); 03550 m_volume->set_fftpad(true); 03551 m_volume->set_attr("npad", m_npad); 03552 m_volume->set_array_offsets(0,1,1); 03553 }
|
|
Definition at line 3555 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(). 03556 { 03557 m_wptr = params["weight"]; 03558 03559 if( m_wptr->get_xsize() != m_vnxc+1 && m_wptr->get_ysize() != m_vnyp && m_wptr->get_zsize() != m_vnzp ) { 03560 m_wptr->set_size(m_vnxc+1,m_vnyp,m_vnzp); 03561 m_wptr->to_zero(); 03562 } 03563 03564 m_wptr->set_array_offsets(0,1,1); 03565 03566 }
|
|
Finish reconstruction and return the complete model.
Reimplemented from EMAN::Reconstructor. Definition at line 3650 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(). 03651 { 03652 m_volume->set_array_offsets(0, 1, 1); 03653 m_wptr->set_array_offsets(0, 1, 1); 03654 m_volume->symplane0_rect(m_wptr); 03655 03656 int box = 7; 03657 int vol = box*box*box; 03658 int kc = (box-1)/2; 03659 vector< float > pow_a( 3*kc+1, 1.0 ); 03660 for( unsigned int i=1; i < pow_a.size(); ++i ) pow_a[i] = pow_a[i-1] * exp(m_wghta); 03661 pow_a[3*kc]=0.0; 03662 03663 03664 float max = max3d( kc, pow_a ); 03665 float alpha = ( 1.0f - 1.0f/(float)vol ) / max; 03666 float osnr = 1.0f/m_snr; 03667 03668 // normalize 03669 int ix,iy,iz; 03670 for (iz = 1; iz <= m_vnzp; iz++) { 03671 for (iy = 1; iy <= m_vnyp; iy++) { 03672 for (ix = 0; ix <= m_vnxc; ix++) { 03673 if ( (*m_wptr)(ix,iy,iz) > 0.0f) {//(*v) should be treated as complex!! 03674 int iyp = (iy<=m_vnyc) ? iy - 1 : iy-m_vnyp-1; 03675 int izp = (iz<=m_vnzc) ? iz - 1 : iz-m_vnzp-1; 03676 float tmp=0.0; 03677 if( m_varsnr ) 03678 { 03679 float freq = sqrt( (float)(ix*ix/(m_xratio*m_xratio)+iyp*iyp/(m_zratio*m_yratio)+izp*izp) ); 03680 tmp = (-2*((ix+iy+iz)%2)+1)/((*m_wptr)(ix,iy,iz)+freq*osnr)*m_sign; 03681 } 03682 else 03683 { 03684 tmp = (-2*((ix+iy+iz)%2)+1)/((*m_wptr)(ix,iy,iz)+osnr)*m_sign; 03685 } 03686 03687 if( m_weighting == ESTIMATE ) { 03688 int cx = ix; 03689 int cy = (iy<=m_vnyc) ? iy - 1 : iy - 1 - m_vnyp; 03690 int cz = (iz<=m_vnzc) ? iz - 1 : iz - 1 - m_vnzp; 03691 float sum = 0.0; 03692 for( int ii = -kc; ii <= kc; ++ii ) { 03693 int nbrcx = cx + ii; 03694 if( nbrcx >= m_vnxc ) continue; 03695 for( int jj= -kc; jj <= kc; ++jj ) { 03696 int nbrcy = cy + jj; 03697 if( nbrcy <= -m_vnyc || nbrcy >= m_vnyc ) continue; 03698 for( int kk = -kc; kk <= kc; ++kk ) { 03699 int nbrcz = cz + jj; 03700 if( nbrcz <= -m_vnyc || nbrcz >= m_vnyc ) continue; 03701 if( nbrcx < 0 ) { 03702 nbrcx = -nbrcx; 03703 nbrcy = -nbrcy; 03704 nbrcz = -nbrcz; 03705 } 03706 03707 int nbrix = nbrcx; 03708 int nbriy = nbrcy >= 0 ? nbrcy + 1 : nbrcy + 1 + m_vnyp; 03709 int nbriz = nbrcz >= 0 ? nbrcz + 1 : nbrcz + 1 + m_vnzp; 03710 if( (*m_wptr)( nbrix, nbriy, nbriz ) == 0.0 ) { 03711 int c = 3*kc+1 - std::abs(ii) - std::abs(jj) - std::abs(kk); 03712 sum = sum + pow_a[c]; 03713 // if(ix%20==0 && iy%20==0 && iz%20==0) 03714 // std::cout << boost::format( "%4d %4d %4d %4d %10.3f" ) % nbrix % nbriy % nbriz % c % sum << std::endl; 03715 } 03716 } 03717 } 03718 } 03719 float wght = 1.0f / ( 1.0f - alpha * sum ); 03720 /* 03721 if(ix%10==0 && iy%10==0) 03722 { 03723 std::cout << boost::format( "%4d %4d %4d " ) % ix % iy %iz; 03724 std::cout << boost::format( "%10.3f %10.3f %10.3f " ) % tmp % wght % sum; 03725 std:: << boost::format( "%10.3f %10.3e " ) % pow_b[r] % alpha; 03726 std::cout << std::endl; 03727 } 03728 */ 03729 tmp = tmp * wght; 03730 } 03731 (*m_volume)(2*ix,iy,iz) *= tmp; 03732 (*m_volume)(2*ix+1,iy,iz) *= tmp; 03733 } 03734 } 03735 } 03736 } 03737 03738 // back fft 03739 m_volume->do_ift_inplace(); 03740 int npad = m_volume->get_attr("npad"); 03741 m_volume->depad(); 03742 circumf_rect( m_volume, npad ); 03743 m_volume->set_array_offsets( 0, 0, 0 ); 03744 return 0; 03745 }
|
|
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 3607 of file reconstructor.cpp. References EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), m_volume, and m_wptr. 03608 { 03609 const float* bufdata = buffed->get_data(); 03610 float* cdata = m_volume->get_data(); 03611 float* wdata = m_wptr->get_data(); 03612 03613 int npoint = buffed->get_xsize()/4; 03614 for( int i=0; i < npoint; ++i ) { 03615 03616 int pos2 = int( bufdata[4*i] ); 03617 int pos1 = pos2 * 2; 03618 cdata[pos1 ] += bufdata[4*i+1]*mult; 03619 cdata[pos1+1] += bufdata[4*i+2]*mult; 03620 wdata[pos2 ] += bufdata[4*i+3]*mult; 03621 /* 03622 std::cout << "pos1, pos2, ctfv1, ctfv2, ctf2: "; 03623 std::cout << pos1 << " " << bufdata[5*i+1] << " " << bufdata[5*i+2] << " "; 03624 std::cout << pos2 << " " << bufdata[5*i+4] << std::endl; 03625 */ 03626 } 03627 return 0; 03628 }
|
|
Definition at line 3631 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. 03632 { 03633 Assert( padfft != NULL ); 03634 float tmp = padfft->get_attr("ctf_applied"); 03635 int ctf_applied = (int) tmp; 03636 vector<Transform> tsym = t.get_sym_proj(m_symmetry); 03637 for (unsigned int isym=0; isym < tsym.size(); isym++) { 03638 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); 03639 03640 else m_volume->insert_rect_slice_ctf(m_wptr, padfft, tsym[isym], m_sizeofprojection, m_xratio, m_yratio, m_zratio, m_npad, mult); 03641 03642 } 03643 03644 03645 return 0; 03646 03647 }
|
|
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 3480 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. 03481 { 03482 m_weighting = ESTIMATE; 03483 if( params.has_key("weighting") ) { 03484 int tmp = int( params["weighting"] ); 03485 if( tmp==0 ) m_weighting = NONE; 03486 } 03487 03488 m_wghta = 0.2f; 03489 m_wghtb = 0.004f; 03490 03491 m_symmetry = symmetry; 03492 m_npad = npad; 03493 m_sign = sign; 03494 m_nsym = Transform::get_nsym(m_symmetry); 03495 03496 m_snr = snr; 03497 if (params.has_key("sizex")) m_vnx = params["sizex"]; 03498 else if (params.has_key("xratio")) { 03499 float temp=params["xratio"]; 03500 m_vnx=int(float(sizeprojection)*temp); 03501 } else m_vnx=sizeprojection; 03502 03503 if (params.has_key("sizey")) m_vny = params["sizey"]; 03504 else if (params.has_key("yratio")) { 03505 float temp=params["yratio"]; 03506 m_vny=int(float(sizeprojection)*temp); 03507 } 03508 else m_vny=sizeprojection; 03509 03510 if (params.has_key("sizez")) m_vnz = params["sizez"]; 03511 else if (params.has_key("zratio")) { 03512 float temp=params["zratio"]; 03513 m_vnz=int(float(sizeprojection)*temp); 03514 } 03515 else m_vnz=sizeprojection; 03516 03517 03518 m_xratio=float(m_vnx)/float(sizeprojection); 03519 m_yratio=float(m_vny)/float(sizeprojection); 03520 m_zratio=float(m_vnz)/float(sizeprojection); 03521 03522 //std::cout<<"xratio=="<<m_xratio<<"yratio=="<<m_yratio<<std::endl; 03523 //std::cout<<"sx=="<<m_vnx<<"sy=="<<m_vny<<"sz=="<<m_vnz<<std::endl; 03524 03525 m_vnxp = m_vnx*npad; 03526 m_vnyp = m_vny*npad; 03527 m_vnzp = m_vnz*npad; 03528 03529 m_vnxc = m_vnxp/2; 03530 m_vnyc = m_vnyp/2; 03531 m_vnzc = m_vnzp/2; 03532 03533 buildFFTVolume(); 03534 buildNormVolume(); 03535 }
|
|
Initialize the reconstructor.
Implements EMAN::Reconstructor. Definition at line 3464 of file reconstructor.cpp. References EMAN::Dict::has_key(), m_sizeofprojection, m_varsnr, and sign. Referenced by nn4_ctf_rectReconstructor(). 03465 { 03466 if( ! params.has_key("sizeprojection") ) throw std::logic_error("Error: projection size is not given"); 03467 m_sizeofprojection = params["sizeprojection"]; 03468 int npad = params.has_key("npad") ? int(params["npad"]) : 4; 03469 // int sign = params.has_key("sign") ? int(params["sign"]) : 1; 03470 int sign = 1; 03471 string symmetry = params.has_key("symmetry")? params["symmetry"].to_str() : "c1"; 03472 03473 float snr = params["snr"]; 03474 03475 m_varsnr = params.has_key("varsnr") ? int(params["varsnr"]) : 0; 03476 setup( symmetry, m_sizeofprojection, npad, snr, sign ); 03477 03478 }
|
|
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. |