EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
EMAN::CtfWtAverager Class Reference

CtfWtAverager. More...

#include <averager.h>

Inheritance diagram for EMAN::CtfWtAverager:
Inheritance graph
[legend]
Collaboration diagram for EMAN::CtfWtAverager:
Collaboration graph
[legend]

Public Member Functions

 CtfWtAverager ()
 
void add_image (EMData *image)
 To add an image to the Averager. More...
 
EMDatafinish ()
 Finish up the averaging and return the result. More...
 
string get_name () const
 Get the Averager's name. More...
 
string get_desc () const
 
void set_params (const Dict &new_params)
 Set the Averager parameters using a key/value dictionary. More...
 
- Public Member Functions inherited from EMAN::Averager
 Averager ()
 
virtual ~Averager ()
 
virtual void add_image_list (const vector< EMData * > &images)
 To add multiple images to the Averager. More...
 
virtual void mult (const float &s)
 Multiply the result image by some floating point constant This is useful when weighting the input images prior to calling add_image - a situation where it is likely you want to divide by the sum of the weights. More...
 
virtual TypeDict get_param_types () const
 Get Averager parameter information in a dictionary. More...
 

Static Public Member Functions

static AveragerNEW ()
 

Static Public Attributes

static const string NAME = "ctf.weight"
 

Protected Attributes

EMDatactfsum
 
int nimg
 
- Protected Attributes inherited from EMAN::Averager
Dict params
 
EMDataresult
 

Detailed Description

CtfWtAverager.

Definition at line 486 of file averager.h.

Constructor & Destructor Documentation

◆ CtfWtAverager()

CtfWtAverager::CtfWtAverager ( )

Definition at line 1255 of file averager.cpp.

1256 : nimg(0)
1257{
1258
1259}

Referenced by NEW().

Member Function Documentation

◆ add_image()

void CtfWtAverager::add_image ( EMData image)
virtual

To add an image to the Averager.

This image will be averaged in this function.

Parameters
imageThe image to be averaged.

Reimplemented from EMAN::Averager.

Definition at line 1262 of file averager.cpp.

1263{
1264 if (!image) {
1265 return;
1266 }
1267
1268
1269
1270 EMData *fft=image->do_fft();
1271
1272 if (nimg >= 1 && !EMUtil::is_same_size(fft, result)) {
1273 LOGERR("%s Averager can only process images of the same size", get_name().c_str());
1274 return;
1275 }
1276
1277 nimg++;
1278 if (nimg == 1) {
1279 result = fft->copy_head();
1280 result->to_zero();
1281 }
1282
1283 Ctf *ctf = (Ctf *)image->get_attr("ctf");
1284
1285 EMData *ctfi = result-> copy();
1286 float b=ctf->bfactor;
1287 ctf->bfactor=0; // no B-factor used in weight
1289 ctf->bfactor=b; // return to its original value
1290
1291 float *outd = result->get_data();
1292 float *ind = fft->get_data();
1293 float *ctfd = ctfi->get_data();
1294
1295 size_t sz=ctfi->get_xsize()*ctfi->get_ysize();
1296 for (size_t i = 0; i < sz; i+=2) {
1297
1298 // CTF weight
1299 outd[i]+=ind[i]*ctfd[i];
1300 outd[i+1]+=ind[i+1]*ctfd[i];
1301 }
1302
1303 if (nimg==1) {
1304 ctfsum=ctfi->copy_head();
1305 ctfsum->to_zero();
1306 }
1307 ctfsum->add(*ctfi);
1308
1309 delete ctf;
1310 delete fft;
1311 delete ctfi;
1312}
EMData * result
Definition: averager.h:158
string get_name() const
Get the Averager's name.
Definition: averager.h:494
Ctf is the base class for all CTF model.
Definition: ctf.h:60
virtual void compute_2d_complex(EMData *img, CtfType t, XYData *struct_factor=0)=0
float bfactor
Definition: ctf.h:85
@ CTF_INTEN
Definition: ctf.h:74
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
static bool is_same_size(const EMData *image1, const EMData *image2)
Check whether two EMData images are of the same size.
Definition: emutil.cpp:1224
EMData * copy() const
This file is a part of "emdata.h", to use functions in this file, you should "#include "emdata....
#define LOGERR
Definition: log.h:51

References EMAN::Ctf::bfactor, EMAN::Ctf::compute_2d_complex(), copy(), EMAN::Ctf::CTF_INTEN, ctfsum, get_name(), EMAN::EMUtil::is_same_size(), LOGERR, nimg, and EMAN::Averager::result.

◆ finish()

EMData * CtfWtAverager::finish ( )
virtual

Finish up the averaging and return the result.

Returns
The averaged image.

Implements EMAN::Averager.

Definition at line 1314 of file averager.cpp.

1315{
1316 int nx=result->get_xsize();
1317 int ny=result->get_ysize();
1318 float *ctfsd=ctfsum->get_data();
1319 float *outd=result->get_data();
1320
1321 for (int j=0; j<ny; j++) {
1322 for (int i=0; i<nx; i+=2) {
1323 size_t ii=i+j*nx;
1324 outd[ii]/=ctfsd[ii]; // snrsd contains total SNR
1325 outd[ii+1]/=ctfsd[ii];
1326 }
1327 }
1328 result->update();
1329 result->set_attr("ptcl_repr",nimg);
1330// result->set_attr("ctf_total",ctfsum->calc_radial_dist(ctfsum->get_ysize()/2,0,1,false));
1331 result->set_attr("ctf_wiener_filtered",0);
1332
1333/* snrsum->write_image("snr.hdf",-1);
1334 result->write_image("avg.hdf",-1);*/
1335
1336 delete ctfsum;
1337 EMData *ret=result->do_ift();
1338 delete result;
1339 result=NULL;
1340 return ret;
1341}

References ctfsum, nimg, and EMAN::Averager::result.

◆ get_desc()

string EMAN::CtfWtAverager::get_desc ( ) const
inlinevirtual

Implements EMAN::Averager.

Definition at line 499 of file averager.h.

500 {
501 return "Average without CTF correction but with CTF weighting. Smoothed SNR can still have large uncertainty, so weighting by envelope-free CTF may provide more uniform results.";
502 }

◆ get_name()

string EMAN::CtfWtAverager::get_name ( ) const
inlinevirtual

Get the Averager's name.

Each Averager is identified by a unique name.

Returns
The Averager's name.

Implements EMAN::Averager.

Definition at line 494 of file averager.h.

495 {
496 return NAME;
497 }
static const string NAME
Definition: averager.h:515

References NAME.

Referenced by add_image().

◆ NEW()

static Averager * EMAN::CtfWtAverager::NEW ( )
inlinestatic

Definition at line 504 of file averager.h.

505 {
506 return new CtfWtAverager();
507 }

References CtfWtAverager().

◆ set_params()

void EMAN::CtfWtAverager::set_params ( const Dict new_params)
inlinevirtual

Set the Averager parameters using a key/value dictionary.

Parameters
new_paramsA dictionary containing the new parameters.

Reimplemented from EMAN::Averager.

Definition at line 509 of file averager.h.

510 {
511 params = new_params;
512// outfile = params["outfile"];
513 }

References EMAN::Averager::params.

Member Data Documentation

◆ ctfsum

EMData* EMAN::CtfWtAverager::ctfsum
protected

Definition at line 518 of file averager.h.

Referenced by add_image(), and finish().

◆ NAME

const string CtfWtAverager::NAME = "ctf.weight"
static

Definition at line 515 of file averager.h.

Referenced by get_name().

◆ nimg

int EMAN::CtfWtAverager::nimg
protected

Definition at line 519 of file averager.h.

Referenced by add_image(), and finish().


The documentation for this class was generated from the following files: