EMAN::NormalizeByMassProcessor Class Reference

Normalize the mass of the image assuming a density of 1.35 g/ml (0.81 Da/A^3). More...

#include <processor.h>

Inheritance diagram for EMAN::NormalizeByMassProcessor:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

string get_name () const
 Get the processor's name.
string get_desc () const
 Get the descrition of this specific processor.
TypeDict get_param_types () const
 Get processor parameter information in a dictionary.
void process_inplace (EMData *image)
 To process an image in-place.

Static Public Member Functions

static ProcessorNEW ()

Static Public Attributes

static const string NAME = "normalize.bymass"

Detailed Description

Normalize the mass of the image assuming a density of 1.35 g/ml (0.81 Da/A^3).

Only works for 3D images. Essentially a replica of Volume.C in EMAN1.

Author:
David Woolford (a direct port of Steve Ludtke's code)
Date:
01/17/09
Parameters:
apix Angstrom per pixel of the image. If not set will use the apix_x attribute of the image
mass The approximate mass of protein/structure in kilodaltons
thr The isosurface threshold which encapsulates the structure

Definition at line 4240 of file processor.h.


Member Function Documentation

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

04254                         {
04255                                 return "Normalize the mass of the image assuming a density of 1.35 g/ml (0.81 Da/A^3) (3D only)";
04256                         }

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

References NAME.

04244                         {
04245                                 return NAME;
04246                         }

TypeDict EMAN::NormalizeByMassProcessor::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 4258 of file processor.h.

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

04259                         {
04260                                 TypeDict d;
04261                                 d.put("apix", EMObject::FLOAT,"Angstrom per pixel of the image. If not set will use the apix_x attribute of the image");
04262                                 d.put("mass", EMObject::FLOAT,"The approximate mass of protein/structure in kilodaltons");
04263                                 d.put("thr", EMObject::FLOAT,"The isosurface threshold which encapsulates the structure");
04264                                 return d;
04265                         }

static Processor* EMAN::NormalizeByMassProcessor::NEW (  )  [inline, static]

Definition at line 4248 of file processor.h.

04249                         {
04250                                 return new NormalizeByMassProcessor();
04251                         }

void NormalizeByMassProcessor::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:
image The image to be processed.

Implements EMAN::Processor.

Definition at line 3639 of file processor.cpp.

References EMAN::EMData::get_attr(), EMAN::EMData::get_data(), EMAN::EMData::get_size(), EMAN::EMData::has_attr(), InvalidParameterException, max, min, EMAN::EMData::mult(), EMAN::Processor::params, EMAN::Dict::set_default(), and EMAN::EMData::update().

03640 {
03641         float mass = params.set_default("mass",-1.0f);
03642 
03643         if (mass <= 0) throw InvalidParameterException("You must specify a positive non zero mass");
03644 
03645         float thr = params.set_default("thr",(float)image->get_attr("mean")+(float)image->get_attr("sigma"));
03646 
03647         float apix = params.set_default("apix",-1.123456789f);
03648         if (apix == -1.123456789 ) {
03649                 if (image->has_attr("apix_x")) {
03650                         apix = image->get_attr("apix_x");
03651                 }
03652         }
03653 
03654         if (apix <= 0) throw InvalidParameterException("You must specify a positive non zero apix");
03655 
03656         float step = ((float)image->get_attr("sigma"))/2.0f;
03657 
03658         int count=0;
03659         size_t n = image->get_size();
03660         float* d = image->get_data();
03661 
03662         for (size_t i=0; i<n; ++i) {
03663                 if (d[i]>=thr) ++count;
03664         }
03665 
03666         float max = image->get_attr("maximum");
03667         float min = image->get_attr("minimum");
03668         for (int j=0; j<4; j++) {
03669                 while (thr<max && count*apix*apix*apix*.81/1000.0>mass) {
03670                         thr+=step;
03671                         count=0;
03672                         for (size_t i=0; i<n; ++i) {
03673                                 if (d[i]>=thr) ++count;
03674                         }
03675                 }
03676 
03677                 step/=4.0;
03678 
03679                 while (thr>min && count*apix*apix*apix*.81/1000.0<mass) {
03680                         thr-=step;
03681                         count=0;
03682                         for (size_t i=0; i<n; ++i) {
03683                                 if (d[i]>=thr) ++count;
03684                         }
03685                 }
03686 
03687                 step/=4.0;
03688         }
03689 
03690         image->mult((float)1.0/thr);
03691         image->update();
03692 }


Member Data Documentation

const string NormalizeByMassProcessor::NAME = "normalize.bymass" [static]

Definition at line 4269 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Mon Jul 19 12:43:42 2010 for EMAN2 by  doxygen 1.4.7