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

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

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

References NAME.

04283                         {
04284                                 return NAME;
04285                         }

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

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

04298                         {
04299                                 TypeDict d;
04300                                 d.put("apix", EMObject::FLOAT,"Angstrom per pixel of the image. If not set will use the apix_x attribute of the image");
04301                                 d.put("mass", EMObject::FLOAT,"The approximate mass of protein/structure in kilodaltons");
04302                                 d.put("thr", EMObject::FLOAT,"The isosurface threshold which encapsulates the structure");
04303                                 return d;
04304                         }

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

Definition at line 4287 of file processor.h.

04288                         {
04289                                 return new NormalizeByMassProcessor();
04290                         }

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 3701 of file processor.cpp.

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

03702 {
03703         float mass = params.set_default("mass",-1.0f);
03704 
03705         if (mass <= 0) throw InvalidParameterException("You must specify a positive non zero mass");
03706 
03707         float thr = params.set_default("thr",(float)image->get_attr("mean")+(float)image->get_attr("sigma"));
03708 
03709         float apix = image->get_attr_default("apix_x",1.0f);
03710         apix = params.set_default("apix",apix);
03711 
03712         if (apix <= 0) throw InvalidParameterException("You must specify a positive non zero apix");
03713 
03714         float step = ((float)image->get_attr("sigma"))/2.0f;
03715 
03716         int count=0;
03717         size_t n = image->get_size();
03718         float* d = image->get_data();
03719 
03720         for (size_t i=0; i<n; ++i) {
03721                 if (d[i]>=thr) ++count;
03722         }
03723 
03724         float max = image->get_attr("maximum");
03725         float min = image->get_attr("minimum");
03726         for (int j=0; j<4; j++) {
03727                 while (thr<max && count*apix*apix*apix*.81/1000.0>mass) {
03728                         thr+=step;
03729                         count=0;
03730                         for (size_t i=0; i<n; ++i) {
03731                                 if (d[i]>=thr) ++count;
03732                         }
03733                 }
03734 
03735                 step/=4.0;
03736 
03737                 while (thr>min && count*apix*apix*apix*.81/1000.0<mass) {
03738                         thr-=step;
03739                         count=0;
03740                         for (size_t i=0; i<n; ++i) {
03741                                 if (d[i]>=thr) ++count;
03742                         }
03743                 }
03744 
03745                 step/=4.0;
03746         }
03747 
03748         image->mult((float)1.0/thr);
03749         image->update();
03750 }


Member Data Documentation

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

Definition at line 4308 of file processor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Fri Aug 10 16:36:19 2012 for EMAN2 by  doxygen 1.4.7