EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes
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

static ProcessorNEW ()

Static Public Attributes

static const string NAME = "math.poly_radial_profile"

Detailed Description

Definition at line 7385 of file processor.h.


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

                {
                        return "Finds the CM of each z-axis slice and applies a polynomial radial profile about it.";
                }
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 7390 of file processor.h.

References NAME.

                {
                        return NAME;
                }
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 7404 of file processor.h.

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

                {
                        TypeDict d;
                        d.put("length", EMObject::FLOAT, "Helix length in angstroms.");
                        d.put("z0", EMObject::INT, "z coordinate in pixels for the midpoint of the cylinder's axis, defaults to center of map");
                        return d;
                }
static Processor* EMAN::ApplyPolynomialProfileToHelix::NEW ( ) [inline, static]

Definition at line 7395 of file processor.h.

                {
                        return new ApplyPolynomialProfileToHelix();
                }
void ApplyPolynomialProfileToHelix::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:
imageThe image to be processed.

Implements EMAN::Processor.

Definition at line 10532 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, nx, ny, EMAN::Processor::params, EMAN::Util::round(), and EMAN::Dict::set_default().

{
        EMData * cyl = in;
        int nx = cyl->get_xsize();
        int ny = cyl->get_ysize();
        int nz = cyl->get_zsize();
        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
        float apix_y = cyl->get_attr("apix_y");
        float apix_z = cyl->get_attr("apix_z");
        float lengthAngstroms = params["length"];
        int z0 = params.set_default("z0", -1); //in voxels

        if (z0 < 0 || z0 >= nz)
                z0 = nz / 2;

        int z_start = Util::round( z0 - 0.5*lengthAngstroms/apix_z );
        int z_stop = Util::round( z0 + 0.5*lengthAngstroms/apix_z );

        float * dat = cyl->get_data();
        double rho_x_sum, rho_y_sum, rho_sum, x_cm, y_cm, radius;

        for (int k = 0; k < nz; ++k) //taking slices along z axis
        {
                rho_x_sum = rho_y_sum = rho_sum = 0; //Set to zero for a new slice

                if (k >= z_start && k <= z_stop)
                //Apply the radial profile only between z_start and z_stop on the z axis
                {
                        //Calculating CM for the slice...
                        for (int j = 0; j < ny; ++j)
                        {
                                for (int i = 0; i < nx; ++i, ++dat)
                                {
                                        rho_x_sum += (*dat)*i;
                                        rho_y_sum += (*dat)*j;
                                        rho_sum += *dat;
                                }
                        }
                        if (rho_sum != 0)
                        {
                                dat -= nx*ny;//going back to the beginning of the dat array
                                x_cm = rho_x_sum/rho_sum;
                                y_cm = rho_y_sum/rho_sum;

                                //Applying radial profile...
                                for (int j=0; j<ny;++j)
                                {
                                        for (int i=0;i<nx;++i,++dat)
                                        {
                                                radius = hypot( (i-x_cm)*apix_x, (j-y_cm)*apix_y );
                                                *dat = radprofile((float)radius, 2);//Type 2 is the polynomial radial profile.
                                        }
                                }
                        }
                }
                else
                //Clear the map, setting the density to zero everywhere else.
                {
                        for (int j=0; j<ny; j++)
                                for(int i=0; i<nx; i++)
                                {
                                        *dat = 0;
                                        dat++;
                                }
                }

        }
}

Member Data Documentation

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

Definition at line 7412 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files: