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

Public Member Functions

string get_name () const
 Get the processor's name. More...
 
string get_desc () const
 Get the descrition of this specific processor. More...
 
TypeDict get_param_types () const
 Get processor parameter information in a dictionary. More...
 
void process_inplace (EMData *image)
 To process an image in-place. More...
 
- Public Member Functions inherited from EMAN::Processor
virtual ~Processor ()
 
virtual EMDataprocess (const EMData *const image)
 To proccess an image out-of-place. More...
 
virtual void process_list_inplace (vector< EMData * > &images)
 To process multiple images using the same algorithm. More...
 
virtual Dict get_params () const
 Get the processor parameters in a key/value dictionary. More...
 
virtual void set_params (const Dict &new_params)
 Set the processor parameters using a key/value dictionary. More...
 

Static Public Member Functions

static ProcessorNEW ()
 
- Static Public Member Functions inherited from EMAN::Processor
static string get_group_desc ()
 Get the description of this group of processors. More...
 
static void EMFourierFilterInPlace (EMData *fimage, Dict params)
 Compute a Fourier-filter processed image in place. More...
 
static EMDataEMFourierFilter (EMData *fimage, Dict params)
 Compute a Fourier-processor processed image without altering the original image. More...
 

Static Public Attributes

static const string NAME = "normalize.bymass"
 

Additional Inherited Members

- Public Types inherited from EMAN::Processor
enum  fourier_filter_types {
  TOP_HAT_LOW_PASS , TOP_HAT_HIGH_PASS , TOP_HAT_BAND_PASS , TOP_HOMOMORPHIC ,
  GAUSS_LOW_PASS , GAUSS_HIGH_PASS , GAUSS_BAND_PASS , GAUSS_INVERSE ,
  GAUSS_HOMOMORPHIC , BUTTERWORTH_LOW_PASS , BUTTERWORTH_HIGH_PASS , BUTTERWORTH_HOMOMORPHIC ,
  KAISER_I0 , KAISER_SINH , KAISER_I0_INVERSE , KAISER_SINH_INVERSE ,
  SHIFT , TANH_LOW_PASS , TANH_HIGH_PASS , TANH_HOMOMORPHIC ,
  TANH_BAND_PASS , RADIAL_TABLE , CTF_
}
 Fourier filter Processor type enum. More...
 
- Protected Attributes inherited from EMAN::Processor
Dict params
 

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
apixAngstrom per pixel of the image. If not set will use the apix_x attribute of the image
massThe approximate mass of protein/structure in kilodaltons
thrThe isosurface threshold which encapsulates the structure

Definition at line 6027 of file processor.h.

Member Function Documentation

◆ get_desc()

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

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

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

◆ get_name()

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

Get the processor's name.

Each processor is identified by a unique name.

Returns
The processor's name.

Implements EMAN::Processor.

Definition at line 6030 of file processor.h.

6031 {
6032 return NAME;
6033 }
static const string NAME
Definition: processor.h:6057

References NAME.

◆ get_param_types()

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

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

6046 {
6047 TypeDict d;
6048 d.put("apix", EMObject::FLOAT,"Angstrom per pixel of the image. If not set will use the apix_x attribute of the image");
6049 d.put("mass", EMObject::FLOAT,"The approximate mass of protein/structure in kilodaltons");
6050 d.put("thr", EMObject::FLOAT,"The isosurface threshold which encapsulates the structure");
6051 d.put("verbose", EMObject::INT,"If set will give details about the normalization");
6052 return d;
6053 }
TypeDict is a dictionary to store <string, EMObject::ObjectType> pair.
Definition: emobject.h:305
void put(const string &key, EMObject::ObjectType o, const string &desc="")
Definition: emobject.h:330

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

◆ NEW()

static Processor * EMAN::NormalizeByMassProcessor::NEW ( )
inlinestatic

Definition at line 6035 of file processor.h.

6036 {
6037 return new NormalizeByMassProcessor();
6038 }
Normalize the mass of the image assuming a density of 1.35 g/ml (0.81 Da/A^3).
Definition: processor.h:6028

◆ process_inplace()

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
imageThe image to be processed.

Implements EMAN::Processor.

Definition at line 4756 of file processor.cpp.

4757{
4758 float mass = params.set_default("mass",-1.0f);
4759 int verbose = params.set_default("verbose",0);
4760
4761 if (mass <= 0) throw InvalidParameterException("You must specify a positive non zero mass");
4762
4763 float tthr = params.set_default("thr",(float)image->get_attr("mean")+(float)image->get_attr("sigma"));
4764
4765 float apix = image->get_attr_default("apix_x",1.0f);
4766 apix = params.set_default("apix",apix);
4767
4768 if (apix <= 0) throw InvalidParameterException("You must specify a positive non zero apix");
4769
4770 float step = ((float)image->get_attr("sigma"))/5.0f;
4771
4772 if (step==0) throw InvalidParameterException("This image has sigma=0, cannot give it mass");
4773
4774
4775 size_t n = image->get_size();
4776 float* d = image->get_data();
4777
4778
4779 float thr=(float)image->get_attr("mean")+(float)image->get_attr("sigma")/2.0;
4780 int count=0;
4781 for (size_t i=0; i<n; ++i) {
4782 if (d[i]>=thr) ++count;
4783 }
4784 if (verbose) printf("apix=%1.3f\tmass=%1.1f\tthr=%1.2f\tstep=%1.3g\n",apix,mass,thr,step);
4785
4786 float max = image->get_attr("maximum");
4787 float min = image->get_attr("minimum");
4788 for (int j=0; j<4; j++) {
4789 int err=0;
4790 while (thr<max && count*apix*apix*apix*.81/1000.0>mass) {
4791 thr+=step;
4792 count=0;
4793 for (size_t i=0; i<n; ++i) {
4794 if (d[i]>=thr) ++count;
4795 }
4796 err+=1;
4797 if (err>1000) throw InvalidParameterException("Specified mass could not be achieved");
4798 if (verbose>1) printf("%d\t%d\t%1.3f\t%1.2f\n",err,count,thr,count*apix*apix*apix*.81/1000.0);
4799 }
4800
4801 step/=4.0;
4802
4803 while (thr>min && count*apix*apix*apix*.81/1000.0<mass) {
4804 thr-=step;
4805 count=0;
4806 for (size_t i=0; i<n; ++i) {
4807 if (d[i]>=thr) ++count;
4808 }
4809 err+=1;
4810 if (err>1000) throw InvalidParameterException("Specified mass could not be achieved");
4811 if (verbose>1) printf("%d\t%d\t%1.3f\t%1.2f\n",err,count,thr,count*apix*apix*apix*.81/1000.0);
4812
4813 }
4814 step/=4.0;
4815 }
4816
4817 // We don't adjust the map if we get a negative value
4818 if ((float)tthr/thr>0) image->mult((float)tthr/thr);
4819 else printf("WARNING: could not normalize map to specified mass.");
4820 image->update();
4821}
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
#define InvalidParameterException(desc)
Definition: exception.h:361

References InvalidParameterException, EMAN::Processor::params, and EMAN::Dict::set_default().

Member Data Documentation

◆ NAME

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

Definition at line 6057 of file processor.h.

Referenced by get_name().


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