#include <averager.h>
Inheritance diagram for EMAN::TomoAverager:
Public Member Functions | |
TomoAverager () | |
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 |
TypeDict | get_param_types () const |
Get Averager parameter information in a dictionary. | |
virtual void | mult (const float &) |
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. | |
Static Public Member Functions | |
Averager * | NEW () |
Static Public Attributes | |
const string | NAME = "mean.tomo" |
Private Attributes | |
EMData * | norm_image |
float | thresh_sigma |
It excludes values near zero from the average, assuming they are part of the missing-cone/wedge. A threshold
thresh_sigma | a number, multiplied by the standard deviation of the image, below-which values are considered zero |
Definition at line 262 of file averager.h.
|
Definition at line 84 of file averager.cpp. 00085 : norm_image(0) 00086 { 00087 00088 }
|
|
To add an image to the Averager. This image will be averaged in this function.
Implements EMAN::Averager. Definition at line 90 of file averager.cpp. References EMAN::EMData::copy_head(), data, EMAN::EMData::do_fft(), EMAN::EMObject::f, EMAN::EMData::get_attr(), EMAN::EMData::get_data(), get_name(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::EMData::has_attr(), EMAN::EMData::is_complex(), EMAN::EMUtil::is_same_size(), LOGERR, norm_image, nx, ny, EMAN::EMData::set_attr(), EMAN::Dict::set_default(), thresh_sigma, and EMAN::EMData::to_zero(). 00091 { 00092 if (!image) { 00093 return; 00094 } 00095 00096 if (!image->is_complex()) { 00097 image=image->do_fft(); 00098 image->set_attr("free_me",(int)1); 00099 } 00100 00101 if (result!=0 && !EMUtil::is_same_size(image, result)) { 00102 LOGERR("%s Averager can only process same-size Images", 00103 get_name().c_str()); 00104 return; 00105 } 00106 00107 int nx = image->get_xsize(); 00108 int ny = image->get_ysize(); 00109 int nz = image->get_zsize(); 00110 size_t image_size = (size_t)nx * ny * nz; 00111 00112 if (norm_image == 0) { 00113 printf("init average %d %d %d",nx,ny,nz); 00114 result = image->copy_head(); 00115 result->to_zero(); 00116 00117 norm_image = image->copy_head(); 00118 norm_image->to_zero(); 00119 00120 thresh_sigma = (float)params.set_default("thresh_sigma", 0.01); 00121 } 00122 00123 float *result_data = result->get_data(); 00124 float *norm_data = norm_image->get_data(); 00125 float *data = image->get_data(); 00126 float thresh=image->get_attr("sigma"); 00127 thresh=2.0f*thresh*thresh*thresh_sigma; 00128 00129 // Add any values above threshold to the result image, and add 1 to the corresponding pixels in the norm image 00130 for (size_t j = 0; j < image_size; j+=2) { 00131 float f=data[j]; // real 00132 float g=data[j+1]; // imag 00133 float inten=f*f+g*g; 00134 00135 if (inten<thresh) continue; 00136 00137 result_data[j] +=f; 00138 result_data[j+1]+=g; 00139 00140 norm_data[j] +=1.0; 00141 norm_data[j+1]+=1.0; 00142 } 00143 00144 if (image->has_attr("free_me")) delete image; 00145 }
|
|
Finish up the averaging and return the result.
Implements EMAN::Averager. Definition at line 147 of file averager.cpp. References EMAN::EMData::do_ift(), EMAN::EMData::get_attr(), EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), norm_image, nx, ny, EMAN::EMData::set_attr(), EMAN::Dict::set_default(), EMAN::EMData::update(), and EMAN::EMData::write_image(). 00148 { 00149 if (norm_image==0 || result==0) return NULL; 00150 00151 int nx = result->get_xsize(); 00152 int ny = result->get_ysize(); 00153 int nz = result->get_zsize(); 00154 size_t image_size = (size_t)nx * ny * nz; 00155 00156 float *result_data = result->get_data(); 00157 float *norm_data = norm_image->get_data(); 00158 00159 printf("finish average %d %d %d",nx,ny,nz); 00160 // normalize the average 00161 for (size_t j = 0; j < image_size; j++) { 00162 if (norm_data[j]==0.0) result_data[j]=0.0; 00163 else result_data[j]/=norm_data[j]; 00164 } 00165 00166 norm_image->update(); 00167 result->update(); 00168 00169 EMData *ret = result->do_ift(); 00170 ret->set_attr("ptcl_repr",norm_image->get_attr("maximum")); 00171 if ((int)params.set_default("save_norm", 0)) 00172 norm_image->write_image("norm.hdf"); 00173 00174 delete result; 00175 delete norm_image; 00176 result=0; 00177 norm_image=0; 00178 00179 return ret; 00180 }
|
|
Implements EMAN::Averager. Definition at line 275 of file averager.h. 00276 { 00277 return "Average of volumes in Fourier space, excluding any pixels with near 0 intensity."; 00278 }
|
|
Get the Averager's name. Each Averager is identified by a unique name.
Implements EMAN::Averager. Definition at line 270 of file averager.h. Referenced by add_image(). 00271 {
00272 return NAME;
00273 }
|
|
Get Averager parameter information in a dictionary. Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.
Reimplemented from EMAN::Averager. Definition at line 285 of file averager.h. References EMAN::TypeDict::put(). 00286 { 00287 TypeDict d; 00288 d.put("thresh_sigma", EMObject::FLOAT, "multiplied by the standard deviation of the image, below-which values are considered zero. Default = .01"); 00289 d.put("save_norm", EMObject::INT, "If set, will save the normalization volume as norm.hdf. Mainly for debugging purposes."); 00290 return d; 00291 }
|
|
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. Hence call mult after all of the weighted images have been added.
Reimplemented from EMAN::Averager. Definition at line 293 of file averager.h. 00293 { }
|
|
Definition at line 280 of file averager.h. 00281 { 00282 return new TomoAverager(); 00283 }
|
|
Definition at line 46 of file averager.cpp. |
|
Definition at line 298 of file averager.h. Referenced by add_image(), and finish(). |
|
Definition at line 299 of file averager.h. Referenced by add_image(). |