#include <reconstructor.h>
Inheritance diagram for EMAN::nn4Reconstructor:


Public Member Functions | |
| nn4Reconstructor () | |
| nn4Reconstructor (const string &symmetry, int size, int npad) | |
| virtual | ~nn4Reconstructor () |
| virtual void | setup () |
| Initialize the reconstructor. | |
| virtual int | insert_slice (const EMData *const slice, const Transform &euler, const float weight=1.0) |
| Insert an image slice to the reconstructor. | |
| 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. | |
| virtual TypeDict | get_param_types () const |
| void | setup (const string &symmetry, int size, int npad) |
| int | insert_padfft_slice (EMData *padded, const Transform &trans, int mult=1) |
Static Public Member Functions | |
| Reconstructor * | NEW () |
Static Public Attributes | |
| const string | NAME = "nn4" |
Private Member Functions | |
| void | buildFFTVolume () |
| void | buildNormVolume () |
| void | load_default_settings () |
Private Attributes | |
| EMData * | m_volume |
| EMData * | m_wptr |
| string | m_symmetry |
| int | m_weighting |
| int | m_vnx |
| int | m_vny |
| int | m_vnz |
| int | m_npad |
| int | m_nsym |
| int | m_ndim |
| int | m_vnzp |
| int | m_vnyp |
| int | m_vnxp |
| int | m_vnzc |
| int | m_vnyc |
| int | m_vnxc |
| float | m_wghta |
| float | m_wghtb |
| float | m_osnr |
|
|
Definition at line 1980 of file reconstructor.cpp. References m_volume, and m_wptr.
|
|
||||||||||||||||
|
Definition at line 1986 of file reconstructor.cpp. References load_default_settings(), m_volume, m_wptr, EMAN::Reconstructor::print_params(), and setup(). 01987 {
01988 m_volume = NULL;
01989 m_wptr = NULL;
01990 setup( symmetry, size, npad );
01991 load_default_settings();
01992 print_params();
01993 }
|
|
|
Definition at line 1995 of file reconstructor.cpp. 01996 {
01997 //if( m_delete_volume ) checked_delete(m_volume);
01998
01999 //if( m_delete_weight ) checked_delete( m_wptr );
02000
02001 //checked_delete( m_result );
02002 }
|
|
|
Definition at line 2088 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_fftodd(), EMAN::EMData::set_fftpad(), EMAN::EMData::set_nxc(), EMAN::EMData::set_ri(), EMAN::EMData::set_size(), and EMAN::EMData::to_zero(). Referenced by setup(). 02088 {
02089 int offset = 2 - m_vnxp%2;
02090
02091 m_volume = params["fftvol"];
02092
02093 if( m_volume->get_xsize() != m_vnxp+offset && m_volume->get_ysize() != m_vnyp && m_volume->get_zsize() != m_vnzp ) {
02094 m_volume->set_size(m_vnxp+offset,m_vnyp,m_vnzp);
02095 m_volume->to_zero();
02096 }
02097 // ----------------------------------------------------------------
02098 // Added by Zhengfan Yang on 03/15/07
02099 // Original author: please check whether my revision is correct and
02100 // other Reconstructor need similiar revision.
02101 if ( m_vnxp % 2 == 0 ) m_volume->set_fftodd(0);
02102 else m_volume->set_fftodd(1);
02103 // ----------------------------------------------------------------
02104
02105 m_volume->set_nxc(m_vnxp/2);
02106 m_volume->set_complex(true);
02107 m_volume->set_ri(true);
02108 m_volume->set_fftpad(true);
02109 m_volume->set_attr("npad", m_npad);
02110 m_volume->set_array_offsets(0,1,1);
02111 }
|
|
|
Definition at line 2113 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(). 02113 {
02114
02115 m_wptr = params["weight"];
02116
02117 if( m_wptr->get_xsize() != m_vnxc+1 &&
02118 m_wptr->get_ysize() != m_vnyp &&
02119 m_wptr->get_zsize() != m_vnzp ) {
02120 m_wptr->set_size(m_vnxc+1,m_vnyp,m_vnzp);
02121 m_wptr->to_zero();
02122 }
02123 m_wptr->set_array_offsets(0,1,1);
02124 }
|
|
|
Finish reconstruction and return the complete model.
Reimplemented from EMAN::Reconstructor. Definition at line 2294 of file reconstructor.cpp. References abs, circumf(), EMAN::EMData::depad(), EMAN::EMData::do_ift_inplace(), EMAN::EMData::get_attr(), m_ndim, m_vnyc, m_vnyp, m_volume, m_weighting, m_wghta, m_wptr, max, max2d(), max3d(), EMAN::EMData::set_array_offsets(), and EMAN::EMData::symplane0(). 02294 {
02295
02296 if( m_ndim==3 ) {
02297 m_volume->symplane0(m_wptr);
02298 } else {
02299 for( int i=1; i <= m_vnyp; ++i ) {
02300
02301 if( (*m_wptr)(0, i, 1)==0.0 ) {
02302 int j = m_vnyp + 1 - i;
02303 (*m_wptr)(0, i, 1) = (*m_wptr)(0, j, 1);
02304 (*m_volume)(0, i, 1) = (*m_volume)(0, j, 1);
02305 (*m_volume)(1, i, 1) = (*m_volume)(1, j, 1);
02306 }
02307 }
02308 }
02309
02310
02311 int box = 7;
02312 int kc = (box-1)/2;
02313 vector< float > pow_a( m_ndim*kc+1, 1.0 );
02314 for( unsigned int i=1; i < pow_a.size(); ++i ) pow_a[i] = pow_a[i-1] * exp(m_wghta);
02315 pow_a.back()=0.0;
02316
02317 float alpha = 0.0;
02318 if( m_ndim==3) {
02319 int vol = box*box*box;
02320 float max = max3d( kc, pow_a );
02321 alpha = ( 1.0f - 1.0f/(float)vol ) / max;
02322 } else {
02323 int ara = box*box;
02324 float max = max2d( kc, pow_a );
02325 alpha = ( 1.0f - 1.0f/(float)ara ) / max;
02326 }
02327
02328 int ix,iy,iz;
02329 for (iz = 1; iz <= m_vnzp; iz++) {
02330 for (iy = 1; iy <= m_vnyp; iy++) {
02331 for (ix = 0; ix <= m_vnxc; ix++) {
02332 if ( (*m_wptr)(ix,iy,iz) > 0) {//(*v) should be treated as complex!!
02333 float tmp;
02334 tmp = (-2*((ix+iy+iz)%2)+1)/((*m_wptr)(ix,iy,iz)+m_osnr);
02335
02336 if( m_weighting == ESTIMATE ) {
02337 int cx = ix;
02338 int cy = (iy<=m_vnyc) ? iy - 1 : iy - 1 - m_vnyp;
02339 int cz = (iz<=m_vnzc) ? iz - 1 : iz - 1 - m_vnzp;
02340 float sum = 0.0;
02341 for( int ii = -kc; ii <= kc; ++ii ) {
02342 int nbrcx = cx + ii;
02343 if( nbrcx >= m_vnxc ) continue;
02344 for( int jj= -kc; jj <= kc; ++jj ) {
02345 int nbrcy = cy + jj;
02346 if( nbrcy <= -m_vnyc || nbrcy >= m_vnyc ) continue;
02347
02348 int kcz = (m_ndim==3) ? kc : 0;
02349 for( int kk = -kcz; kk <= kcz; ++kk ) {
02350 int nbrcz = cz + kk;
02351 if( nbrcz <= -m_vnyc || nbrcz >= m_vnyc ) continue;
02352 if( nbrcx < 0 ) {
02353 nbrcx = -nbrcx;
02354 nbrcy = -nbrcy;
02355 nbrcz = -nbrcz;
02356 }
02357 int nbrix = nbrcx;
02358 int nbriy = nbrcy >= 0 ? nbrcy + 1 : nbrcy + 1 + m_vnyp;
02359 int nbriz = nbrcz >= 0 ? nbrcz + 1 : nbrcz + 1 + m_vnzp;
02360 if( (*m_wptr)( nbrix, nbriy, nbriz ) == 0 ) {
02361 int c = m_ndim*kc+1 - std::abs(ii) - std::abs(jj) - std::abs(kk);
02362 sum = sum + pow_a[c];
02363 }
02364 }
02365 }
02366 }
02367 float wght = 1.0f / ( 1.0f - alpha * sum );
02368 tmp = tmp * wght;
02369 }
02370 (*m_volume)(2*ix,iy,iz) *= tmp;
02371 (*m_volume)(2*ix+1,iy,iz) *= tmp;
02372 }
02373 }
02374 }
02375 }
02376
02377 //if(m_ndim==2) printImage( m_volume );
02378
02379 // back fft
02380 m_volume->do_ift_inplace();
02381
02382 // EMData* win = m_volume->window_center(m_vnx);
02383 int npad = m_volume->get_attr("npad");
02384 m_volume->depad();
02385 circumf( m_volume, npad );
02386 m_volume->set_array_offsets( 0, 0, 0 );
02387
02388 return 0;
02389 }
|
|
|
Get a clear, concise description of this class.
Implements EMAN::FactoryBase. Definition at line 759 of file reconstructor.h. 00760 {
00761 return "Direct Fourier inversion routine";
00762 }
|
|
|
Get the unique name of this class (especially for factory based instantiation access).
Implements EMAN::FactoryBase. Definition at line 754 of file reconstructor.h. 00755 {
00756 return NAME;
00757 }
|
|
|
Implements EMAN::FactoryBase. Definition at line 769 of file reconstructor.h. References EMAN::TypeDict::put(). 00770 {
00771 TypeDict d;
00772 d.put("size", EMObject::INT);
00773 d.put("npad", EMObject::INT);
00774 d.put("sign", EMObject::INT);
00775 d.put("ndim", EMObject::INT);
00776 d.put("snr", EMObject::FLOAT);
00777 d.put("symmetry", EMObject::STRING);
00778 d.put("snr", EMObject::FLOAT);
00779 d.put("fftvol", EMObject::EMDATA);
00780 d.put("weight", EMObject::EMDATA);
00781 d.put("weighting", EMObject::INT);
00782 return d;
00783 }
|
|
||||||||||||||||
|
Definition at line 2202 of file reconstructor.cpp. References Assert, EMAN::Transform::get_sym_proj(), m_symmetry, m_volume, m_wptr, mult(), EMAN::EMData::nn(), and t. 02203 {
02204 Assert( padfft != NULL );
02205
02206 vector<Transform> tsym = t.get_sym_proj(m_symmetry);
02207 for (unsigned int isym=0; isym < tsym.size(); isym++) {
02208 m_volume->nn( m_wptr, padfft, tsym[isym], mult);
02209 }
02210
02211 /*for (int isym=0; isym < m_nsym; isym++) {
02212 Transform tsym = t.get_sym(m_symmetry, isym);
02213 m_volume->nn( m_wptr, padfft, tsym, mult);
02214 }*/
02215 return 0;
02216 }
|
|
||||||||||||||||
|
Insert an image slice to the reconstructor. To insert multiple image slices, call this function multiple times.
Reimplemented from EMAN::Reconstructor. |
|
|
Definition at line 807 of file reconstructor.h. Referenced by nn4Reconstructor(). 00808 {
00809 //params["use_weights"] = false;
00810 }
|
|
|
Definition at line 764 of file reconstructor.h. 00765 {
00766 return new nn4Reconstructor();
00767 }
|
|
||||||||||||||||
|
Definition at line 2061 of file reconstructor.cpp. References buildFFTVolume(), buildNormVolume(), EMAN::Transform::get_nsym(), m_ndim, m_npad, m_nsym, m_symmetry, m_vnx, m_vnxc, m_vnxp, m_vny, m_vnyc, m_vnyp, m_vnz, m_vnzc, m_vnzp, m_weighting, and m_wghta. 02062 {
02063 m_weighting = ESTIMATE;
02064 m_wghta = 0.2f;
02065
02066 m_symmetry = symmetry;
02067 m_npad = npad;
02068 m_nsym = Transform::get_nsym(m_symmetry);
02069
02070 m_vnx = size;
02071 m_vny = size;
02072 m_vnz = (m_ndim==3) ? size : 1;
02073
02074 m_vnxp = size*npad;
02075 m_vnyp = size*npad;
02076 m_vnzp = (m_ndim==3) ? size*npad : 1;
02077
02078 m_vnxc = m_vnxp/2;
02079 m_vnyc = m_vnyp/2;
02080 m_vnzc = (m_ndim==3) ? m_vnzp/2 : 1;
02081
02082 buildFFTVolume();
02083 buildNormVolume();
02084
02085 }
|
|
|
Initialize the reconstructor.
Implements EMAN::Reconstructor. Definition at line 2042 of file reconstructor.cpp. References EMAN::Dict::has_key(), m_ndim, and m_osnr. Referenced by nn4Reconstructor(). 02043 {
02044 int size = params["size"];
02045 int npad = params["npad"];
02046
02047
02048 string symmetry;
02049 if( params.has_key("symmetry") ) symmetry = params["symmetry"].to_str();
02050 else symmetry = "c1";
02051
02052 if( params.has_key("ndim") ) m_ndim = params["ndim"];
02053 else m_ndim = 3;
02054
02055 if( params.has_key( "snr" ) ) m_osnr = 1.0f/float( params["snr"] );
02056 else m_osnr = 0.0;
02057
02058 setup( symmetry, size, npad );
02059 }
|
|
|
Definition at line 799 of file reconstructor.h. |
|
|
Definition at line 797 of file reconstructor.h. Referenced by buildFFTVolume(), and setup(). |
|
|
Definition at line 798 of file reconstructor.h. Referenced by setup(). |
|
|
Definition at line 806 of file reconstructor.h. Referenced by setup(). |
|
|
Definition at line 794 of file reconstructor.h. Referenced by insert_padfft_slice(), and setup(). |
|
|
Definition at line 796 of file reconstructor.h. Referenced by setup(). |
|
|
Definition at line 801 of file reconstructor.h. Referenced by buildNormVolume(), and setup(). |
|
|
Definition at line 800 of file reconstructor.h. Referenced by buildFFTVolume(), and setup(). |
|
|
Definition at line 796 of file reconstructor.h. Referenced by setup(). |
|
|
Definition at line 801 of file reconstructor.h. |
|
|
Definition at line 800 of file reconstructor.h. Referenced by buildFFTVolume(), buildNormVolume(), finish(), and setup(). |
|
|
Definition at line 796 of file reconstructor.h. Referenced by setup(). |
|
|
Definition at line 801 of file reconstructor.h. Referenced by setup(). |
|
|
Definition at line 800 of file reconstructor.h. Referenced by buildFFTVolume(), buildNormVolume(), and setup(). |
|
|
Definition at line 792 of file reconstructor.h. Referenced by buildFFTVolume(), finish(), insert_padfft_slice(), and nn4Reconstructor(). |
|
|
Definition at line 795 of file reconstructor.h. |
|
|
Definition at line 804 of file reconstructor.h. |
|
|
Definition at line 805 of file reconstructor.h. |
|
|
Definition at line 793 of file reconstructor.h. Referenced by buildNormVolume(), finish(), insert_padfft_slice(), and nn4Reconstructor(). |
|
|
Definition at line 81 of file reconstructor.cpp. |
1.3.9.1