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

05909                         {
05910                                 return "Weight the amplitudes of an image based on radial noise and snr curves ";
05911                         }

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

05904                         {
05905                                 return NAME;
05906                         }

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

References EMAN::TypeDict::put().

05919                         {
05920                                 TypeDict d;
05921                                 d.put("noise", EMObject::FLOATARRAY, "The noise profile, squared amplitude. As in, what is the EMAN2CTF.background attribute");
05922                                 d.put("snr", EMObject::FLOATARRAY, "Squared amplitude divided by squared noise amplitude. As in, what is the EMAN2CTF.snr attribute");
05923                                 d.put("boost", EMObject::FLOAT, "Multiplicative signal boost");
05924                                 return d;
05925                         }

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

Definition at line 5913 of file processor.h.

05914                         {
05915                                 return new CTFSNRWeightProcessor();
05916                         }

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 6808 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.

06808                                                          {
06809         if (params.has_key("noise")==false) throw InvalidParameterException("You must supply the noise argument");
06810         if (params.has_key("snr")==false) throw InvalidParameterException("You must supply the snr argument");
06811 
06812         float boost = params.set_default("boost",1.0f);
06813 
06814         if (!image->is_complex()) {
06815                 image->do_fft_inplace();
06816         }
06817         EMData* cpy = image->copy();
06818         cpy->ri2inten();
06819         vector<float> sf = cpy->calc_radial_dist(cpy->get_ysize()/2,0.0,1.0,1);
06820         transform(sf.begin(),sf.end(),sf.begin(),sqrtf);
06821         delete cpy;
06822 
06823         image->ri2ap();
06824 
06825         vector<float> noise = params["noise"];
06826         vector<float> snr = params["snr"];
06827 
06828 //      copy(snr.begin(), snr.end(), ostream_iterator<float>(cout, "\n"));
06829 //      copy(noise.begin(), noise.end(), ostream_iterator<float>(cout, "\n"));
06830 
06831         for(vector<float>::iterator it = noise.begin(); it != noise.end(); ++it){
06832                 if ((*it) == 0) *it = 1;
06833         }
06834         for(vector<float>::iterator it = snr.begin(); it != snr.end(); ++it){
06835                 if ((*it) < 0) *it = 0;
06836         }
06837         // Subtract the mean from the data and store it in data_mm
06838         transform(snr.begin(),snr.end(),noise.begin(),snr.begin(),std::multiplies<float>());
06839         transform(snr.begin(),snr.end(),snr.begin(),sqrtf);
06840 //      copy(snr.begin(), snr.end(), ostream_iterator<float>(cout, "\n"));
06841 //      copy(noise.begin(), noise.end(), ostream_iterator<float>(cout, "\n"));
06842 
06843         int i = static_cast<int>(snr.size());
06844 
06845         float * d = image->get_data();
06846         int nx = image->get_xsize();
06847 //      int ny = image->get_ysize();
06848         int nxy = image->get_ysize()*nx;
06849         int nzon2 = image->get_zsize()/2;
06850         int nyon2 = image->get_ysize()/2;
06851         float rx, ry, rz, amp;
06852         int length;
06853         int twox;
06854         image->process_inplace("xform.fourierorigin.tocenter");
06855         for (int z = 0; z< image->get_zsize(); ++z) {
06856                 for (int y = 0; y < image->get_ysize(); ++y) {
06857                         for (int x = 0; x < image->get_xsize()/2; ++x) {
06858                                 rx = (float)x;
06859                                 ry = (float)nyon2 - (float)y;
06860                                 rz = (float)nzon2 - (float)z;
06861                                 length = static_cast<int>(sqrt(rx*rx + ry*ry + rz*rz));
06862 
06863                                 twox = 2*x;
06864                                 size_t idx1 = twox + y*nx+(size_t)z*nxy;
06865                                 if (length >= i || length >= (int)sf.size()) {
06866                                         d[idx1] = 0;
06867                                         continue;
06868                                 } else {
06869                                         amp = boost*snr[length];
06870 //                                      if (amp > 0) amp =sqrtf(amp);
06871 //                                      else amp = 0;
06872                                 }
06873 
06874                                 if (sf[length] == 0) {
06875                                         d[idx1] = 0;
06876                                         continue;
06877                                 }
06878 
06879 //                              size_t idx2 = idx1 + 1;
06880 //                              cout << d[idx1] << " " << sf[length] << endl;
06881                                 d[idx1] /= sf[length];
06882                                 if (d[idx1] < 0) {
06883                                         d[idx1] *= amp;
06884                                 }else {
06885                                         d[idx1] *= -amp;
06886                                 }
06887 //                              d[idx2] = phase;
06888 
06889                         }
06890                 }
06891         }
06892 
06893         image->ap2ri();
06894         if (image->get_ndim() != 1) image->process_inplace("xform.fourierorigin.tocorner");
06895         image->do_ift_inplace();
06896         image->depad();
06897 }


Member Data Documentation

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

Definition at line 198 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Tue Jul 12 13:52:35 2011 for EMAN2 by  doxygen 1.3.9.1