#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_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_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 997 of file reconstructor.h.
|
Definition at line 3135 of file reconstructor.cpp. References m_volume, and m_wptr.
|
|
Definition at line 3141 of file reconstructor.cpp. 03142 { 03143 setup( symmetry, size, npad, snr, sign ); 03144 }
|
|
Definition at line 3146 of file reconstructor.cpp. 03147 { 03148 //if( m_delete_volume ) checked_delete(m_volume); 03149 03150 //if( m_delete_weight ) checked_delete( m_wptr ); 03151 03152 //checked_delete( m_result ); 03153 }
|
|
Definition at line 3208 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(). 03208 { 03209 int offset = 2 - m_vnxp%2; 03210 03211 m_volume = params["fftvol"]; 03212 03213 if( m_volume->get_xsize() != m_vnxp+offset && m_volume->get_ysize() != m_vnyp && m_volume->get_zsize() != m_vnzp ) { 03214 m_volume->set_size(m_vnxp+offset,m_vnyp,m_vnzp); 03215 m_volume->to_zero(); 03216 } 03217 03218 m_volume->set_nxc(m_vnxp/2); 03219 m_volume->set_complex(true); 03220 m_volume->set_ri(true); 03221 m_volume->set_fftpad(true); 03222 m_volume->set_attr("npad", m_npad); 03223 m_volume->set_array_offsets(0,1,1); 03224 }
|
|
Definition at line 3226 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(). 03227 { 03228 m_wptr = params["weight"]; 03229 03230 if( m_wptr->get_xsize() != m_vnxc+1 && m_wptr->get_ysize() != m_vnyp && m_wptr->get_zsize() != m_vnzp ) { 03231 m_wptr->set_size(m_vnxc+1,m_vnyp,m_vnzp); 03232 m_wptr->to_zero(); 03233 } 03234 03235 m_wptr->set_array_offsets(0,1,1); 03236 03237 }
|
|
Finish reconstruction and return the complete model.
Reimplemented from EMAN::Reconstructor. Definition at line 3320 of file reconstructor.cpp. References abs, circumf(), 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, max, max3d(), EMAN::EMData::set_array_offsets(), sqrt(), and EMAN::EMData::symplane0_ctf(). 03321 { 03322 m_volume->set_array_offsets(0, 1, 1); 03323 m_wptr->set_array_offsets(0, 1, 1); 03324 m_volume->symplane0_ctf(m_wptr); 03325 03326 int box = 7; 03327 int vol = box*box*box; 03328 int kc = (box-1)/2; 03329 vector< float > pow_a( 3*kc+1, 1.0 ); 03330 for( unsigned int i=1; i < pow_a.size(); ++i ) pow_a[i] = pow_a[i-1] * exp(m_wghta); 03331 pow_a[3*kc]=0.0; 03332 03333 03334 float max = max3d( kc, pow_a ); 03335 float alpha = ( 1.0f - 1.0f/(float)vol ) / max; 03336 float osnr = 1.0f/m_snr; 03337 03338 // normalize 03339 int ix,iy,iz; 03340 for (iz = 1; iz <= m_vnzp; iz++) { 03341 for (iy = 1; iy <= m_vnyp; iy++) { 03342 for (ix = 0; ix <= m_vnxc; ix++) { 03343 if ( (*m_wptr)(ix,iy,iz) > 0.0f) {//(*v) should be treated as complex!! 03344 int iyp = (iy<=m_vnyc) ? iy - 1 : iy-m_vnyp-1; 03345 int izp = (iz<=m_vnzc) ? iz - 1 : iz-m_vnzp-1; 03346 float tmp=0.0; 03347 if( m_varsnr ) 03348 { 03349 float freq = sqrt( (float)(ix*ix+iyp*iyp+izp*izp) ); 03350 tmp = (-2*((ix+iy+iz)%2)+1)/((*m_wptr)(ix,iy,iz)+freq*osnr)*m_sign; 03351 } 03352 else 03353 { 03354 tmp = (-2*((ix+iy+iz)%2)+1)/((*m_wptr)(ix,iy,iz)+osnr)*m_sign; 03355 } 03356 03357 if( m_weighting == ESTIMATE ) { 03358 int cx = ix; 03359 int cy = (iy<=m_vnyc) ? iy - 1 : iy - 1 - m_vnyp; 03360 int cz = (iz<=m_vnzc) ? iz - 1 : iz - 1 - m_vnzp; 03361 float sum = 0.0; 03362 for( int ii = -kc; ii <= kc; ++ii ) { 03363 int nbrcx = cx + ii; 03364 if( nbrcx >= m_vnxc ) continue; 03365 for( int jj= -kc; jj <= kc; ++jj ) { 03366 int nbrcy = cy + jj; 03367 if( nbrcy <= -m_vnyc || nbrcy >= m_vnyc ) continue; 03368 for( int kk = -kc; kk <= kc; ++kk ) { 03369 int nbrcz = cz + jj; 03370 if( nbrcz <= -m_vnyc || nbrcz >= m_vnyc ) continue; 03371 if( nbrcx < 0 ) { 03372 nbrcx = -nbrcx; 03373 nbrcy = -nbrcy; 03374 nbrcz = -nbrcz; 03375 } 03376 03377 int nbrix = nbrcx; 03378 int nbriy = nbrcy >= 0 ? nbrcy + 1 : nbrcy + 1 + m_vnyp; 03379 int nbriz = nbrcz >= 0 ? nbrcz + 1 : nbrcz + 1 + m_vnzp; 03380 if( (*m_wptr)( nbrix, nbriy, nbriz ) == 0.0 ) { 03381 int c = 3*kc+1 - std::abs(ii) - std::abs(jj) - std::abs(kk); 03382 sum = sum + pow_a[c]; 03383 // if(ix%20==0 && iy%20==0 && iz%20==0) 03384 // std::cout << boost::format( "%4d %4d %4d %4d %10.3f" ) % nbrix % nbriy % nbriz % c % sum << std::endl; 03385 } 03386 } 03387 } 03388 } 03389 float wght = 1.0f / ( 1.0f - alpha * sum ); 03390 /* 03391 if(ix%10==0 && iy%10==0) 03392 { 03393 std::cout << boost::format( "%4d %4d %4d " ) % ix % iy %iz; 03394 std::cout << boost::format( "%10.3f %10.3f %10.3f " ) % tmp % wght % sum; 03395 std:: << boost::format( "%10.3f %10.3e " ) % pow_b[r] % alpha; 03396 std::cout << std::endl; 03397 } 03398 */ 03399 tmp = tmp * wght; 03400 } 03401 (*m_volume)(2*ix,iy,iz) *= tmp; 03402 (*m_volume)(2*ix+1,iy,iz) *= tmp; 03403 } 03404 } 03405 } 03406 } 03407 03408 // back fft 03409 m_volume->do_ift_inplace(); 03410 int npad = m_volume->get_attr("npad"); 03411 m_volume->depad(); 03412 circumf( m_volume, npad ); 03413 m_volume->set_array_offsets( 0, 0, 0 ); 03414 03415 return 0; 03416 }
|
|
Get a clear, concise description of this class.
Implements EMAN::FactoryBase. Definition at line 1026 of file reconstructor.h. 01027 { 01028 return "Direct Fourier inversion reconstruction routine"; 01029 }
|
|
Get the unique name of this class (especially for factory based instantiation access).
Implements EMAN::FactoryBase. Definition at line 1021 of file reconstructor.h. 01022 {
01023 return NAME;
01024 }
|
|
Implements EMAN::FactoryBase. Definition at line 1037 of file reconstructor.h. References EMAN::TypeDict::put(). 01038 { 01039 TypeDict d; 01040 d.put("size", EMObject::INT); 01041 d.put("npad", EMObject::INT); 01042 d.put("sign", EMObject::INT); 01043 d.put("symmetry", EMObject::STRING); 01044 d.put("snr", EMObject::FLOAT); 01045 d.put("fftvol", EMObject::EMDATA); 01046 d.put("weight", EMObject::EMDATA); 01047 d.put("weighting", EMObject::INT); 01048 d.put("varsnr", EMObject::INT); 01049 return d; 01050 }
|
|
Definition at line 3277 of file reconstructor.cpp. References EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), m_volume, and m_wptr. 03278 { 03279 const float* bufdata = buffed->get_data(); 03280 float* cdata = m_volume->get_data(); 03281 float* wdata = m_wptr->get_data(); 03282 03283 int npoint = buffed->get_xsize()/4; 03284 for( int i=0; i < npoint; ++i ) { 03285 03286 int pos2 = int( bufdata[4*i] ); 03287 int pos1 = pos2 * 2; 03288 cdata[pos1 ] += bufdata[4*i+1]*mult; 03289 cdata[pos1+1] += bufdata[4*i+2]*mult; 03290 wdata[pos2 ] += bufdata[4*i+3]*mult; 03291 /* 03292 std::cout << "pos1, pos2, ctfv1, ctfv2, ctf2: "; 03293 std::cout << pos1 << " " << bufdata[5*i+1] << " " << bufdata[5*i+2] << " "; 03294 std::cout << pos2 << " " << bufdata[5*i+4] << std::endl; 03295 */ 03296 } 03297 return 0; 03298 }
|
|
Definition at line 3300 of file reconstructor.cpp. References Assert, EMAN::EMData::get_attr(), EMAN::Transform::get_sym_proj(), m_symmetry, m_volume, m_wptr, mult(), EMAN::EMData::nn_ctf(), EMAN::EMData::nn_ctf_applied(), and t. 03301 { 03302 Assert( padfft != NULL ); 03303 float tmp = padfft->get_attr("ctf_applied"); 03304 int ctf_applied = (int) tmp; 03305 03306 vector<Transform> tsym = t.get_sym_proj(m_symmetry); 03307 for (unsigned int isym=0; isym < tsym.size(); isym++) { 03308 if(ctf_applied) m_volume->nn_ctf_applied(m_wptr, padfft, tsym[isym], mult); 03309 03310 else m_volume->nn_ctf(m_wptr, padfft, tsym[isym], mult); 03311 03312 } 03313 03314 03315 return 0; 03316 03317 }
|
|
Insert a slice into a 3D volume, in a given orientation.
Reimplemented from EMAN::Reconstructor. |
|
Definition at line 1031 of file reconstructor.h. 01032 { 01033 return new nn4_ctfReconstructor(); 01034 }
|
|
Definition at line 3172 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. 03173 { 03174 m_weighting = ESTIMATE; 03175 if( params.has_key("weighting") ) { 03176 int tmp = int( params["weighting"] ); 03177 if( tmp==0 ) m_weighting = NONE; 03178 } 03179 03180 03181 03182 m_wghta = 0.2f; 03183 m_wghtb = 0.004f; 03184 03185 m_symmetry = symmetry; 03186 m_npad = npad; 03187 m_sign = sign; 03188 m_nsym = Transform::get_nsym(m_symmetry); 03189 03190 m_snr = snr; 03191 03192 m_vnx = size; 03193 m_vny = size; 03194 m_vnz = size; 03195 03196 m_vnxp = size*npad; 03197 m_vnyp = size*npad; 03198 m_vnzp = size*npad; 03199 03200 m_vnxc = m_vnxp/2; 03201 m_vnyc = m_vnyp/2; 03202 m_vnzc = m_vnzp/2; 03203 03204 buildFFTVolume(); 03205 buildNormVolume(); 03206 }
|
|
Initialize the reconstructor.
Implements EMAN::Reconstructor. Definition at line 3155 of file reconstructor.cpp. References EMAN::Dict::has_key(), m_varsnr, and sign. Referenced by nn4_ctfReconstructor(). 03156 { 03157 if( ! params.has_key("size") ) throw std::logic_error("Error: image size is not given"); 03158 03159 int size = params["size"]; 03160 int npad = params.has_key("npad") ? int(params["npad"]) : 4; 03161 // int sign = params.has_key("sign") ? int(params["sign"]) : 1; 03162 int sign = 1; 03163 string symmetry = params.has_key("symmetry")? params["symmetry"].to_str() : "c1"; 03164 03165 float snr = params["snr"]; 03166 03167 m_varsnr = params.has_key("varsnr") ? int(params["varsnr"]) : 0; 03168 setup( symmetry, size, npad, snr, sign ); 03169 03170 }
|
|
Definition at line 1066 of file reconstructor.h. Referenced by buildFFTVolume(), and setup(). |
|
Definition at line 1073 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1067 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1071 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1072 of file reconstructor.h. Referenced by insert_padfft_slice(), and setup(). |
|
Definition at line 1068 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1063 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1065 of file reconstructor.h. Referenced by buildNormVolume(), and setup(). |
|
Definition at line 1064 of file reconstructor.h. Referenced by buildFFTVolume(), and setup(). |
|
Definition at line 1063 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1065 of file reconstructor.h. |
|
Definition at line 1064 of file reconstructor.h. Referenced by buildFFTVolume(), buildNormVolume(), finish(), and setup(). |
|
Definition at line 1063 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1065 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1064 of file reconstructor.h. Referenced by buildFFTVolume(), buildNormVolume(), finish(), and setup(). |
|
Definition at line 1061 of file reconstructor.h. Referenced by buildFFTVolume(), finish(), insert_buffed_slice(), insert_padfft_slice(), and nn4_ctfReconstructor(). |
|
Definition at line 1069 of file reconstructor.h. |
|
Definition at line 1070 of file reconstructor.h. |
|
Definition at line 1070 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1062 of file reconstructor.h. Referenced by buildNormVolume(), finish(), insert_buffed_slice(), insert_padfft_slice(), and nn4_ctfReconstructor(). |
|
Definition at line 84 of file reconstructor.cpp. |