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

static ProcessorNEW ()

Static Public Attributes

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

Detailed Description

Author:
David Woolford
Date:
June 15th 2009

Definition at line 5932 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 5942 of file processor.h.

05943                         {
05944                                 return "Weight the amplitudes of an image based on radial noise and snr curves ";
05945                         }

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

References NAME.

05938                         {
05939                                 return NAME;
05940                         }

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

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

05953                         {
05954                                 TypeDict d;
05955                                 d.put("noise", EMObject::FLOATARRAY, "The noise profile, squared amplitude. As in, what is the EMAN2CTF.background attribute");
05956                                 d.put("snr", EMObject::FLOATARRAY, "Squared amplitude divided by squared noise amplitude. As in, what is the EMAN2CTF.snr attribute");
05957                                 d.put("boost", EMObject::FLOAT, "Multiplicative signal boost");
05958                                 return d;
05959                         }

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

Definition at line 5947 of file processor.h.

05948                         {
05949                                 return new CTFSNRWeightProcessor();
05950                         }

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 6816 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::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(), EMAN::Processor::params, EMAN::EMData::process_inplace(), EMAN::EMData::ri2ap(), EMAN::EMData::ri2inten(), EMAN::Dict::set_default(), sqrt(), and x.

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


Member Data Documentation

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

Definition at line 5961 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Mon Jul 19 12:44:04 2010 for EMAN2 by  doxygen 1.4.7