#include <processor.h>
Inheritance diagram for EMAN::ApplyPolynomialProfileToHelix:
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 | |
static Processor * | NEW () |
Static Public Attributes | |
static const string | NAME = "math.poly_radial_profile" |
Definition at line 6802 of file processor.h.
string EMAN::ApplyPolynomialProfileToHelix::get_desc | ( | ) | const [inline, virtual] |
Get the descrition of this specific processor.
This function must be overwritten by a subclass.
Implements EMAN::Processor.
Definition at line 6817 of file processor.h.
06818 { 06819 return "Finds the CM of each z-axis slice and applies a polynomial radial profile about it."; 06820 }
string EMAN::ApplyPolynomialProfileToHelix::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 6807 of file processor.h.
References NAME.
06808 { 06809 return NAME; 06810 }
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.
Reimplemented from EMAN::Processor.
Definition at line 6821 of file processor.h.
References EMAN::EMObject::FLOAT, EMAN::EMObject::INT, and EMAN::TypeDict::put().
06822 { 06823 TypeDict d; 06824 d.put("length", EMObject::FLOAT, "Helix length in angstroms."); 06825 d.put("z0", EMObject::INT, "z coordinate in pixels for the midpoint of the cylinder's axis, defaults to center of map"); 06826 return d; 06827 }
static Processor* EMAN::ApplyPolynomialProfileToHelix::NEW | ( | ) | [inline, static] |
Definition at line 6812 of file processor.h.
06813 { 06814 return new ApplyPolynomialProfileToHelix(); 06815 }
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.
image | The image to be processed. |
Implements EMAN::Processor.
Definition at line 9631 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(), in, EMAN::Processor::params, EMAN::ModelHelixProcessor::radprofile(), EMAN::Util::round(), and EMAN::Dict::set_default().
09632 { 09633 EMData * cyl = in; 09634 int nx = cyl->get_xsize(); 09635 int ny = cyl->get_ysize(); 09636 int nz = cyl->get_zsize(); 09637 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 09638 float apix_y = cyl->get_attr("apix_y"); 09639 float apix_z = cyl->get_attr("apix_z"); 09640 float lengthAngstroms = params["length"]; 09641 int z0 = params.set_default("z0", -1); //in voxels 09642 09643 if (z0 < 0 || z0 >= nz) 09644 z0 = nz / 2; 09645 09646 int z_start = Util::round( z0 - 0.5*lengthAngstroms/apix_z ); 09647 int z_stop = Util::round( z0 + 0.5*lengthAngstroms/apix_z ); 09648 09649 float * dat = cyl->get_data(); 09650 double rho_x_sum, rho_y_sum, rho_sum, x_cm, y_cm, radius; 09651 09652 for (int k = 0; k < nz; ++k) //taking slices along z axis 09653 { 09654 rho_x_sum = rho_y_sum = rho_sum = 0; //Set to zero for a new slice 09655 09656 if (k >= z_start && k <= z_stop) 09657 //Apply the radial profile only between z_start and z_stop on the z axis 09658 { 09659 //Calculating CM for the slice... 09660 for (int j = 0; j < ny; ++j) 09661 { 09662 for (int i = 0; i < nx; ++i, ++dat) 09663 { 09664 rho_x_sum += (*dat)*i; 09665 rho_y_sum += (*dat)*j; 09666 rho_sum += *dat; 09667 } 09668 } 09669 if (rho_sum != 0) 09670 { 09671 dat -= nx*ny;//going back to the beginning of the dat array 09672 x_cm = rho_x_sum/rho_sum; 09673 y_cm = rho_y_sum/rho_sum; 09674 09675 //Applying radial profile... 09676 for (int j=0; j<ny;++j) 09677 { 09678 for (int i=0;i<nx;++i,++dat) 09679 { 09680 radius = hypot( (i-x_cm)*apix_x, (j-y_cm)*apix_y ); 09681 *dat = radprofile((float)radius, 2);//Type 2 is the polynomial radial profile. 09682 } 09683 } 09684 } 09685 } 09686 else 09687 //Clear the map, setting the density to zero everywhere else. 09688 { 09689 for (int j=0; j<ny; j++) 09690 for(int i=0; i<nx; i++) 09691 { 09692 *dat = 0; 09693 dat++; 09694 } 09695 } 09696 09697 } 09698 }
const string ApplyPolynomialProfileToHelix::NAME = "math.poly_radial_profile" [static] |