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

Inertia Matrix computer Computes the Inertia Matrix for a 3-D volume. More...

#include <analyzer.h>

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

List of all members.

Public Member Functions

 InertiaMatrixAnalyzer ()
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 = "inertiamatrix"

Protected Attributes

int verbose
vector< EMData * > ret

Detailed Description

Inertia Matrix computer Computes the Inertia Matrix for a 3-D volume.

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

Definition at line 131 of file analyzer.h.


Constructor & Destructor Documentation

EMAN::InertiaMatrixAnalyzer::InertiaMatrixAnalyzer ( ) [inline]

Definition at line 134 of file analyzer.h.

Referenced by NEW().

: verbose(0) {}

Member Function Documentation

vector< EMData * > InertiaMatrixAnalyzer::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 81 of file analyzer.cpp.

References 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(), EMAN::EMData::to_zero(), v, verbose, x, and y.

                                                {
        int verbose = params.set_default("verbose",0);
        EMData *mx = new EMData(3,3);   // result is a 3x3 matrix
        mx->to_zero();
        ret.push_back(mx);

        if (images.size()!=1) throw ImageDimensionException("Inertia matrix 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("Inertia volume 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*(yy*yy+zz*zz));
                                mx->set_value_at(0,1,mx->get_value_at(0,1)+v*(-xx*yy));
                                mx->set_value_at(0,2,mx->get_value_at(0,2)+v*(-xx*zz));
                                mx->set_value_at(1,0,mx->get_value_at(1,0)+v*(-xx*yy));
                                mx->set_value_at(1,1,mx->get_value_at(1,1)+v*(zz*zz+xx*xx));
                                mx->set_value_at(1,2,mx->get_value_at(1,2)+v*(-yy*zz));
                                mx->set_value_at(2,0,mx->get_value_at(2,0)+v*(-xx*zz));
                                mx->set_value_at(2,1,mx->get_value_at(2,1)+v*(-yy*zz));
                                mx->set_value_at(2,2,mx->get_value_at(2,2)+v*(xx*xx+yy*yy));
                        }
                }
        }
        mx->mult(1.0f/(nx*ny*nz));

        if (verbose>0) {
                printf("%1.3g\t%1.3g\t%1.3g\n",mx->get_value_at(0,0),mx->get_value_at(1,0),mx->get_value_at(2,0));
                printf("%1.3g\t%1.3g\t%1.3g\n",mx->get_value_at(0,1),mx->get_value_at(1,1),mx->get_value_at(2,1));
                printf("%1.3g\t%1.3g\t%1.3g\n",mx->get_value_at(0,2),mx->get_value_at(1,2),mx->get_value_at(2,2));
        }

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

Get the Analyzer's description.

Returns:
The Analyzer's description.

Implements EMAN::Analyzer.

Definition at line 149 of file analyzer.h.

                {
                        return "Compute Inertia matrix for a volume";
                }
string EMAN::InertiaMatrixAnalyzer::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 144 of file analyzer.h.

References NAME.

                {
                        return NAME;
                }
TypeDict EMAN::InertiaMatrixAnalyzer::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 159 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::InertiaMatrixAnalyzer::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 136 of file analyzer.h.

References EMAN::Analyzer::images.

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

Definition at line 154 of file analyzer.h.

References InertiaMatrixAnalyzer().

                {
                        return new InertiaMatrixAnalyzer();
                }

Member Data Documentation

const string EMAN::InertiaMatrixAnalyzer::NAME = "inertiamatrix" [static]

Definition at line 166 of file analyzer.h.

Referenced by get_name().

Definition at line 170 of file analyzer.h.

Referenced by analyze().

Definition at line 169 of file analyzer.h.

Referenced by analyze().


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