EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes
EMAN::DirectionalSumProcessor Class Reference

Does a projection in one the axial directions Doesn't support process_inplace (because the output has potentially been compressed in one dimension) More...

#include <processor.h>

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

List of all members.

Public Member Functions

virtual string get_name () const
 Get the processor's name.
virtual EMDataprocess (const EMData *const image)
 
Exceptions:
InvalidParameterExceptionraised if the direction parameter is not "x", "y" or "z"

virtual void process_inplace (EMData *)
 
Exceptions:
InvalidCallExceptionraised if this function is called

virtual TypeDict get_param_types () const
 Get processor parameter information in a dictionary.
string get_desc () const
 Get the descrition of this specific processor.

Static Public Member Functions

static ProcessorNEW ()

Static Public Attributes

static const string NAME = "misc.directional_sum"

Detailed Description

Does a projection in one the axial directions Doesn't support process_inplace (because the output has potentially been compressed in one dimension)

Parameters:
directionThe direction of the sum, either x,y or z

Definition at line 5931 of file processor.h.


Member Function Documentation

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

                {
                        return "Calculates the projection of the image along one of the axial directions, either x, y or z";
                }
virtual string EMAN::DirectionalSumProcessor::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 5934 of file processor.h.

References NAME.

                {
                        return NAME;
                }
virtual TypeDict EMAN::DirectionalSumProcessor::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 5956 of file processor.h.

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

                {
                        TypeDict d;
                        d.put("axis", EMObject::STRING,"The direction of the sum, either x,y or z. Returned axes are xy, xz or zy.");
                        d.put("first", EMObject::INT,"The first position along the speficied axis to use in the sum. Neg val -> nx/y/z+first (default=0)");
                        d.put("last", EMObject::INT,"The last position along the speficied axis to use in the sum. Neg val -> nx/y/z+last (default=-1)");
                        return d;
                }
static Processor* EMAN::DirectionalSumProcessor::NEW ( ) [inline, static]

Definition at line 5939 of file processor.h.

                {
                        return new DirectionalSumProcessor();
                }
EMData * DirectionalSumProcessor::process ( const EMData *const  image) [virtual]

Exceptions:
InvalidParameterExceptionraised if the direction parameter is not "x", "y" or "z"

Reimplemented from EMAN::Processor.

Definition at line 7300 of file processor.cpp.

References EMAN::EMData::get_value_at(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), InvalidParameterException, nx, ny, EMAN::Processor::params, EMAN::Dict::set_default(), EMAN::EMData::set_size(), EMAN::EMData::set_value_at(), EMAN::EMData::update(), and x.

                                                                   {
        string dir = params.set_default("axis", "");
        if ( dir == "" || ( dir != "x" && dir != "y" && dir != "z" ) )
                throw InvalidParameterException("The direction parameter must be either x, y, or z");

        int nx = image->get_xsize();
        int ny = image->get_ysize();
        int nz = image->get_zsize();

        int a0 = params.set_default("first", 0);
        int a1 = params.set_default("last", -1);

        EMData* ret = new EMData;
        // compress one of the dimensions
        if ( dir == "x" ) {
                ret->set_size(nz,ny);

                // bounds checks
                if (a0<0) a0+=nx;
                if (a1<0) a1+=nx;
                if (a0<0) a0=0;
                if (a1<0) a1=0;
                if (a0>=nx) a0=nx-1;
                if (a1>=nx) a1=nx-1;

                for (int y=0; y<ny; y++) {
                        for (int z=0; z<nz; z++) {
                                double sum=0.0;
                                for (int x=a0; x<=a1; x++) sum+=image->get_value_at(x,y,z);
                                ret->set_value_at(z,y,(float)sum);
                        }
                }
        }
        else if ( dir == "y" ) {
                ret->set_size(nx,nz);

                // bounds checks
                if (a0<0) a0+=ny;
                if (a1<0) a1+=ny;
                if (a0<0) a0=0;
                if (a1<0) a1=0;
                if (a0>=ny) a0=ny-1;
                if (a1>=ny) a1=ny-1;

                for (int x=0; x<nx; x++) {
                        for (int z=0; z<nz; z++) {
                                double sum=0.0;
                                for (int y=a0; y<=a1; y++) sum+=image->get_value_at(x,y,z);
                                ret->set_value_at(x,z,(float)sum);
                        }
                }
        }
        else if ( dir == "z" ) {
                ret->set_size(nx,ny);

                // bounds checks
                if (a0<0) a0+=nz;
                if (a1<0) a1+=nz;
                if (a0<0) a0=0;
                if (a1<0) a1=0;
                if (a0>=nz) a0=nz-1;
                if (a1>=nz) a1=nz-1;

                for (int y=0; y<ny; y++) {
                        for (int x=0; x<nx; x++) {
                                double sum=0.0;
                                for (int z=a0; z<=a1; z++) sum+=image->get_value_at(x,y,z);
                                ret->set_value_at(x,y,(float)sum);
                        }
                }
        }

        ret->update();
        return ret;
}
virtual void EMAN::DirectionalSumProcessor::process_inplace ( EMData ) [inline, virtual]

Exceptions:
InvalidCallExceptionraised if this function is called

Implements EMAN::Processor.

Definition at line 5952 of file processor.h.

References InvalidCallException.

                                                      {
                        throw InvalidCallException("The directional sum processor does not work inplace");
                }

Member Data Documentation

const string DirectionalSumProcessor::NAME = "misc.directional_sum" [static]

Definition at line 5970 of file processor.h.

Referenced by get_name().


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