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

EMAN::ApplyPolynomialProfileToHelix Class Reference

#include <processor.h>

Inheritance diagram for EMAN::ApplyPolynomialProfileToHelix:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

void process_inplace (EMData *in)
 To process an image in-place.
string get_name () const
 Get the processor's name.
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 = "math.poly_radial_profile"

Member Function Documentation

string EMAN::ApplyPolynomialProfileToHelix::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 6911 of file processor.h.

06912                 {
06913                         return "Finds the CM of each z-axis slice and applies a polynomial radial profile about it.";
06914                 }

string EMAN::ApplyPolynomialProfileToHelix::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 6901 of file processor.h.

06902                 {
06903                         return NAME;
06904                 }

virtual TypeDict EMAN::ApplyPolynomialProfileToHelix::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 6915 of file processor.h.

References EMAN::TypeDict::put().

06916                 {
06917                         TypeDict d;
06918                         d.put("length", EMObject::FLOAT, "Helix length in angstroms.");
06919                         d.put("z0", EMObject::INT, "z coordinate in pixels for the midpoint of the cylinder's axis, defaults to center of map");
06920                         return d;
06921                 }

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

Definition at line 6906 of file processor.h.

06907                 {
06908                         return new ApplyPolynomialProfileToHelix();
06909                 }

void ApplyPolynomialProfileToHelix::process_inplace EMData in  )  [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 9660 of file processor.cpp.

References EMAN::EMData::get_attr(), EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), nx, ny, EMAN::ModelHelixProcessor::radprofile(), EMAN::Util::round(), and EMAN::Dict::set_default().

09661 {
09662         EMData * cyl = in;
09663         int nx = cyl->get_xsize();
09664         int ny = cyl->get_ysize();
09665         int nz = cyl->get_zsize();
09666         float apix_x = cyl->get_attr("apix_x"); //TODO: Ask Matt if I correctly handled cases where apix_x != apix_y or apix_x != apix_z are not equal
09667         float apix_y = cyl->get_attr("apix_y");
09668         float apix_z = cyl->get_attr("apix_z");
09669         float lengthAngstroms = params["length"];
09670         int z0 = params.set_default("z0", -1); //in voxels
09671 
09672         if (z0 < 0 || z0 >= nz)
09673                 z0 = nz / 2;
09674 
09675         int z_start = Util::round( z0 - 0.5*lengthAngstroms/apix_z );
09676         int z_stop = Util::round( z0 + 0.5*lengthAngstroms/apix_z );
09677 
09678         float * dat = cyl->get_data();
09679         double rho_x_sum, rho_y_sum, rho_sum, x_cm, y_cm, radius;
09680 
09681         for (int k = 0; k < nz; ++k) //taking slices along z axis
09682         {
09683                 rho_x_sum = rho_y_sum = rho_sum = 0; //Set to zero for a new slice
09684 
09685                 if (k >= z_start && k <= z_stop)
09686                 //Apply the radial profile only between z_start and z_stop on the z axis
09687                 {
09688                         //Calculating CM for the slice...
09689                         for (int j = 0; j < ny; ++j)
09690                         {
09691                                 for (int i = 0; i < nx; ++i, ++dat)
09692                                 {
09693                                         rho_x_sum += (*dat)*i;
09694                                         rho_y_sum += (*dat)*j;
09695                                         rho_sum += *dat;
09696                                 }
09697                         }
09698                         if (rho_sum != 0)
09699                         {
09700                                 dat -= nx*ny;//going back to the beginning of the dat array
09701                                 x_cm = rho_x_sum/rho_sum;
09702                                 y_cm = rho_y_sum/rho_sum;
09703 
09704                                 //Applying radial profile...
09705                                 for (int j=0; j<ny;++j)
09706                                 {
09707                                         for (int i=0;i<nx;++i,++dat)
09708                                         {
09709                                                 radius = hypot( (i-x_cm)*apix_x, (j-y_cm)*apix_y );
09710                                                 *dat = radprofile((float)radius, 2);//Type 2 is the polynomial radial profile.
09711                                         }
09712                                 }
09713                         }
09714                 }
09715                 else
09716                 //Clear the map, setting the density to zero everywhere else.
09717                 {
09718                         for (int j=0; j<ny; j++)
09719                                 for(int i=0; i<nx; i++)
09720                                 {
09721                                         *dat = 0;
09722                                         dat++;
09723                                 }
09724                 }
09725 
09726         }
09727 }


Member Data Documentation

const string ApplyPolynomialProfileToHelix::NAME = "math.poly_radial_profile" [static]
 

Definition at line 223 of file processor.cpp.


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