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

05815                         {
05816                                 return "Weight the amplitudes of an image based on radial noise and snr curves ";
05817                         }

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

05810                         {
05811                                 return NAME;
05812                         }

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

References EMAN::TypeDict::put().

05825                         {
05826                                 TypeDict d;
05827                                 d.put("noise", EMObject::FLOATARRAY, "The noise profile, squared amplitude. As in, what is the EMAN2CTF.background attribute");
05828                                 d.put("snr", EMObject::FLOATARRAY, "Squared amplitude divided by squared noise amplitude. As in, what is the EMAN2CTF.snr attribute");
05829                                 d.put("boost", EMObject::FLOAT, "Multiplicative signal boost");
05830                                 return d;
05831                         }

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

Definition at line 5819 of file processor.h.

05820                         {
05821                                 return new CTFSNRWeightProcessor();
05822                         }

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

06778                                                          {
06779         if (params.has_key("noise")==false) throw InvalidParameterException("You must supply the noise argument");
06780         if (params.has_key("snr")==false) throw InvalidParameterException("You must supply the snr argument");
06781 
06782         float boost = params.set_default("boost",1.0f);
06783 
06784         if (!image->is_complex()) {
06785                 image->do_fft_inplace();
06786         }
06787         EMData* cpy = image->copy();
06788         cpy->ri2inten();
06789         vector<float> sf = cpy->calc_radial_dist(cpy->get_ysize()/2,0.0,1.0,1);
06790         transform(sf.begin(),sf.end(),sf.begin(),sqrtf);
06791         delete cpy;
06792 
06793         image->ri2ap();
06794 
06795         vector<float> noise = params["noise"];
06796         vector<float> snr = params["snr"];
06797 
06798 //      copy(snr.begin(), snr.end(), ostream_iterator<float>(cout, "\n"));
06799 //      copy(noise.begin(), noise.end(), ostream_iterator<float>(cout, "\n"));
06800 
06801         for(vector<float>::iterator it = noise.begin(); it != noise.end(); ++it){
06802                 if ((*it) == 0) *it = 1;
06803         }
06804         for(vector<float>::iterator it = snr.begin(); it != snr.end(); ++it){
06805                 if ((*it) < 0) *it = 0;
06806         }
06807         // Subtract the mean from the data and store it in data_mm
06808         transform(snr.begin(),snr.end(),noise.begin(),snr.begin(),std::multiplies<float>());
06809         transform(snr.begin(),snr.end(),snr.begin(),sqrtf);
06810 //      copy(snr.begin(), snr.end(), ostream_iterator<float>(cout, "\n"));
06811 //      copy(noise.begin(), noise.end(), ostream_iterator<float>(cout, "\n"));
06812 
06813         int i = static_cast<int>(snr.size());
06814 
06815         float * d = image->get_data();
06816         int nx = image->get_xsize();
06817 //      int ny = image->get_ysize();
06818         int nxy = image->get_ysize()*nx;
06819         int nzon2 = image->get_zsize()/2;
06820         int nyon2 = image->get_ysize()/2;
06821         float rx, ry, rz, amp;
06822         int length;
06823         int twox;
06824         image->process_inplace("xform.fourierorigin.tocenter");
06825         for (int z = 0; z< image->get_zsize(); ++z) {
06826                 for (int y = 0; y < image->get_ysize(); ++y) {
06827                         for (int x = 0; x < image->get_xsize()/2; ++x) {
06828                                 rx = (float)x;
06829                                 ry = (float)nyon2 - (float)y;
06830                                 rz = (float)nzon2 - (float)z;
06831                                 length = static_cast<int>(sqrt(rx*rx + ry*ry + rz*rz));
06832 
06833                                 twox = 2*x;
06834                                 size_t idx1 = twox + y*nx+(size_t)z*nxy;
06835                                 if (length >= i || length >= (int)sf.size()) {
06836                                         d[idx1] = 0;
06837                                         continue;
06838                                 } else {
06839                                         amp = boost*snr[length];
06840 //                                      if (amp > 0) amp =sqrtf(amp);
06841 //                                      else amp = 0;
06842                                 }
06843 
06844                                 if (sf[length] == 0) {
06845                                         d[idx1] = 0;
06846                                         continue;
06847                                 }
06848 
06849 //                              size_t idx2 = idx1 + 1;
06850 //                              cout << d[idx1] << " " << sf[length] << endl;
06851                                 d[idx1] /= sf[length];
06852                                 if (d[idx1] < 0) {
06853                                         d[idx1] *= amp;
06854                                 }else {
06855                                         d[idx1] *= -amp;
06856                                 }
06857 //                              d[idx2] = phase;
06858 
06859                         }
06860                 }
06861         }
06862 
06863         image->ap2ri();
06864         if (image->get_ndim() != 1) image->process_inplace("xform.fourierorigin.tocorner");
06865         image->do_ift_inplace();
06866         image->depad();
06867 }


Member Data Documentation

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

Definition at line 191 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Thu Mar 10 23:00:26 2011 for EMAN2 by  doxygen 1.3.9.1