Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

EMAN::CTFSNRWeightProcessor Class Reference

#include <processor.h>

Inheritance diagram for EMAN::CTFSNRWeightProcessor:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual void process_inplace (EMData *image)
 To process an image in-place.
virtual string get_name () const
 Get the processor's name.
virtual string get_desc () const
 Get the descrition of this specific processor.
virtual TypeDict get_param_types () const
 Get processor parameter information in a dictionary.

Static Public Member Functions

ProcessorNEW ()

Static Public Attributes

const string NAME = "ctf.snr.weight"

Detailed Description

Author:
David Woolford
Date:
June 15th 2009

Definition at line 6015 of file processor.h.


Member Function Documentation

virtual string EMAN::CTFSNRWeightProcessor::get_desc  )  const [inline, virtual]
 

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 6025 of file processor.h.

06026                         {
06027                                 return "Weight the amplitudes of an image based on radial noise and snr curves ";
06028                         }

virtual string EMAN::CTFSNRWeightProcessor::get_name  )  const [inline, virtual]
 

Get the processor's name.

Each processor is identified by a unique name.

Returns:
The processor's name.

Implements EMAN::Processor.

Definition at line 6020 of file processor.h.

06021                         {
06022                                 return NAME;
06023                         }

virtual TypeDict EMAN::CTFSNRWeightProcessor::get_param_types  )  const [inline, virtual]
 

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 6035 of file processor.h.

References EMAN::TypeDict::put().

06036                         {
06037                                 TypeDict d;
06038                                 d.put("noise", EMObject::FLOATARRAY, "The noise profile, squared amplitude. As in, what is the EMAN2CTF.background attribute");
06039                                 d.put("snr", EMObject::FLOATARRAY, "Squared amplitude divided by squared noise amplitude. As in, what is the EMAN2CTF.snr attribute");
06040                                 d.put("boost", EMObject::FLOAT, "Multiplicative signal boost");
06041                                 return d;
06042                         }

Processor* EMAN::CTFSNRWeightProcessor::NEW  )  [inline, static]
 

Definition at line 6030 of file processor.h.

06031                         {
06032                                 return new CTFSNRWeightProcessor();
06033                         }

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:
image The image to be processed.

Implements EMAN::Processor.

Definition at line 7046 of file processor.cpp.

References EMAN::EMData::ap2ri(), EMAN::EMData::calc_radial_dist(), EMAN::EMData::copy(), EMAN::EMData::depad(), EMAN::EMData::do_fft_inplace(), EMAN::EMData::do_ift_inplace(), EMAN::Dict::end(), EMAN::EMData::get_data(), EMAN::EMData::get_ndim(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::Dict::has_key(), InvalidParameterException, EMAN::EMData::is_complex(), EMAN::length(), nx, EMAN::EMData::process_inplace(), EMAN::EMData::ri2ap(), EMAN::EMData::ri2inten(), EMAN::Dict::set_default(), sqrt(), x, and y.

07046                                                          {
07047         if (params.has_key("noise")==false) throw InvalidParameterException("You must supply the noise argument");
07048         if (params.has_key("snr")==false) throw InvalidParameterException("You must supply the snr argument");
07049 
07050         float boost = params.set_default("boost",1.0f);
07051 
07052         if (!image->is_complex()) {
07053                 image->do_fft_inplace();
07054         }
07055         EMData* cpy = image->copy();
07056         cpy->ri2inten();
07057         vector<float> sf = cpy->calc_radial_dist(cpy->get_ysize()/2,0.0,1.0,1);
07058         transform(sf.begin(),sf.end(),sf.begin(),sqrtf);
07059         delete cpy;
07060 
07061         image->ri2ap();
07062 
07063         vector<float> noise = params["noise"];
07064         vector<float> snr = params["snr"];
07065 
07066 //      copy(snr.begin(), snr.end(), ostream_iterator<float>(cout, "\n"));
07067 //      copy(noise.begin(), noise.end(), ostream_iterator<float>(cout, "\n"));
07068 
07069         for(vector<float>::iterator it = noise.begin(); it != noise.end(); ++it){
07070                 if ((*it) == 0) *it = 1;
07071         }
07072         for(vector<float>::iterator it = snr.begin(); it != snr.end(); ++it){
07073                 if ((*it) < 0) *it = 0;
07074         }
07075         // Subtract the mean from the data and store it in data_mm
07076         transform(snr.begin(),snr.end(),noise.begin(),snr.begin(),std::multiplies<float>());
07077         transform(snr.begin(),snr.end(),snr.begin(),sqrtf);
07078 //      copy(snr.begin(), snr.end(), ostream_iterator<float>(cout, "\n"));
07079 //      copy(noise.begin(), noise.end(), ostream_iterator<float>(cout, "\n"));
07080 
07081         int i = static_cast<int>(snr.size());
07082 
07083         float * d = image->get_data();
07084         int nx = image->get_xsize();
07085 //      int ny = image->get_ysize();
07086         int nxy = image->get_ysize()*nx;
07087         int nzon2 = image->get_zsize()/2;
07088         int nyon2 = image->get_ysize()/2;
07089         float rx, ry, rz, amp;
07090         int length;
07091         int twox;
07092         image->process_inplace("xform.fourierorigin.tocenter");
07093         for (int z = 0; z< image->get_zsize(); ++z) {
07094                 for (int y = 0; y < image->get_ysize(); ++y) {
07095                         for (int x = 0; x < image->get_xsize()/2; ++x) {
07096                                 rx = (float)x;
07097                                 ry = (float)nyon2 - (float)y;
07098                                 rz = (float)nzon2 - (float)z;
07099                                 length = static_cast<int>(sqrt(rx*rx + ry*ry + rz*rz));
07100 
07101                                 twox = 2*x;
07102                                 size_t idx1 = twox + y*nx+(size_t)z*nxy;
07103                                 if (length >= i || length >= (int)sf.size()) {
07104                                         d[idx1] = 0;
07105                                         continue;
07106                                 } else {
07107                                         amp = boost*snr[length];
07108 //                                      if (amp > 0) amp =sqrtf(amp);
07109 //                                      else amp = 0;
07110                                 }
07111 
07112                                 if (sf[length] == 0) {
07113                                         d[idx1] = 0;
07114                                         continue;
07115                                 }
07116 
07117 //                              size_t idx2 = idx1 + 1;
07118 //                              cout << d[idx1] << " " << sf[length] << endl;
07119                                 d[idx1] /= sf[length];
07120                                 if (d[idx1] < 0) {
07121                                         d[idx1] *= amp;
07122                                 }else {
07123                                         d[idx1] *= -amp;
07124                                 }
07125 //                              d[idx2] = phase;
07126 
07127                         }
07128                 }
07129         }
07130 
07131         image->ap2ri();
07132         if (image->get_ndim() != 1) image->process_inplace("xform.fourierorigin.tocorner");
07133         image->do_ift_inplace();
07134         image->depad();
07135 }


Member Data Documentation

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

Definition at line 194 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Tue Jun 11 13:49:08 2013 for EMAN2 by  doxygen 1.3.9.1