Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

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 4200 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 4213 of file processor.h.

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

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 4203 of file processor.h.

References NAME.

04204                         {
04205                                 return NAME;
04206                         }

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 4218 of file processor.h.

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

04219                         {
04220                                 TypeDict d;
04221                                 d.put("apix", EMObject::FLOAT,"Angstrom per pixel of the image. If not set will use the apix_x attribute of the image");
04222                                 d.put("mass", EMObject::FLOAT,"The approximate mass of protein/structure in kilodaltons");
04223                                 d.put("thr", EMObject::FLOAT,"The isosurface threshold which encapsulates the structure");
04224                                 return d;
04225                         }

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

Definition at line 4208 of file processor.h.

04209                         {
04210                                 return new NormalizeByMassProcessor();
04211                         }

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 3532 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().

03533 {
03534         float mass = params.set_default("mass",-1.0f);
03535 
03536         if (mass <= 0) throw InvalidParameterException("You must specify a positive non zero mass");
03537 
03538         float thr = params.set_default("thr",(float)image->get_attr("mean")+(float)image->get_attr("sigma"));
03539 
03540         float apix = params.set_default("apix",-1.123456789f);
03541         if (apix == -1.123456789 ) {
03542                 if (image->has_attr("apix_x")) {
03543                         apix = image->get_attr("apix_x");
03544                 }
03545         }
03546 
03547         if (apix <= 0) throw InvalidParameterException("You must specify a positive non zero apix");
03548 
03549         float step = ((float)image->get_attr("sigma"))/2.0f;
03550 
03551         int count=0;
03552         size_t n = image->get_size();
03553         float* d = image->get_data();
03554 
03555         for (size_t i=0; i<n; ++i) {
03556                 if (d[i]>=thr) ++count;
03557         }
03558 
03559         float max = image->get_attr("maximum");
03560         float min = image->get_attr("minimum");
03561         for (int j=0; j<4; j++) {
03562                 while (thr<max && count*apix*apix*apix*.81/1000.0>mass) {
03563                         thr+=step;
03564                         count=0;
03565                         for (size_t i=0; i<n; ++i) {
03566                                 if (d[i]>=thr) ++count;
03567                         }
03568                 }
03569 
03570                 step/=4.0;
03571 
03572                 while (thr>min && count*apix*apix*apix*.81/1000.0<mass) {
03573                         thr-=step;
03574                         count=0;
03575                         for (size_t i=0; i<n; ++i) {
03576                                 if (d[i]>=thr) ++count;
03577                         }
03578                 }
03579 
03580                 step/=4.0;
03581         }
03582 
03583         image->mult((float)1.0/thr);
03584         image->update();
03585 }


Member Data Documentation

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

Definition at line 4229 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Tue May 25 17:37:27 2010 for EMAN2 by  doxygen 1.4.4