#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 1086 of file reconstructor.h.
|
Definition at line 3379 of file reconstructor.cpp. References m_result, m_volume, and m_wptr.
|
|
Definition at line 3386 of file reconstructor.cpp. 03387 { 03388 setup( symmetry, size, npad, snr, sign ); 03389 }
|
|
Definition at line 3391 of file reconstructor.cpp. References checked_delete(), m_result, m_volume, and m_wptr. 03392 { 03393 if( m_delete_volume ) checked_delete(m_volume); 03394 03395 if( m_delete_weight ) checked_delete( m_wptr ); 03396 03397 checked_delete( m_result ); 03398 }
|
|
|
Definition at line 3497 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(). 03498 { 03499 if( params.has_key("weight") ) { 03500 m_wptr = params["weight"]; 03501 m_delete_weight = false; 03502 } else { 03503 m_wptr = new EMData(); 03504 m_delete_weight = true; 03505 } 03506 03507 if( m_wptr->get_xsize() != m_vnxc+1 && m_wptr->get_ysize() != m_vnyp && m_wptr->get_zsize() != m_vnzp ) { 03508 m_wptr->set_size(m_vnxc+1,m_vnyp,m_vnzp); 03509 m_wptr->to_zero(); 03510 } 03511 03512 m_wptr->set_array_offsets(0,1,1); 03513 03514 }
|
|
Finish reconstruction and return the complete model.
Reimplemented from EMAN::Reconstructor. Definition at line 3595 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(). 03596 { 03597 m_volume->set_array_offsets(0, 1, 1); 03598 m_wptr->set_array_offsets(0, 1, 1); 03599 m_volume->symplane0_rect(m_wptr); 03600 03601 int box = 7; 03602 int vol = box*box*box; 03603 int kc = (box-1)/2; 03604 vector< float > pow_a( 3*kc+1, 1.0 ); 03605 for( unsigned int i=1; i < pow_a.size(); ++i ) pow_a[i] = pow_a[i-1] * exp(m_wghta); 03606 pow_a[3*kc]=0.0; 03607 03608 03609 float max = max3d( kc, pow_a ); 03610 float alpha = ( 1.0f - 1.0f/(float)vol ) / max; 03611 float osnr = 1.0f/m_snr; 03612 03613 // normalize 03614 int ix,iy,iz; 03615 for (iz = 1; iz <= m_vnzp; iz++) { 03616 for (iy = 1; iy <= m_vnyp; iy++) { 03617 for (ix = 0; ix <= m_vnxc; ix++) { 03618 if ( (*m_wptr)(ix,iy,iz) > 0.0f) {//(*v) should be treated as complex!! 03619 int iyp = (iy<=m_vnyc) ? iy - 1 : iy-m_vnyp-1; 03620 int izp = (iz<=m_vnzc) ? iz - 1 : iz-m_vnzp-1; 03621 float tmp=0.0; 03622 if( m_varsnr ) 03623 { 03624 float freq = sqrt( (float)(ix*ix/(m_xratio*m_xratio)+iyp*iyp/(m_zratio*m_yratio)+izp*izp) ); 03625 tmp = (-2*((ix+iy+iz)%2)+1)/((*m_wptr)(ix,iy,iz)+freq*osnr)*m_sign; 03626 } 03627 else 03628 { 03629 tmp = (-2*((ix+iy+iz)%2)+1)/((*m_wptr)(ix,iy,iz)+osnr)*m_sign; 03630 } 03631 03632 if( m_weighting == ESTIMATE ) { 03633 int cx = ix; 03634 int cy = (iy<=m_vnyc) ? iy - 1 : iy - 1 - m_vnyp; 03635 int cz = (iz<=m_vnzc) ? iz - 1 : iz - 1 - m_vnzp; 03636 float sum = 0.0; 03637 for( int ii = -kc; ii <= kc; ++ii ) { 03638 int nbrcx = cx + ii; 03639 if( nbrcx >= m_vnxc ) continue; 03640 for( int jj= -kc; jj <= kc; ++jj ) { 03641 int nbrcy = cy + jj; 03642 if( nbrcy <= -m_vnyc || nbrcy >= m_vnyc ) continue; 03643 for( int kk = -kc; kk <= kc; ++kk ) { 03644 int nbrcz = cz + jj; 03645 if( nbrcz <= -m_vnyc || nbrcz >= m_vnyc ) continue; 03646 if( nbrcx < 0 ) { 03647 nbrcx = -nbrcx; 03648 nbrcy = -nbrcy; 03649 nbrcz = -nbrcz; 03650 } 03651 03652 int nbrix = nbrcx; 03653 int nbriy = nbrcy >= 0 ? nbrcy + 1 : nbrcy + 1 + m_vnyp; 03654 int nbriz = nbrcz >= 0 ? nbrcz + 1 : nbrcz + 1 + m_vnzp; 03655 if( (*m_wptr)( nbrix, nbriy, nbriz ) == 0.0 ) { 03656 int c = 3*kc+1 - std::abs(ii) - std::abs(jj) - std::abs(kk); 03657 sum = sum + pow_a[c]; 03658 // if(ix%20==0 && iy%20==0 && iz%20==0) 03659 // std::cout << boost::format( "%4d %4d %4d %4d %10.3f" ) % nbrix % nbriy % nbriz % c % sum << std::endl; 03660 } 03661 } 03662 } 03663 } 03664 float wght = 1.0f / ( 1.0f - alpha * sum ); 03665 /* 03666 if(ix%10==0 && iy%10==0) 03667 { 03668 std::cout << boost::format( "%4d %4d %4d " ) % ix % iy %iz; 03669 std::cout << boost::format( "%10.3f %10.3f %10.3f " ) % tmp % wght % sum; 03670 std:: << boost::format( "%10.3f %10.3e " ) % pow_b[r] % alpha; 03671 std::cout << std::endl; 03672 } 03673 */ 03674 tmp = tmp * wght; 03675 } 03676 (*m_volume)(2*ix,iy,iz) *= tmp; 03677 (*m_volume)(2*ix+1,iy,iz) *= tmp; 03678 } 03679 } 03680 } 03681 } 03682 03683 // back fft 03684 m_volume->do_ift_inplace(); 03685 int npad = m_volume->get_attr("npad"); 03686 m_volume->depad(); 03687 circumf_rect( m_volume, npad ); 03688 m_volume->set_array_offsets( 0, 0, 0 ); 03689 m_result = m_volume->copy(); 03690 return m_result; 03691 }
|
|
Get a clear, concise description of this class.
Implements EMAN::FactoryBase. Definition at line 1115 of file reconstructor.h. 01116 { 01117 return "Direct Fourier inversion reconstruction routine"; 01118 }
|
|
Get the unique name of this class (especially for factory based instantiation access).
Implements EMAN::FactoryBase. Definition at line 1110 of file reconstructor.h. 01111 {
01112 return NAME;
01113 }
|
|
Implements EMAN::FactoryBase. Definition at line 1126 of file reconstructor.h. References EMAN::TypeDict::put(). 01127 { 01128 TypeDict d; 01129 d.put("sizeprojection", EMObject::INT); 01130 d.put("sizex", EMObject::INT); 01131 d.put("sizey", EMObject::INT); 01132 d.put("sizez", EMObject::INT); 01133 d.put("xratio", EMObject::FLOAT); 01134 d.put("yratio", EMObject::FLOAT); 01135 d.put("size", EMObject::INT); 01136 d.put("npad", EMObject::INT); 01137 d.put("sign", EMObject::INT); 01138 d.put("symmetry", EMObject::STRING); 01139 d.put("snr", EMObject::FLOAT); 01140 d.put("fftvol", EMObject::EMDATA); 01141 d.put("weight", EMObject::EMDATA); 01142 d.put("weighting", EMObject::INT); 01143 d.put("varsnr", EMObject::INT); 01144 return d; 01145 }
|
|
Definition at line 3555 of file reconstructor.cpp. References EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), m_volume, and m_wptr. Referenced by insert_slice(). 03556 { 03557 const float* bufdata = buffed->get_data(); 03558 float* cdata = m_volume->get_data(); 03559 float* wdata = m_wptr->get_data(); 03560 03561 int npoint = buffed->get_xsize()/4; 03562 for( int i=0; i < npoint; ++i ) { 03563 03564 int pos2 = int( bufdata[4*i] ); 03565 int pos1 = pos2 * 2; 03566 cdata[pos1 ] += bufdata[4*i+1]*mult; 03567 cdata[pos1+1] += bufdata[4*i+2]*mult; 03568 wdata[pos2 ] += bufdata[4*i+3]*mult; 03569 /* 03570 std::cout << "pos1, pos2, ctfv1, ctfv2, ctf2: "; 03571 std::cout << pos1 << " " << bufdata[5*i+1] << " " << bufdata[5*i+2] << " "; 03572 std::cout << pos2 << " " << bufdata[5*i+4] << std::endl; 03573 */ 03574 } 03575 return 0; 03576 }
|
|
Definition at line 3579 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. Referenced by insert_slice(). 03580 { 03581 Assert( padfft != NULL ); 03582 float tmp = padfft->get_attr("ctf_applied"); 03583 int ctf_applied = (int) tmp; 03584 03585 if (ctf_applied) m_volume->insert_rect_slice_ctf_applied(m_wptr, padfft, t, m_sizeofprojection, m_xratio,m_yratio, m_npad, mult); 03586 else m_volume->insert_rect_slice_ctf(m_wptr, padfft, t, m_sizeofprojection, m_xratio, m_yratio, m_npad, mult); 03587 03588 03589 03590 return 0; 03591 03592 }
|
|
Insert a slice into a 3D volume, in a given orientation.
Reimplemented from EMAN::Reconstructor. Definition at line 3516 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, mult(), EMAN::padfft_slice(), and t. 03517 { 03518 // sanity checks 03519 if (!slice) { 03520 LOGERR("try to insert NULL slice"); 03521 return 1; 03522 } 03523 03524 int buffed = slice->get_attr_default( "buffed", 0 ); 03525 if( buffed > 0 ) { 03526 int mult = slice->get_attr_default( "mult", 1 ); 03527 insert_buffed_slice( slice, mult ); 03528 return 0; 03529 } 03530 03531 int padffted= slice->get_attr_default("padffted", 0); 03532 //if( padffted==0 && (slice->get_xsize()!=slice->get_ysize() || slice->get_xsize()!=m_vnx) ) 03533 if( padffted==0 && (slice->get_xsize()!=slice->get_ysize()) ) 03534 { 03535 // FIXME: Why doesn't this throw an exception? 03536 LOGERR("Tried to insert a slice that is the wrong size."); 03537 return 1; 03538 } 03539 03540 EMData* padfft = NULL; 03541 03542 if( padffted != 0 ) padfft = new EMData(*slice); 03543 else padfft = padfft_slice( slice, t, m_npad ); 03544 03545 int mult= slice->get_attr_default("mult", 1); 03546 03547 Assert( mult > 0 ); 03548 insert_padfft_slice( padfft, t, mult ); 03549 03550 checked_delete( padfft ); 03551 03552 return 0; 03553 }
|
|
Definition at line 1120 of file reconstructor.h. 01121 { 01122 return new nn4_ctf_rectReconstructor(); 01123 }
|
|
Definition at line 3416 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. 03417 { 03418 m_weighting = ESTIMATE; 03419 if( params.has_key("weighting") ) { 03420 int tmp = int( params["weighting"] ); 03421 if( tmp==0 ) m_weighting = NONE; 03422 } 03423 03424 03425 03426 m_wghta = 0.2f; 03427 m_wghtb = 0.004f; 03428 03429 m_symmetry = symmetry; 03430 m_npad = npad; 03431 m_sign = sign; 03432 m_nsym = Transform::get_nsym(m_symmetry); 03433 03434 m_snr = snr; 03435 if( params.has_key("sizex") ) m_vnx = params["sizex"]; 03436 else if(params.has_key("xratio")) 03437 { 03438 float temp=params["xratio"]; 03439 m_vnx=int(float(sizeprojection)*temp); 03440 } 03441 else m_vnx=sizeprojection; 03442 03443 if( params.has_key("sizey") ) m_vny = params["sizey"]; 03444 else if (params.has_key("yratio")) 03445 { 03446 float temp=params["yratio"]; 03447 m_vny=int(float(sizeprojection)*temp); 03448 } 03449 else m_vny=sizeprojection; 03450 03451 if( params.has_key("sizez") ) 03452 m_vnz = params["sizez"]; 03453 else 03454 m_vnz =sizeprojection; 03455 03456 m_xratio=float(m_vnx)/float(sizeprojection); 03457 m_yratio=float(m_vny)/float(sizeprojection); 03458 03459 //std::cout<<"xratio=="<<m_xratio<<"yratio=="<<m_yratio<<std::endl; 03460 //std::cout<<"sx=="<<m_vnx<<"sy=="<<m_vny<<"sz=="<<m_vnz<<std::endl; 03461 03462 m_vnxp = m_vnx*npad; 03463 m_vnyp = m_vny*npad; 03464 m_vnzp = m_vnz*npad; 03465 03466 m_vnxc = m_vnxp/2; 03467 m_vnyc = m_vnyp/2; 03468 m_vnzc = m_vnzp/2; 03469 03470 buildFFTVolume(); 03471 buildNormVolume(); 03472 }
|
|
Initialize the reconstructor.
Implements EMAN::Reconstructor. Definition at line 3400 of file reconstructor.cpp. References EMAN::Dict::has_key(), m_sizeofprojection, m_varsnr, and sign. Referenced by nn4_ctf_rectReconstructor(). 03401 { 03402 if( ! params.has_key("sizeprojection") ) throw std::logic_error("Error: projection size is not given"); 03403 m_sizeofprojection = params["sizeprojection"]; 03404 int npad = params.has_key("npad") ? int(params["npad"]) : 4; 03405 // int sign = params.has_key("sign") ? int(params["sign"]) : 1; 03406 int sign = 1; 03407 string symmetry = params.has_key("symmetry")? params["symmetry"].to_str() : "c1"; 03408 03409 float snr = params["snr"]; 03410 03411 m_varsnr = params.has_key("varsnr") ? int(params["varsnr"]) : 0; 03412 setup( symmetry, m_sizeofprojection, npad, snr, sign ); 03413 03414 }
|
|
Definition at line 1164 of file reconstructor.h. |
|
Definition at line 1159 of file reconstructor.h. Referenced by buildFFTVolume(). |
|
Definition at line 1160 of file reconstructor.h. Referenced by buildNormVolume(). |
|
Definition at line 1168 of file reconstructor.h. Referenced by buildFFTVolume(), insert_padfft_slice(), insert_slice(), and setup(). |
|
Definition at line 1175 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1157 of file reconstructor.h. Referenced by finish(), nn4_ctf_rectReconstructor(), and ~nn4_ctf_rectReconstructor(). |
|
Definition at line 1169 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1167 of file reconstructor.h. Referenced by insert_padfft_slice(), and setup(). |
|
Definition at line 1173 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1174 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1170 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1161 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1163 of file reconstructor.h. Referenced by buildNormVolume(), and setup(). |
|
Definition at line 1162 of file reconstructor.h. Referenced by buildFFTVolume(), and setup(). |
|
Definition at line 1161 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1163 of file reconstructor.h. |
|
Definition at line 1162 of file reconstructor.h. Referenced by buildFFTVolume(), buildNormVolume(), finish(), and setup(). |
|
Definition at line 1161 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1163 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1162 of file reconstructor.h. Referenced by buildFFTVolume(), buildNormVolume(), finish(), and setup(). |
|
Definition at line 1156 of file reconstructor.h. Referenced by buildFFTVolume(), finish(), insert_buffed_slice(), insert_padfft_slice(), nn4_ctf_rectReconstructor(), and ~nn4_ctf_rectReconstructor(). |
|
Definition at line 1171 of file reconstructor.h. |
|
Definition at line 1172 of file reconstructor.h. |
|
Definition at line 1172 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1158 of file reconstructor.h. Referenced by buildNormVolume(), finish(), insert_buffed_slice(), insert_padfft_slice(), nn4_ctf_rectReconstructor(), and ~nn4_ctf_rectReconstructor(). |
|
Definition at line 1165 of file reconstructor.h. Referenced by finish(), insert_padfft_slice(), and setup(). |
|
Definition at line 1166 of file reconstructor.h. |
|
Definition at line 1165 of file reconstructor.h. Referenced by finish(), insert_padfft_slice(), and setup(). |
|
Definition at line 1166 of file reconstructor.h. |
|
Definition at line 1165 of file reconstructor.h. Referenced by finish(). |
|
Definition at line 81 of file reconstructor.cpp. |