#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 996 of file reconstructor.h.
|
Definition at line 3079 of file reconstructor.cpp. References m_result, m_volume, and m_wptr.
|
|
Definition at line 3086 of file reconstructor.cpp. 03087 { 03088 setup( symmetry, size, npad, snr, sign ); 03089 }
|
|
Definition at line 3091 of file reconstructor.cpp. References checked_delete(), m_result, m_volume, and m_wptr. 03092 { 03093 if( m_delete_volume ) checked_delete(m_volume); 03094 03095 if( m_delete_weight ) checked_delete( m_wptr ); 03096 03097 checked_delete( m_result ); 03098 }
|
|
|
Definition at line 3176 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(). 03177 { 03178 if( params.has_key("weight") ) { 03179 m_wptr = params["weight"]; 03180 m_delete_weight = false; 03181 } else { 03182 m_wptr = new EMData(); 03183 m_delete_weight = true; 03184 } 03185 03186 if( m_wptr->get_xsize() != m_vnxc+1 && m_wptr->get_ysize() != m_vnyp && m_wptr->get_zsize() != m_vnzp ) { 03187 m_wptr->set_size(m_vnxc+1,m_vnyp,m_vnzp); 03188 m_wptr->to_zero(); 03189 } 03190 03191 m_wptr->set_array_offsets(0,1,1); 03192 03193 }
|
|
Finish reconstruction and return the complete model.
Reimplemented from EMAN::Reconstructor. Definition at line 3275 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(). 03276 { 03277 m_volume->set_array_offsets(0, 1, 1); 03278 m_wptr->set_array_offsets(0, 1, 1); 03279 m_volume->symplane0_ctf(m_wptr); 03280 03281 int box = 7; 03282 int vol = box*box*box; 03283 int kc = (box-1)/2; 03284 vector< float > pow_a( 3*kc+1, 1.0 ); 03285 for( unsigned int i=1; i < pow_a.size(); ++i ) pow_a[i] = pow_a[i-1] * exp(m_wghta); 03286 pow_a[3*kc]=0.0; 03287 03288 03289 float max = max3d( kc, pow_a ); 03290 float alpha = ( 1.0f - 1.0f/(float)vol ) / max; 03291 float osnr = 1.0f/m_snr; 03292 03293 // normalize 03294 int ix,iy,iz; 03295 for (iz = 1; iz <= m_vnzp; iz++) { 03296 for (iy = 1; iy <= m_vnyp; iy++) { 03297 for (ix = 0; ix <= m_vnxc; ix++) { 03298 if ( (*m_wptr)(ix,iy,iz) > 0.0f) {//(*v) should be treated as complex!! 03299 int iyp = (iy<=m_vnyc) ? iy - 1 : iy-m_vnyp-1; 03300 int izp = (iz<=m_vnzc) ? iz - 1 : iz-m_vnzp-1; 03301 float tmp=0.0; 03302 if( m_varsnr ) 03303 { 03304 float freq = sqrt( (float)(ix*ix+iyp*iyp+izp*izp) ); 03305 tmp = (-2*((ix+iy+iz)%2)+1)/((*m_wptr)(ix,iy,iz)+freq*osnr)*m_sign; 03306 } 03307 else 03308 { 03309 tmp = (-2*((ix+iy+iz)%2)+1)/((*m_wptr)(ix,iy,iz)+osnr)*m_sign; 03310 } 03311 03312 if( m_weighting == ESTIMATE ) { 03313 int cx = ix; 03314 int cy = (iy<=m_vnyc) ? iy - 1 : iy - 1 - m_vnyp; 03315 int cz = (iz<=m_vnzc) ? iz - 1 : iz - 1 - m_vnzp; 03316 float sum = 0.0; 03317 for( int ii = -kc; ii <= kc; ++ii ) { 03318 int nbrcx = cx + ii; 03319 if( nbrcx >= m_vnxc ) continue; 03320 for( int jj= -kc; jj <= kc; ++jj ) { 03321 int nbrcy = cy + jj; 03322 if( nbrcy <= -m_vnyc || nbrcy >= m_vnyc ) continue; 03323 for( int kk = -kc; kk <= kc; ++kk ) { 03324 int nbrcz = cz + jj; 03325 if( nbrcz <= -m_vnyc || nbrcz >= m_vnyc ) continue; 03326 if( nbrcx < 0 ) { 03327 nbrcx = -nbrcx; 03328 nbrcy = -nbrcy; 03329 nbrcz = -nbrcz; 03330 } 03331 03332 int nbrix = nbrcx; 03333 int nbriy = nbrcy >= 0 ? nbrcy + 1 : nbrcy + 1 + m_vnyp; 03334 int nbriz = nbrcz >= 0 ? nbrcz + 1 : nbrcz + 1 + m_vnzp; 03335 if( (*m_wptr)( nbrix, nbriy, nbriz ) == 0.0 ) { 03336 int c = 3*kc+1 - std::abs(ii) - std::abs(jj) - std::abs(kk); 03337 sum = sum + pow_a[c]; 03338 // if(ix%20==0 && iy%20==0 && iz%20==0) 03339 // std::cout << boost::format( "%4d %4d %4d %4d %10.3f" ) % nbrix % nbriy % nbriz % c % sum << std::endl; 03340 } 03341 } 03342 } 03343 } 03344 float wght = 1.0f / ( 1.0f - alpha * sum ); 03345 /* 03346 if(ix%10==0 && iy%10==0) 03347 { 03348 std::cout << boost::format( "%4d %4d %4d " ) % ix % iy %iz; 03349 std::cout << boost::format( "%10.3f %10.3f %10.3f " ) % tmp % wght % sum; 03350 std:: << boost::format( "%10.3f %10.3e " ) % pow_b[r] % alpha; 03351 std::cout << std::endl; 03352 } 03353 */ 03354 tmp = tmp * wght; 03355 } 03356 (*m_volume)(2*ix,iy,iz) *= tmp; 03357 (*m_volume)(2*ix+1,iy,iz) *= tmp; 03358 } 03359 } 03360 } 03361 } 03362 03363 // back fft 03364 m_volume->do_ift_inplace(); 03365 int npad = m_volume->get_attr("npad"); 03366 m_volume->depad(); 03367 circumf( m_volume, npad ); 03368 m_volume->set_array_offsets( 0, 0, 0 ); 03369 m_result = m_volume->copy(); 03370 return m_result; 03371 }
|
|
Get a clear, concise description of this class.
Implements EMAN::FactoryBase. Definition at line 1025 of file reconstructor.h. 01026 { 01027 return "Direct Fourier inversion reconstruction routine"; 01028 }
|
|
Get the unique name of this class (especially for factory based instantiation access).
Implements EMAN::FactoryBase. Definition at line 1020 of file reconstructor.h. 01021 {
01022 return NAME;
01023 }
|
|
Implements EMAN::FactoryBase. Definition at line 1036 of file reconstructor.h. References EMAN::TypeDict::put(). 01037 { 01038 TypeDict d; 01039 d.put("size", EMObject::INT); 01040 d.put("npad", EMObject::INT); 01041 d.put("sign", EMObject::INT); 01042 d.put("symmetry", EMObject::STRING); 01043 d.put("snr", EMObject::FLOAT); 01044 d.put("fftvol", EMObject::EMDATA); 01045 d.put("weight", EMObject::EMDATA); 01046 d.put("weighting", EMObject::INT); 01047 d.put("varsnr", EMObject::INT); 01048 return d; 01049 }
|
|
Definition at line 3233 of file reconstructor.cpp. References EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), m_volume, and m_wptr. Referenced by insert_slice(). 03234 { 03235 const float* bufdata = buffed->get_data(); 03236 float* cdata = m_volume->get_data(); 03237 float* wdata = m_wptr->get_data(); 03238 03239 int npoint = buffed->get_xsize()/4; 03240 for( int i=0; i < npoint; ++i ) { 03241 03242 int pos2 = int( bufdata[4*i] ); 03243 int pos1 = pos2 * 2; 03244 cdata[pos1 ] += bufdata[4*i+1]*mult; 03245 cdata[pos1+1] += bufdata[4*i+2]*mult; 03246 wdata[pos2 ] += bufdata[4*i+3]*mult; 03247 /* 03248 std::cout << "pos1, pos2, ctfv1, ctfv2, ctf2: "; 03249 std::cout << pos1 << " " << bufdata[5*i+1] << " " << bufdata[5*i+2] << " "; 03250 std::cout << pos2 << " " << bufdata[5*i+4] << std::endl; 03251 */ 03252 } 03253 return 0; 03254 }
|
|
Definition at line 3256 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. Referenced by insert_slice(). 03257 { 03258 Assert( padfft != NULL ); 03259 float tmp = padfft->get_attr("ctf_applied"); 03260 int ctf_applied = (int) tmp; 03261 03262 for( int isym=0; isym < m_nsym; isym++) { 03263 Transform tsym = t.get_sym( m_symmetry, isym ); 03264 03265 if(ctf_applied) m_volume->nn_ctf_applied(m_wptr, padfft, tsym, mult); 03266 03267 else m_volume->nn_ctf(m_wptr, padfft, tsym, mult); 03268 } 03269 03270 return 0; 03271 03272 }
|
|
Insert a slice into a 3D volume, in a given orientation.
Reimplemented from EMAN::Reconstructor. Definition at line 3195 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. 03196 { 03197 // sanity checks 03198 if (!slice) { 03199 LOGERR("try to insert NULL slice"); 03200 return 1; 03201 } 03202 03203 int buffed = slice->get_attr_default( "buffed", 0 ); 03204 if( buffed > 0 ) { 03205 int mult = slice->get_attr_default( "mult", 1 ); 03206 insert_buffed_slice( slice, mult ); 03207 return 0; 03208 } 03209 03210 int padffted= slice->get_attr_default("padffted", 0); 03211 if( padffted==0 && (slice->get_xsize()!=slice->get_ysize() || slice->get_xsize()!=m_vnx) ) 03212 { 03213 // FIXME: Why doesn't this throw an exception? 03214 LOGERR("Tried to insert a slice that is the wrong size."); 03215 return 1; 03216 } 03217 03218 EMData* padfft = NULL; 03219 03220 if( padffted != 0 ) padfft = new EMData(*slice); 03221 else padfft = padfft_slice( slice, t, m_npad ); 03222 03223 int mult= slice->get_attr_default("mult", 1); 03224 03225 Assert( mult > 0 ); 03226 insert_padfft_slice( padfft, t, mult ); 03227 03228 checked_delete( padfft ); 03229 03230 return 0; 03231 }
|
|
Definition at line 1030 of file reconstructor.h. 01031 { 01032 return new nn4_ctfReconstructor(); 01033 }
|
|
Definition at line 3117 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. 03118 { 03119 m_weighting = ESTIMATE; 03120 if( params.has_key("weighting") ) { 03121 int tmp = int( params["weighting"] ); 03122 if( tmp==0 ) m_weighting = NONE; 03123 } 03124 03125 03126 03127 m_wghta = 0.2f; 03128 m_wghtb = 0.004f; 03129 03130 m_symmetry = symmetry; 03131 m_npad = npad; 03132 m_sign = sign; 03133 m_nsym = Transform::get_nsym(m_symmetry); 03134 03135 m_snr = snr; 03136 03137 m_vnx = size; 03138 m_vny = size; 03139 m_vnz = size; 03140 03141 m_vnxp = size*npad; 03142 m_vnyp = size*npad; 03143 m_vnzp = size*npad; 03144 03145 m_vnxc = m_vnxp/2; 03146 m_vnyc = m_vnyp/2; 03147 m_vnzc = m_vnzp/2; 03148 03149 buildFFTVolume(); 03150 buildNormVolume(); 03151 }
|
|
Initialize the reconstructor.
Implements EMAN::Reconstructor. Definition at line 3100 of file reconstructor.cpp. References EMAN::Dict::has_key(), m_varsnr, and sign. Referenced by nn4_ctfReconstructor(). 03101 { 03102 if( ! params.has_key("size") ) throw std::logic_error("Error: image size is not given"); 03103 03104 int size = params["size"]; 03105 int npad = params.has_key("npad") ? int(params["npad"]) : 4; 03106 // int sign = params.has_key("sign") ? int(params["sign"]) : 1; 03107 int sign = 1; 03108 string symmetry = params.has_key("symmetry")? params["symmetry"].to_str() : "c1"; 03109 03110 float snr = params["snr"]; 03111 03112 m_varsnr = params.has_key("varsnr") ? int(params["varsnr"]) : 0; 03113 setup( symmetry, size, npad, snr, sign ); 03114 03115 }
|
|
Definition at line 1063 of file reconstructor.h. Referenced by buildFFTVolume(). |
|
Definition at line 1064 of file reconstructor.h. Referenced by buildNormVolume(). |
|
Definition at line 1068 of file reconstructor.h. Referenced by buildFFTVolume(), insert_slice(), and setup(). |
|
Definition at line 1075 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1061 of file reconstructor.h. Referenced by finish(), nn4_ctfReconstructor(), and ~nn4_ctfReconstructor(). |
|
Definition at line 1069 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1073 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1074 of file reconstructor.h. Referenced by insert_padfft_slice(), and setup(). |
|
Definition at line 1070 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1065 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1067 of file reconstructor.h. Referenced by buildNormVolume(), and setup(). |
|
Definition at line 1066 of file reconstructor.h. Referenced by buildFFTVolume(), and setup(). |
|
Definition at line 1065 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1067 of file reconstructor.h. |
|
Definition at line 1066 of file reconstructor.h. Referenced by buildFFTVolume(), buildNormVolume(), finish(), and setup(). |
|
Definition at line 1065 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1067 of file reconstructor.h. Referenced by setup(). |
|
Definition at line 1066 of file reconstructor.h. Referenced by buildFFTVolume(), buildNormVolume(), finish(), and setup(). |
|
Definition at line 1060 of file reconstructor.h. Referenced by buildFFTVolume(), finish(), insert_buffed_slice(), insert_padfft_slice(), nn4_ctfReconstructor(), and ~nn4_ctfReconstructor(). |
|
Definition at line 1071 of file reconstructor.h. |
|
Definition at line 1072 of file reconstructor.h. |
|
Definition at line 1072 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(), nn4_ctfReconstructor(), and ~nn4_ctfReconstructor(). |
|
Definition at line 80 of file reconstructor.cpp. |