EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes
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:
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 4475 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 4488 of file processor.h.

                        {
                                return "Normalize the mass of the image assuming a density of 1.35 g/ml (0.81 Da/A^3) (3D only)";
                        }
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 4478 of file processor.h.

References NAME.

                        {
                                return NAME;
                        }
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 4493 of file processor.h.

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

                        {
                                TypeDict d;
                                d.put("apix", EMObject::FLOAT,"Angstrom per pixel of the image. If not set will use the apix_x attribute of the image");
                                d.put("mass", EMObject::FLOAT,"The approximate mass of protein/structure in kilodaltons");
                                d.put("thr", EMObject::FLOAT,"The isosurface threshold which encapsulates the structure");
                                d.put("verbose", EMObject::INT,"If set will give details about the normalization");
                                return d;
                        }
static Processor* EMAN::NormalizeByMassProcessor::NEW ( ) [inline, static]

Definition at line 4483 of file processor.h.

                        {
                                return new NormalizeByMassProcessor();
                        }
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 3765 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().

{
        float mass = params.set_default("mass",-1.0f);
        int verbose = params.set_default("verbose",0);

        if (mass <= 0) throw InvalidParameterException("You must specify a positive non zero mass");

        float tthr = params.set_default("thr",(float)image->get_attr("mean")+(float)image->get_attr("sigma"));

        float apix = image->get_attr_default("apix_x",1.0f);
        apix = params.set_default("apix",apix);

        if (apix <= 0) throw InvalidParameterException("You must specify a positive non zero apix");

        float step = ((float)image->get_attr("sigma"))/5.0f;

        if (step==0) throw InvalidParameterException("This image has sigma=0, cannot give it mass");


        size_t n = image->get_size();
        float* d = image->get_data();


        float thr=(float)image->get_attr("mean")+(float)image->get_attr("sigma")/2.0;
        int count=0;
        for (size_t i=0; i<n; ++i) {
                if (d[i]>=thr) ++count;
        }
        if (verbose) printf("apix=%1.3f\tmass=%1.1f\tthr=%1.2f\tstep=%1.3g\n",apix,mass,thr,step);

        float max = image->get_attr("maximum");
        float min = image->get_attr("minimum");
        for (int j=0; j<4; j++) {
                int err=0;
                while (thr<max && count*apix*apix*apix*.81/1000.0>mass) {
                        thr+=step;
                        count=0;
                        for (size_t i=0; i<n; ++i) {
                                if (d[i]>=thr) ++count;
                        }
                        err+=1;
                        if (err>1000) throw InvalidParameterException("Specified mass could not be achieved");
                        if (verbose>1) printf("%d\t%d\t%1.3f\t%1.2f\n",err,count,thr,count*apix*apix*apix*.81/1000.0);
                }

                step/=4.0;

                while (thr>min && count*apix*apix*apix*.81/1000.0<mass) {
                        thr-=step;
                        count=0;
                        for (size_t i=0; i<n; ++i) {
                                if (d[i]>=thr) ++count;
                        }
                        err+=1;
                        if (err>1000) throw InvalidParameterException("Specified mass could not be achieved");
                        if (verbose>1) printf("%d\t%d\t%1.3f\t%1.2f\n",err,count,thr,count*apix*apix*apix*.81/1000.0);

                }
                step/=4.0;
        }

        image->mult((float)tthr/thr);
        image->update();
}

Member Data Documentation

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

Definition at line 4505 of file processor.h.

Referenced by get_name().


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