EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
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]

Public Member Functions

 InertiaMatrixAnalyzer ()
 
virtual int insert_image (EMData *image)
 insert a image to the list of input images More...
 
virtual vector< EMData * > analyze ()
 main function for Analyzer, analyze input images and create output images More...
 
string get_name () const
 Get the Analyzer's name. More...
 
string get_desc () const
 Get the Analyzer's description. More...
 
TypeDict get_param_types () const
 Get Analyzer parameter information in a dictionary. More...
 
- Public Member Functions inherited from EMAN::Analyzer
 Analyzer ()
 
virtual ~Analyzer ()
 
virtual int insert_images_list (vector< EMData * > image_list)
 insert a list of images to the list of input images More...
 
virtual void set_params (const Dict &new_params)
 Set the Analyzer parameters using a key/value dictionary. More...
 
virtual Dict get_params () const
 Get the Reconstructor's parameters in a key/value dictionary. More...
 

Static Public Member Functions

static AnalyzerNEW ()
 

Static Public Attributes

static const string NAME = "inertiamatrix"
 

Protected Attributes

int verbose
 
vector< EMData * > ret
 
- Protected Attributes inherited from EMAN::Analyzer
Dict params
 
vector< EMData * > images
 

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 127 of file analyzer.h.

Constructor & Destructor Documentation

◆ InertiaMatrixAnalyzer()

EMAN::InertiaMatrixAnalyzer::InertiaMatrixAnalyzer ( )
inline

Definition at line 130 of file analyzer.h.

Referenced by NEW().

Member Function Documentation

◆ analyze()

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 78 of file analyzer.cpp.

78 {
79 int verbose = params.set_default("verbose",0);
80 EMData *mx = new EMData(3,3); // result is a 3x3 matrix
81 mx->to_zero();
82 ret.push_back(mx);
83
84 if (images.size()!=1) throw ImageDimensionException("Inertia matrix computation accepts only a single volume as input");
85 int nx=images[0]->get_xsize();
86 int ny=images[0]->get_ysize();
87 int nz=images[0]->get_zsize();
88 if (nz==1 || ny==1 || nz==1) throw ImageDimensionException("Map must be 3-D");
89
90 if (verbose>0) printf("Inertia volume size: %d %d %d\n",nx,ny,nz);
91
92 for (int z=0; z<nz; z++) {
93 for (int y=0; y<ny; y++) {
94 for (int x=0; x<nx; x++) {
95 int xx=x-nx/2;
96 int yy=y-ny/2;
97 int zz=z-nz/2;
98 float v=images[0]->get_value_at(x,y,z);
99 mx->set_value_at(0,0,mx->get_value_at(0,0)+v*(yy*yy+zz*zz));
100 mx->set_value_at(0,1,mx->get_value_at(0,1)+v*(-xx*yy));
101 mx->set_value_at(0,2,mx->get_value_at(0,2)+v*(-xx*zz));
102 mx->set_value_at(1,0,mx->get_value_at(1,0)+v*(-xx*yy));
103 mx->set_value_at(1,1,mx->get_value_at(1,1)+v*(zz*zz+xx*xx));
104 mx->set_value_at(1,2,mx->get_value_at(1,2)+v*(-yy*zz));
105 mx->set_value_at(2,0,mx->get_value_at(2,0)+v*(-xx*zz));
106 mx->set_value_at(2,1,mx->get_value_at(2,1)+v*(-yy*zz));
107 mx->set_value_at(2,2,mx->get_value_at(2,2)+v*(xx*xx+yy*yy));
108 }
109 }
110 }
111 mx->mult(1.0f/(nx*ny*nz));
112
113 if (verbose>0) {
114 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));
115 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));
116 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));
117 }
118
119 return ret;
120}
vector< EMData * > images
Definition: analyzer.h:117
type set_default(const string &key, type val)
Default setting behavior This can be achieved using a template - d.woolford Jan 2008 (before there wa...
Definition: emobject.h:569
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
vector< EMData * > ret
Definition: analyzer.h:166
#define ImageDimensionException(desc)
Definition: exception.h:166
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

References ImageDimensionException, EMAN::Analyzer::images, EMAN::Analyzer::params, ret, EMAN::Dict::set_default(), verbose, x, and y.

◆ get_desc()

string EMAN::InertiaMatrixAnalyzer::get_desc ( ) const
inlinevirtual

Get the Analyzer's description.

Returns
The Analyzer's description.

Implements EMAN::Analyzer.

Definition at line 145 of file analyzer.h.

146 {
147 return "Compute Inertia matrix for a volume";
148 }

◆ get_name()

string EMAN::InertiaMatrixAnalyzer::get_name ( ) const
inlinevirtual

Get the Analyzer's name.

Each Analyzer is identified by a unique name.

Returns
The Analyzer's name.

Implements EMAN::Analyzer.

Definition at line 140 of file analyzer.h.

141 {
142 return NAME;
143 }
static const string NAME
Definition: analyzer.h:162

References NAME.

◆ get_param_types()

TypeDict EMAN::InertiaMatrixAnalyzer::get_param_types ( ) const
inlinevirtual

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 155 of file analyzer.h.

156 {
157 TypeDict d;
158 d.put("verbose", EMObject::INT, "Display progress if set, more detail with larger numbers");
159 return d;
160 }

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

◆ insert_image()

virtual int EMAN::InertiaMatrixAnalyzer::insert_image ( EMData image)
inlinevirtual

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 132 of file analyzer.h.

132 {
133 images.push_back(image);
134 if (images.size()>1) { printf("InertiaMatrixAnalyzer takes only a single image\n"); return 1; }
135 return 0;
136 }

References EMAN::Analyzer::images.

◆ NEW()

static Analyzer * EMAN::InertiaMatrixAnalyzer::NEW ( )
inlinestatic

Definition at line 150 of file analyzer.h.

151 {
152 return new InertiaMatrixAnalyzer();
153 }

References InertiaMatrixAnalyzer().

Member Data Documentation

◆ NAME

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

Definition at line 162 of file analyzer.h.

Referenced by get_name().

◆ ret

vector<EMData *> EMAN::InertiaMatrixAnalyzer::ret
protected

Definition at line 166 of file analyzer.h.

Referenced by analyze().

◆ verbose

int EMAN::InertiaMatrixAnalyzer::verbose
protected

Definition at line 165 of file analyzer.h.

Referenced by analyze().


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