#include <reconstructor.h>
Inheritance diagram for EMAN::nn4_ctfReconstructor:
Public Member Functions | |
nn4_ctfReconstructor () | |
nn4_ctfReconstructor (const string &symmetry, int size, int npad, float snr, int sign) | |
virtual | ~nn4_ctfReconstructor () |
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" |
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_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 1005 of file reconstructor.h.
|
Definition at line 3181 of file reconstructor.cpp. References m_result, m_volume, and m_wptr.
|
|
Definition at line 3188 of file reconstructor.cpp. 03189 { 03190 setup( symmetry, size, npad, snr, sign ); 03191 }
|
|
Definition at line 3193 of file reconstructor.cpp. References checked_delete(), m_result, m_volume, and m_wptr. 03194 { 03195 if( m_delete_volume ) checked_delete(m_volume); 03196 03197 if( m_delete_weight ) checked_delete( m_wptr ); 03198 03199 checked_delete( m_result ); 03200 }
|
|
|
Definition at line 3278 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(). 03279 { 03280 if( params.has_key("weight") ) { 03281 m_wptr = params["weight"]; 03282 m_delete_weight = false; 03283 } else { 03284 m_wptr = new EMData(); 03285 m_delete_weight = true; 03286 } 03287 03288 if( m_wptr->get_xsize() != m_vnxc+1 && m_wptr->get_ysize() != m_vnyp && m_wptr->get_zsize() != m_vnzp ) { 03289 m_wptr->set_size(m_vnxc+1,m_vnyp,m_vnzp); 03290 m_wptr->to_zero(); 03291 } 03292 03293 m_wptr->set_array_offsets(0,1,1); 03294 03295 }
|
|
Finish reconstruction and return the complete model.
Reimplemented from EMAN::Reconstructor. Definition at line 3376 of file reconstructor.cpp. References abs, circumf(), 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, max, max3d(), EMAN::EMData::set_array_offsets(), sqrt(), and EMAN::EMData::symplane0_ctf(). 03377 { 03378 m_volume->set_array_offsets(0, 1, 1); 03379 m_wptr->set_array_offsets(0, 1, 1); 03380 m_volume->symplane0_ctf(m_wptr); 03381 03382 int box = 7; 03383 int vol = box*box*box; 03384 int kc = (box-1)/2; 03385 vector< float > pow_a( 3*kc+1, 1.0 ); 03386 for( unsigned int i=1; i < pow_a.size(); ++i ) pow_a[i] = pow_a[i-1] * exp(m_wghta); 03387 pow_a[3*kc]=0.0; 03388 03389 03390 float max = max3d( kc, pow_a ); 03391 float alpha = ( 1.0f - 1.0f/(float)vol ) / max; 03392 float osnr = 1.0f/m_snr; 03393 03394 // normalize 03395 int ix,iy,iz; 03396 for (iz = 1; iz <= m_vnzp; iz++) { 03397 for (iy = 1; iy <= m_vnyp; iy++) { 03398 for (ix = 0; ix <= m_vnxc; ix++) { 03399 if ( (*m_wptr)(ix,iy,iz) > 0.0f) {//(*v) should be treated as complex!! 03400 int iyp = (iy<=m_vnyc) ? iy - 1 : iy-m_vnyp-1; 03401 int izp = (iz<=m_vnzc) ? iz - 1 : iz-m_vnzp-1; 03402 float tmp=0.0; 03403 if( m_varsnr ) 03404 { 03405 float freq = sqrt( (float)(ix*ix+iyp*iyp+izp*izp) ); 03406 tmp = (-2*((ix+iy+iz)%2)+1)/((*m_wptr)(ix,iy,iz)+freq*osnr)*m_sign; 03407 } 03408 else 03409 { 03410 tmp = (-2*((ix+iy+iz)%2)+1)/((*m_wptr)(ix,iy,iz)+osnr)*m_sign; 03411 } 03412 03413 if( m_weighting == ESTIMATE ) { 03414 int cx = ix; 03415 int cy = (iy<=m_vnyc) ? iy - 1 : iy - 1 - m_vnyp; 03416 int cz = (iz<=m_vnzc) ? iz - 1 : iz - 1 - m_vnzp; 03417 float sum = 0.0; 03418 for( int ii = -kc; ii <= kc; ++ii ) { 03419 int nbrcx = cx + ii; 03420 if( nbrcx >= m_vnxc ) continue; 03421 for( int jj= -kc; jj <= kc; ++jj ) { 03422 int nbrcy = cy + jj; 03423 if( nbrcy <= -m_vnyc || nbrcy >= m_vnyc ) continue; 03424 for( int kk = -kc; kk <= kc; ++kk ) { 03425 int nbrcz = cz + jj; 03426 if( nbrcz <= -m_vnyc || nbrcz >= m_vnyc ) continue; 03427 if( nbrcx < 0 ) { 03428 nbrcx = -nbrcx; 03429 nbrcy = -nbrcy; 03430 nbrcz = -nbrcz; 03431 } 03432 03433 int nbrix = nbrcx; 03434 int nbriy = nbrcy >= 0 ? nbrcy + 1 : nbrcy + 1 + m_vnyp; 03435 int nbriz = nbrcz >= 0 ? nbrcz + 1 : nbrcz + 1 + m_vnzp; 03436 if( (*m_wptr)( nbrix, nbriy, nbriz ) == 0.0 ) { 03437 int c = 3*kc+1 - std::abs(ii) - std::abs(jj) - std::abs(kk); 03438 sum = sum + pow_a[c]; 03439 // if(ix%20==0 && iy%20==0 && iz%20==0) 03440 // std::cout << boost::format( "%4d %4d %4d %4d %10.3f" ) % nbrix % nbriy % nbriz % c % sum << std::endl; 03441 } 03442 } 03443 } 03444 } 03445 float wght = 1.0f / ( 1.0f - alpha * sum ); 03446 /* 03447 if(ix%10==0 && iy%10==0) 03448 { 03449 std::cout << boost::format( "%4d %4d %4d " ) % ix % iy %iz; 03450 std::cout << boost::format( "%10.3f %10.3f %10.3f " ) % tmp % wght % sum; 03451 std:: << boost::format( "%10.3f %10.3e " ) % pow_b[r] % alpha; 03452 std::cout << std::endl; 03453 } 03454 */ 03455 tmp = tmp * wght; 03456 } 03457 (*m_volume)(2*ix,iy,iz) *= tmp; 03458 (*m_volume)(2*ix+1,iy,iz) *= tmp; 03459 } 03460 } 03461 } 03462 } 03463 03464 // back fft 03465 m_volume->do_ift_inplace(); 03466 int npad = m_volume->get_attr("npad"); 03467 m_volume->depad(); 03468 circumf( m_volume, npad ); 03469 m_volume->set_array_offsets( 0, 0, 0 ); 03470 m_result = m_volume->copy(); 03471 return m_result; 03472 }
|
|
Get a clear, concise description of this class.
Implements EMAN::FactoryBase. Definition at line 1034 of file reconstructor.h. 01035 { 01036 return "Direct Fourier inversion reconstruction routine"; 01037 }
|
|
Get the unique name of this class (especially for factory based instantiation access).
Implements EMAN::FactoryBase. Definition at line 1029 of file reconstructor.h. 01030 {
01031 return NAME;
01032 }
|
|
Implements EMAN::FactoryBase. Definition at line 1045 of file reconstructor.h. References EMAN::TypeDict::put(). 01046 { 01047 TypeDict d; 01048 d.put("size", EMObject::INT); 01049 d.put("npad", EMObject::INT); 01050 d.put("sign", EMObject::INT); 01051 d.put("symmetry", EMObject::STRING); 01052 d.put("snr", EMObject::FLOAT); 01053 d.put("fftvol", EMObject::EMDATA); 01054 d.put("weight", EMObject::EMDATA); 01055 d.put("weighting", EMObject::INT); 01056 d.put("varsnr", EMObject::INT); 01057 return d; 01058 }
|
|
Definition at line 3335 of file reconstructor.cpp. References EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), m_volume, and m_wptr. 03336 { 03337 const float* bufdata = buffed->get_data(); 03338 float* cdata = m_volume->get_data(); 03339 float* wdata = m_wptr->get_data(); 03340 03341 int npoint = buffed->get_xsize()/4; 03342 for( int i=0; i < npoint; ++i ) { 03343 03344 int pos2 = int( bufdata[4*i] ); 03345 int pos1 = pos2 * 2; 03346 cdata[pos1 ] += bufdata[4*i+1]*mult; 03347 cdata[pos1+1] += bufdata[4*i+2]*mult; 03348 wdata[pos2 ] += bufdata[4*i+3]*mult; 03349 /* 03350 std::cout << "pos1, pos2, ctfv1, ctfv2, ctf2: "; 03351 std::cout << pos1 << " " << bufdata[5*i+1] << " " << bufdata[5*i+2] << " "; 03352 std::cout << pos2 << " " << bufdata[5*i+4] << std::endl; 03353 */ 03354 } 03355 return 0; 03356 }
|
|
Definition at line 3358 of file reconstructor.cpp. References Assert, EMAN::EMData::get_attr(), EMAN::Transform::get_sym(), m_symmetry, m_volume, m_wptr, mult(), EMAN::EMData::nn_ctf(), EMAN::EMData::nn_ctf_applied(), and t. 03359 { 03360 Assert( padfft != NULL ); 03361 float tmp = padfft->get_attr("ctf_applied"); 03362 int ctf_applied = (int) tmp; 03363 for( int isym=0; isym < m_nsym; isym++) { 03364 Transform tsym = t.get_sym( m_symmetry, isym ); 03365 03366 if(ctf_applied) m_volume->nn_ctf_applied(m_wptr, padfft, tsym, mult); 03367 03368 else m_volume->nn_ctf(m_wptr, padfft, tsym, mult); 03369 } 03370 03371 return 0; 03372 03373 }
|
|
Insert a slice into a 3D volume, in a given orientation.
Reimplemented from EMAN::Reconstructor. |
|
Definition at line 1039 of file reconstructor.h. 01040 { 01041 return new nn4_ctfReconstructor(); 01042 }
|
|
Definition at line 3219 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, and m_wghtb. 03220 { 03221 m_weighting = ESTIMATE; 03222 if( params.has_key("weighting") ) { 03223 int tmp = int( params["weighting"] ); 03224 if( tmp==0 ) m_weighting = NONE; 03225 } 03226 03227 03228 03229 m_wghta = 0.2f; 03230 m_wghtb = 0.004f; 03231 03232 m_symmetry = symmetry; 03233 m_npad = npad; 03234 m_sign = sign; 03235 m_nsym = Transform::get_nsym(m_symmetry); 03236 03237 m_snr = snr; 03238 03239 m_vnx = size; 03240 m_vny = size; 03241 m_vnz = size; 03242 03243 m_vnxp = size*npad; 03244 m_vnyp = size*npad; 03245 m_vnzp = size*npad; 03246 03247 m_vnxc = m_vnxp/2; 03248 m_vnyc = m_vnyp/2; 03249 m_vnzc = m_vnzp/2; 03250 03251 buildFFTVolume(); 03252 buildNormVolume(); 03253 }
|
|
Initialize the reconstructor.
Implements EMAN::Reconstructor. Definition at line 3202 of file reconstructor.cpp. References EMAN::Dict::has_key(), m_varsnr, and sign. Referenced by nn4_ctfReconstructor(). 03203 { 03204 if( ! params.has_key("size") ) throw std::logic_error("Error: image size is not given"); 03205 03206 int size = params["size"]; 03207 int npad = params.has_key("npad") ? int(params["npad"]) : 4; 03208 // int sign = params.has_key("sign") ? int(params["sign"]) : 1; 03209 int sign = 1; 03210 string symmetry = params.has_key("symmetry")? params["symmetry"].to_str() : "c1"; 03211 03212 float snr = params["snr"]; 03213 03214 m_varsnr = params.has_key("varsnr") ? int(params["varsnr"]) : 0; 03215 setup( symmetry, size, npad, snr, sign ); 03216 03217 }
|
|
Definition at line 1072 of file reconstructor.h. Referenced by buildFFTVolume(). |
|
Definition at line 1073 of file reconstructor.h. Referenced by buildNormVolume(). |
|
Definition at line 1077 of file reconstructor.h. Referenced by buildFFTVolume(), and setup(). |
|
Definition at line 1084 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1070 of file reconstructor.h. Referenced by finish(), nn4_ctfReconstructor(), and ~nn4_ctfReconstructor(). |
|
Definition at line 1078 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1082 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1083 of file reconstructor.h. Referenced by insert_padfft_slice(), and setup(). |
|
Definition at line 1079 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1074 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1076 of file reconstructor.h. Referenced by buildNormVolume(), and setup(). |
|
Definition at line 1075 of file reconstructor.h. Referenced by buildFFTVolume(), and setup(). |
|
Definition at line 1074 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1076 of file reconstructor.h. |
|
Definition at line 1075 of file reconstructor.h. Referenced by buildFFTVolume(), buildNormVolume(), finish(), and setup(). |
|
Definition at line 1074 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1076 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1075 of file reconstructor.h. Referenced by buildFFTVolume(), buildNormVolume(), finish(), and setup(). |
|
Definition at line 1069 of file reconstructor.h. Referenced by buildFFTVolume(), finish(), insert_buffed_slice(), insert_padfft_slice(), nn4_ctfReconstructor(), and ~nn4_ctfReconstructor(). |
|
Definition at line 1080 of file reconstructor.h. |
|
Definition at line 1081 of file reconstructor.h. |
|
Definition at line 1081 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1071 of file reconstructor.h. Referenced by buildNormVolume(), finish(), insert_buffed_slice(), insert_padfft_slice(), nn4_ctfReconstructor(), and ~nn4_ctfReconstructor(). |
|
Definition at line 84 of file reconstructor.cpp. |