#include <averager.h>


Public Member Functions | |
| CtfCWautoAverager () | |
| void | add_image (EMData *image) |
| To add an image to the Averager. | |
| EMData * | finish () |
| Finish up the averaging and return the result. | |
| string | get_name () const |
| Get the Averager's name. | |
| string | get_desc () const |
| void | set_params (const Dict &new_params) |
| Set the Averager parameters using a key/value dictionary. | |
Static Public Member Functions | |
| static Averager * | NEW () |
Protected Attributes | |
| EMData * | snrsum |
| int | nimg |
The Weiner filter is estimated directly from the data.
Definition at line 413 of file averager.h.
| CtfCWautoAverager::CtfCWautoAverager | ( | ) |
Definition at line 463 of file averager.cpp.
Referenced by NEW().
00464 : nimg(0) 00465 { 00466 00467 }
| void CtfCWautoAverager::add_image | ( | EMData * | image | ) | [virtual] |
To add an image to the Averager.
This image will be averaged in this function.
| image | The image to be averaged. |
Implements EMAN::Averager.
Definition at line 470 of file averager.cpp.
References EMAN::EMData::add(), b, EMAN::Ctf::bfactor, EMAN::Ctf::compute_2d_complex(), copy(), EMAN::EMData::copy_head(), EMAN::Ctf::CTF_AMP, EMAN::Ctf::CTF_SNR, EMAN::EMData::do_fft(), EMAN::EMData::get_attr(), EMAN::EMData::get_data(), get_name(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMUtil::is_same_size(), LOGERR, nimg, snrsum, and EMAN::EMData::to_zero().
00471 { 00472 if (!image) { 00473 return; 00474 } 00475 00476 00477 00478 EMData *fft=image->do_fft(); 00479 00480 if (nimg >= 1 && !EMUtil::is_same_size(fft, result)) { 00481 LOGERR("%s Averager can only process images of the same size", get_name().c_str()); 00482 return; 00483 } 00484 00485 nimg++; 00486 if (nimg == 1) { 00487 result = fft->copy_head(); 00488 result->to_zero(); 00489 } 00490 00491 Ctf *ctf = (Ctf *)image->get_attr("ctf"); 00492 float b=ctf->bfactor; 00493 ctf->bfactor=100.0; // FIXME - this is a temporary fixed B-factor which does a (very) little sharpening 00494 00495 EMData *snr = result -> copy(); 00496 ctf->compute_2d_complex(snr,Ctf::CTF_SNR); 00497 EMData *ctfi = result-> copy(); 00498 ctf->compute_2d_complex(ctfi,Ctf::CTF_AMP); 00499 00500 ctf->bfactor=b; // return to its original value 00501 00502 float *outd = result->get_data(); 00503 float *ind = fft->get_data(); 00504 float *snrd = snr->get_data(); 00505 float *ctfd = ctfi->get_data(); 00506 00507 size_t sz=snr->get_xsize()*snr->get_ysize(); 00508 for (size_t i = 0; i < sz; i+=2) { 00509 if (snrd[i]<0) snrd[i]=0; 00510 ctfd[i]=fabs(ctfd[i]); 00511 if (ctfd[i]<.05) { 00512 if (snrd[i]<=0) ctfd[i]=.05f; 00513 else ctfd[i]=snrd[i]*10.0f; 00514 } 00515 outd[i]+=ind[i]*snrd[i]/ctfd[i]; 00516 outd[i+1]+=ind[i+1]*snrd[i]/ctfd[i]; 00517 } 00518 00519 if (nimg==1) { 00520 snrsum=snr->copy_head(); 00521 float *ssnrd=snrsum->get_data(); 00522 // we're only using the real component, and we need to start with 1.0 00523 for (size_t i = 0; i < sz; i+=2) { ssnrd[i]=1.0; ssnrd[i+1]=0.0; } 00524 } 00525 snrsum->add(*snr); 00526 00527 delete ctf; 00528 delete fft; 00529 delete snr; 00530 delete ctfi; 00531 }
| EMData * CtfCWautoAverager::finish | ( | ) | [virtual] |
Finish up the averaging and return the result.
Implements EMAN::Averager.
Definition at line 533 of file averager.cpp.
References EMAN::EMData::do_ift(), EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), nimg, EMAN::EMData::set_attr(), snrsum, and EMAN::EMData::update().
00534 { 00535 /* EMData *tmp=result->do_ift(); 00536 tmp->write_image("ctfcw.hdf",0); 00537 delete tmp; 00538 00539 tmp=snrsum->do_ift(); 00540 tmp->write_image("ctfcw.hdf",1); 00541 delete tmp;*/ 00542 00543 // snrsum->write_image("snrsum.hdf",-1); 00544 size_t sz=result->get_xsize()*result->get_ysize(); 00545 float *snrsd=snrsum->get_data(); 00546 float *outd=result->get_data(); 00547 00548 for (size_t i=0; i<sz; i+=2) { 00549 outd[i]/=snrsd[i]; // snrsd contains total SNR+1 00550 outd[i+1]/=snrsd[i]; 00551 } 00552 result->update(); 00553 result->set_attr("ptcl_repr",nimg); 00554 00555 delete snrsum; 00556 EMData *ret=result->do_ift(); 00557 delete result; 00558 result=NULL; 00559 return ret; 00560 }
| string EMAN::CtfCWautoAverager::get_name | ( | ) | const [inline, virtual] |
Get the Averager's name.
Each Averager is identified by a unique name.
Implements EMAN::Averager.
Definition at line 421 of file averager.h.
Referenced by add_image().
| string EMAN::CtfCWautoAverager::get_desc | ( | ) | const [inline, virtual] |
Implements EMAN::Averager.
Definition at line 426 of file averager.h.
00427 { 00428 return "Averaging with autmatic CTF correction. Does not require a structure factor, but only works with EMAN2's CTF model"; 00429 }
| static Averager* EMAN::CtfCWautoAverager::NEW | ( | ) | [inline, static] |
Definition at line 431 of file averager.h.
References CtfCWautoAverager().
00432 { 00433 return new CtfCWautoAverager(); 00434 }
| void EMAN::CtfCWautoAverager::set_params | ( | const Dict & | new_params | ) | [inline, virtual] |
Set the Averager parameters using a key/value dictionary.
| new_params | A dictionary containing the new parameters. |
Reimplemented from EMAN::Averager.
Definition at line 436 of file averager.h.
References EMAN::Averager::params.
00437 { 00438 params = new_params; 00439 // outfile = params["outfile"]; 00440 }
EMData* EMAN::CtfCWautoAverager::snrsum [protected] |
int EMAN::CtfCWautoAverager::nimg [protected] |
1.5.6