#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 216 of file averager.h.
|
Definition at line 87 of file averager.cpp. 00088 : norm_image(0) 00089 { 00090 00091 }
|
|
To add an image to the Averager. This image will be averaged in this function.
Implements EMAN::Averager. Definition at line 93 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(). 00094 { 00095 if (!image) { 00096 return; 00097 } 00098 00099 if (!image->is_complex()) { 00100 image=image->do_fft(); 00101 image->set_attr("free_me",(int)1); 00102 } 00103 00104 if (result!=0 && !EMUtil::is_same_size(image, result)) { 00105 LOGERR("%s Averager can only process same-size Images", 00106 get_name().c_str()); 00107 return; 00108 } 00109 00110 int nx = image->get_xsize(); 00111 int ny = image->get_ysize(); 00112 int nz = image->get_zsize(); 00113 size_t image_size = (size_t)nx * ny * nz; 00114 00115 if (norm_image == 0) { 00116 printf("init average %d %d %d",nx,ny,nz); 00117 result = image->copy_head(); 00118 result->to_zero(); 00119 00120 norm_image = image->copy_head(); 00121 norm_image->to_zero(); 00122 00123 thresh_sigma = (float)params.set_default("thresh_sigma", 0.01); 00124 } 00125 00126 float *result_data = result->get_data(); 00127 float *norm_data = norm_image->get_data(); 00128 float *data = image->get_data(); 00129 float thresh=image->get_attr("sigma"); 00130 thresh=2.0f*thresh*thresh*thresh_sigma; 00131 00132 // Add any values above threshold to the result image, and add 1 to the corresponding pixels in the norm image 00133 for (size_t j = 0; j < image_size; j+=2) { 00134 float f=data[j]; // real 00135 float g=data[j+1]; // imag 00136 float inten=f*f+g*g; 00137 00138 if (inten<thresh) continue; 00139 00140 result_data[j] +=f; 00141 result_data[j+1]+=g; 00142 00143 norm_data[j] +=1.0; 00144 norm_data[j+1]+=1.0; 00145 } 00146 00147 if (image->has_attr("free_me")) delete image; 00148 }
|
|
Finish up the averaging and return the result.
Implements EMAN::Averager. Definition at line 150 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(). 00151 { 00152 if (norm_image==0 || result==0) return NULL; 00153 00154 int nx = result->get_xsize(); 00155 int ny = result->get_ysize(); 00156 int nz = result->get_zsize(); 00157 size_t image_size = (size_t)nx * ny * nz; 00158 00159 float *result_data = result->get_data(); 00160 float *norm_data = norm_image->get_data(); 00161 00162 printf("finish average %d %d %d",nx,ny,nz); 00163 // normalize the average 00164 for (size_t j = 0; j < image_size; j++) { 00165 if (norm_data[j]==0.0) result_data[j]=0.0; 00166 else result_data[j]/=norm_data[j]; 00167 } 00168 00169 norm_image->update(); 00170 result->update(); 00171 00172 EMData *ret = result->do_ift(); 00173 ret->set_attr("ptcl_repr",norm_image->get_attr("maximum")); 00174 if ((int)params.set_default("save_norm", 0)) 00175 norm_image->write_image("norm.hdf"); 00176 00177 delete result; 00178 delete norm_image; 00179 result=0; 00180 norm_image=0; 00181 00182 return ret; 00183 }
|
|
Implements EMAN::Averager. Definition at line 229 of file averager.h. 00230 { 00231 return "Average of volumes in Fourier space, excluding any pixels with near 0 intensity."; 00232 }
|
|
Get the Averager's name. Each Averager is identified by a unique name.
Implements EMAN::Averager. Definition at line 224 of file averager.h. Referenced by add_image(). 00225 {
00226 return NAME;
00227 }
|
|
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 239 of file averager.h. References EMAN::TypeDict::put(). 00240 { 00241 TypeDict d; 00242 d.put("thresh_sigma", EMObject::FLOAT, "multiplied by the standard deviation of the image, below-which values are considered zero. Default = .01"); 00243 d.put("save_norm", EMObject::INT, "If set, will save the normalization volume as norm.hdf. Mainly for debugging purposes."); 00244 return d; 00245 }
|
|
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 247 of file averager.h. 00247 { }
|
|
Definition at line 234 of file averager.h. 00235 { 00236 return new TomoAverager(); 00237 }
|
|
Definition at line 46 of file averager.cpp. |
|
Definition at line 252 of file averager.h. Referenced by add_image(), and finish(). |
|
Definition at line 253 of file averager.h. Referenced by add_image(). |