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

#include <processor.h>

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

Public Member Functions

virtual void process_inplace (EMData *image)
 To process an image in-place. More...
 
virtual string get_name () const
 Get the processor's name. More...
 
virtual string get_desc () const
 Get the descrition of this specific processor. More...
 
virtual TypeDict get_param_types () const
 Get processor parameter information in a dictionary. More...
 
- Public Member Functions inherited from EMAN::Processor
virtual ~Processor ()
 
virtual EMDataprocess (const EMData *const image)
 To proccess an image out-of-place. More...
 
virtual void process_list_inplace (vector< EMData * > &images)
 To process multiple images using the same algorithm. More...
 
virtual Dict get_params () const
 Get the processor parameters in a key/value dictionary. More...
 
virtual void set_params (const Dict &new_params)
 Set the processor parameters using a key/value dictionary. More...
 

Static Public Member Functions

static ProcessorNEW ()
 
- Static Public Member Functions inherited from EMAN::TestImageProcessor
static string get_group_desc ()
 
- Static Public Member Functions inherited from EMAN::Processor
static string get_group_desc ()
 Get the description of this group of processors. More...
 
static void EMFourierFilterInPlace (EMData *fimage, Dict params)
 Compute a Fourier-filter processed image in place. More...
 
static EMDataEMFourierFilter (EMData *fimage, Dict params)
 Compute a Fourier-processor processed image without altering the original image. More...
 

Static Public Attributes

static const string NAME = "ctf.snr.weight"
 

Additional Inherited Members

- Public Types inherited from EMAN::Processor
enum  fourier_filter_types {
  TOP_HAT_LOW_PASS , TOP_HAT_HIGH_PASS , TOP_HAT_BAND_PASS , TOP_HOMOMORPHIC ,
  GAUSS_LOW_PASS , GAUSS_HIGH_PASS , GAUSS_BAND_PASS , GAUSS_INVERSE ,
  GAUSS_HOMOMORPHIC , BUTTERWORTH_LOW_PASS , BUTTERWORTH_HIGH_PASS , BUTTERWORTH_HOMOMORPHIC ,
  KAISER_I0 , KAISER_SINH , KAISER_I0_INVERSE , KAISER_SINH_INVERSE ,
  SHIFT , TANH_LOW_PASS , TANH_HIGH_PASS , TANH_HOMOMORPHIC ,
  TANH_BAND_PASS , RADIAL_TABLE , CTF_
}
 Fourier filter Processor type enum. More...
 
- Protected Member Functions inherited from EMAN::TestImageProcessor
void preprocess (EMData *image)
 
- Protected Attributes inherited from EMAN::TestImageProcessor
int nx
 
int ny
 
int nz
 
- Protected Attributes inherited from EMAN::Processor
Dict params
 

Detailed Description

Author
David Woolford
Date
June 15th 2009

Definition at line 8217 of file processor.h.

Member Function Documentation

◆ get_desc()

virtual string EMAN::CTFSNRWeightProcessor::get_desc ( ) const
inlinevirtual

Get the descrition of this specific processor.

This function must be overwritten by a subclass.

Returns
The description of this processor.

Implements EMAN::Processor.

Definition at line 8227 of file processor.h.

8228 {
8229 return "Weight the amplitudes of an image based on radial noise and snr curves ";
8230 }

◆ get_name()

virtual string EMAN::CTFSNRWeightProcessor::get_name ( ) const
inlinevirtual

Get the processor's name.

Each processor is identified by a unique name.

Returns
The processor's name.

Implements EMAN::Processor.

Definition at line 8222 of file processor.h.

8223 {
8224 return NAME;
8225 }
static const string NAME
Definition: processor.h:8246

References NAME.

◆ get_param_types()

virtual TypeDict EMAN::CTFSNRWeightProcessor::get_param_types ( ) const
inlinevirtual

Get processor parameter information in a dictionary.

Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.

Returns
A dictionary containing the parameter info.

Reimplemented from EMAN::Processor.

Definition at line 8237 of file processor.h.

8238 {
8239 TypeDict d;
8240 d.put("noise", EMObject::FLOATARRAY, "The noise profile, squared amplitude. As in, what is the EMAN2CTF.background attribute");
8241 d.put("snr", EMObject::FLOATARRAY, "Squared amplitude divided by squared noise amplitude. As in, what is the EMAN2CTF.snr attribute");
8242 d.put("boost", EMObject::FLOAT, "Multiplicative signal boost");
8243 return d;
8244 }
TypeDict is a dictionary to store <string, EMObject::ObjectType> pair.
Definition: emobject.h:305
void put(const string &key, EMObject::ObjectType o, const string &desc="")
Definition: emobject.h:330

References EMAN::EMObject::FLOAT, EMAN::EMObject::FLOATARRAY, and EMAN::TypeDict::put().

◆ NEW()

static Processor * EMAN::CTFSNRWeightProcessor::NEW ( )
inlinestatic

Definition at line 8232 of file processor.h.

8233 {
8234 return new CTFSNRWeightProcessor();
8235 }

◆ process_inplace()

void CTFSNRWeightProcessor::process_inplace ( EMData image)
virtual

To process an image in-place.

For those processors which can only be processed out-of-place, override this function to just print out some error message to remind user call the out-of-place version.

Parameters
imageThe image to be processed.

Implements EMAN::Processor.

Definition at line 9089 of file processor.cpp.

9089 {
9090 if (params.has_key("noise")==false) throw InvalidParameterException("You must supply the noise argument");
9091 if (params.has_key("snr")==false) throw InvalidParameterException("You must supply the snr argument");
9092
9093 float boost = params.set_default("boost",1.0f);
9094
9095 if (!image->is_complex()) {
9096 image->do_fft_inplace();
9097 }
9098 EMData* cpy = image->copy();
9099 cpy->ri2inten();
9100 vector<float> sf = cpy->calc_radial_dist(cpy->get_ysize()/2,0.0,1.0,1);
9101 transform(sf.begin(),sf.end(),sf.begin(),sqrtf);
9102 delete cpy;
9103
9104 image->ri2ap();
9105
9106 vector<float> noise = params["noise"];
9107 vector<float> snr = params["snr"];
9108
9109// copy(snr.begin(), snr.end(), ostream_iterator<float>(cout, "\n"));
9110// copy(noise.begin(), noise.end(), ostream_iterator<float>(cout, "\n"));
9111
9112 for(vector<float>::iterator it = noise.begin(); it != noise.end(); ++it){
9113 if ((*it) == 0) *it = 1;
9114 }
9115 for(vector<float>::iterator it = snr.begin(); it != snr.end(); ++it){
9116 if ((*it) < 0) *it = 0;
9117 }
9118 // Subtract the mean from the data and store it in data_mm
9119 transform(snr.begin(),snr.end(),noise.begin(),snr.begin(),std::multiplies<float>());
9120 transform(snr.begin(),snr.end(),snr.begin(),sqrtf);
9121// copy(snr.begin(), snr.end(), ostream_iterator<float>(cout, "\n"));
9122// copy(noise.begin(), noise.end(), ostream_iterator<float>(cout, "\n"));
9123
9124 int i = static_cast<int>(snr.size());
9125
9126 float * d = image->get_data();
9127 int nx = image->get_xsize();
9128// int ny = image->get_ysize();
9129 int nxy = image->get_ysize()*nx;
9130 int nzon2 = image->get_zsize()/2;
9131 int nyon2 = image->get_ysize()/2;
9132 float rx, ry, rz, amp;
9133 int length;
9134 int twox;
9135 image->process_inplace("xform.fourierorigin.tocenter");
9136 for (int z = 0; z< image->get_zsize(); ++z) {
9137 for (int y = 0; y < image->get_ysize(); ++y) {
9138 for (int x = 0; x < image->get_xsize()/2; ++x) {
9139 rx = (float)x;
9140 ry = (float)nyon2 - (float)y;
9141 rz = (float)nzon2 - (float)z;
9142 length = static_cast<int>(sqrt(rx*rx + ry*ry + rz*rz));
9143
9144 twox = 2*x;
9145 size_t idx1 = twox + y*nx+(size_t)z*nxy;
9146 if (length >= i || length >= (int)sf.size()) {
9147 d[idx1] = 0;
9148 continue;
9149 } else {
9150 amp = boost*snr[length];
9151// if (amp > 0) amp =sqrtf(amp);
9152// else amp = 0;
9153 }
9154
9155 if (sf[length] == 0) {
9156 d[idx1] = 0;
9157 continue;
9158 }
9159
9160// size_t idx2 = idx1 + 1;
9161// cout << d[idx1] << " " << sf[length] << endl;
9162 d[idx1] /= sf[length];
9163 if (d[idx1] < 0) {
9164 d[idx1] *= amp;
9165 }else {
9166 d[idx1] *= -amp;
9167 }
9168// d[idx2] = phase;
9169
9170 }
9171 }
9172 }
9173
9174 image->ap2ri();
9175 if (image->get_ndim() != 1) image->process_inplace("xform.fourierorigin.tocorner");
9176 image->do_ift_inplace();
9177 image->depad();
9178}
type set_default(const string &key, type val)
Default setting behavior This can be achieved using a template - d.woolford Jan 2008 (before there wa...
Definition: emobject.h:569
bool has_key(const string &key) const
Ask the Dictionary if it as a particular key.
Definition: emobject.h:511
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
vector< float > calc_radial_dist(int n, float x0, float dx, int inten)
calculates radial distribution.
Definition: emdata.cpp:2781
EMData * sqrt() const
return square root of current image
#define InvalidParameterException(desc)
Definition: exception.h:361
double length(const Vector3 &v)
Definition: vecmath.h:313
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

References EMAN::EMData::calc_radial_dist(), EMAN::Dict::has_key(), InvalidParameterException, EMAN::length(), EMAN::TestImageProcessor::nx, EMAN::Processor::params, EMAN::Dict::set_default(), sqrt(), x, and y.

Member Data Documentation

◆ NAME

const string CTFSNRWeightProcessor::NAME = "ctf.snr.weight"
static

Definition at line 8246 of file processor.h.

Referenced by get_name().


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