EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes
EMAN::ShapeAnalyzer Class Reference

Shape characterization Computes a set of values characteristic of the shape of a volume. More...

#include <analyzer.h>

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

List of all members.

Public Member Functions

 ShapeAnalyzer ()
virtual int insert_image (EMData *image)
 insert a image to the list of input images
virtual vector< EMData * > analyze ()
 main function for Analyzer, analyze input images and create output images
string get_name () const
 Get the Analyzer's name.
string get_desc () const
 Get the Analyzer's description.
TypeDict get_param_types () const
 Get Analyzer parameter information in a dictionary.

Static Public Member Functions

static AnalyzerNEW ()

Static Public Attributes

static const string NAME = "shape"

Protected Attributes

int verbose
vector< EMData * > ret

Detailed Description

Shape characterization Computes a set of values characteristic of the shape of a volume.

The first 3 values are distributions along X, Y and Z axes respectively, and are not orientation independent.

Author:
Steve Ludtke
Date:
12/29/2013
Parameters:
verboseDisplay progress if set, more detail with larger numbers

Definition at line 181 of file analyzer.h.


Constructor & Destructor Documentation

EMAN::ShapeAnalyzer::ShapeAnalyzer ( ) [inline]

Definition at line 184 of file analyzer.h.

Referenced by NEW().

: verbose(0) {}

Member Function Documentation

vector< EMData * > ShapeAnalyzer::analyze ( ) [virtual]

main function for Analyzer, analyze input images and create output images

Returns:
vector<EMData *> result os images analysis

Implements EMAN::Analyzer.

Definition at line 125 of file analyzer.cpp.

References abs, EMAN::EMData::get_value_at(), ImageDimensionException, EMAN::Analyzer::images, EMAN::EMData::mult(), nx, ny, EMAN::Analyzer::params, ret, EMAN::Dict::set_default(), EMAN::EMData::set_value_at(), sqrt(), EMAN::EMData::to_zero(), v, verbose, x, and y.

                                        {
        int verbose = params.set_default("verbose",0);
        EMData *mx = new EMData(4,2,1); // result is 4 values
        mx->to_zero();
        ret.push_back(mx);

        if (images.size()!=1) throw ImageDimensionException("Shape computation accepts only a single volume as input");
        int nx=images[0]->get_xsize();
        int ny=images[0]->get_ysize();
        int nz=images[0]->get_zsize();
        if (nz==1 || ny==1 || nz==1) throw ImageDimensionException("Map must be 3-D");

        if (verbose>0) printf("Shape size: %d %d %d\n",nx,ny,nz);

        for (int z=0; z<nz; z++) {
                for (int y=0; y<ny; y++) {
                        for (int x=0; x<nx; x++) {
                                int xx=x-nx/2;
                                int yy=y-ny/2;
                                int zz=z-nz/2;
                                float v=images[0]->get_value_at(x,y,z);
                                mx->set_value_at(0,0,mx->get_value_at(0,0)+v*(xx*xx));
                                mx->set_value_at(1,0,mx->get_value_at(1,0)+v*(yy*yy));
                                mx->set_value_at(2,0,mx->get_value_at(2,0)+v*(zz*zz));
                                mx->set_value_at(3,0,mx->get_value_at(3,0)+v*(xx*xx+yy*yy+zz*zz)); 
                                // sum(m*r^2), in which r is the distance to the center. Used for minicircle classification
                                mx->set_value_at(0,1,mx->get_value_at(0,0)+v*abs(xx));
                                mx->set_value_at(1,1,mx->get_value_at(1,0)+v*abs(yy));
                                mx->set_value_at(2,1,mx->get_value_at(2,0)+v*abs(zz));
                                mx->set_value_at(3,1,mx->get_value_at(3,0)+v*(float)sqrt((float)(xx*xx+yy*yy+zz*zz)));
                        }
                }
        }
        mx->mult(1.0f/(nx*ny*nz));

        return ret;
}
string EMAN::ShapeAnalyzer::get_desc ( ) const [inline, virtual]

Get the Analyzer's description.

Returns:
The Analyzer's description.

Implements EMAN::Analyzer.

Definition at line 199 of file analyzer.h.

                {
                        return "Experimental. Computes a set of values characterizing a 3-D volume. Returns a 3x2x1 image containing X, Y and Z axial distributions using axis squared and axis linear weighting.";
                }
string EMAN::ShapeAnalyzer::get_name ( ) const [inline, virtual]

Get the Analyzer's name.

Each Analyzer is identified by a unique name.

Returns:
The Analyzer's name.

Implements EMAN::Analyzer.

Definition at line 194 of file analyzer.h.

References NAME.

                {
                        return NAME;
                }
TypeDict EMAN::ShapeAnalyzer::get_param_types ( ) const [inline, virtual]

Get Analyzer 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.

Implements EMAN::Analyzer.

Definition at line 209 of file analyzer.h.

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

                {
                        TypeDict d;
                        d.put("verbose", EMObject::INT, "Display progress if set, more detail with larger numbers");
                        return d;
                }
virtual int EMAN::ShapeAnalyzer::insert_image ( EMData image) [inline, virtual]

insert a image to the list of input images

Parameters:
image
Returns:
int 0 for success, <0 for fail

Implements EMAN::Analyzer.

Definition at line 186 of file analyzer.h.

References EMAN::Analyzer::images.

                                                        {
                        images.push_back(image);
                        if (images.size()>1) { printf("ShapeAnalyzer takes only a single image\n"); return 1; }
                        return 0;
                }
static Analyzer* EMAN::ShapeAnalyzer::NEW ( ) [inline, static]

Definition at line 204 of file analyzer.h.

References ShapeAnalyzer().

                {
                        return new ShapeAnalyzer();
                }

Member Data Documentation

const string EMAN::ShapeAnalyzer::NAME = "shape" [static]

Definition at line 216 of file analyzer.h.

Referenced by get_name().

vector<EMData *> EMAN::ShapeAnalyzer::ret [protected]

Definition at line 220 of file analyzer.h.

Referenced by analyze().

Definition at line 219 of file analyzer.h.

Referenced by analyze().


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