#include <processor.h>
Inheritance diagram for EMAN::NormalizeByMassProcessor:
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 Processor * | NEW () |
Static Public Attributes | |
static const string | NAME = "normalize.bymass" |
Only works for 3D images. Essentially a replica of Volume.C in EMAN1.
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 4281 of file processor.h.
string EMAN::NormalizeByMassProcessor::get_desc | ( | ) | const [inline, virtual] |
Get the descrition of this specific processor.
This function must be overwritten by a subclass.
Implements EMAN::Processor.
Definition at line 4294 of file processor.h.
04295 { 04296 return "Normalize the mass of the image assuming a density of 1.35 g/ml (0.81 Da/A^3) (3D only)"; 04297 }
string EMAN::NormalizeByMassProcessor::get_name | ( | ) | const [inline, virtual] |
Get the processor's name.
Each processor is identified by a unique name.
Implements EMAN::Processor.
Definition at line 4284 of file processor.h.
References NAME.
04285 { 04286 return NAME; 04287 }
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.
Reimplemented from EMAN::Processor.
Definition at line 4299 of file processor.h.
References EMAN::EMObject::FLOAT, and EMAN::TypeDict::put().
04300 { 04301 TypeDict d; 04302 d.put("apix", EMObject::FLOAT,"Angstrom per pixel of the image. If not set will use the apix_x attribute of the image"); 04303 d.put("mass", EMObject::FLOAT,"The approximate mass of protein/structure in kilodaltons"); 04304 d.put("thr", EMObject::FLOAT,"The isosurface threshold which encapsulates the structure"); 04305 return d; 04306 }
static Processor* EMAN::NormalizeByMassProcessor::NEW | ( | ) | [inline, static] |
Definition at line 4289 of file processor.h.
04290 { 04291 return new NormalizeByMassProcessor(); 04292 }
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.
image | The image to be processed. |
Implements EMAN::Processor.
Definition at line 3703 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().
03704 { 03705 float mass = params.set_default("mass",-1.0f); 03706 03707 if (mass <= 0) throw InvalidParameterException("You must specify a positive non zero mass"); 03708 03709 float thr = params.set_default("thr",(float)image->get_attr("mean")+(float)image->get_attr("sigma")); 03710 03711 float apix = image->get_attr_default("apix_x",1.0f); 03712 apix = params.set_default("apix",apix); 03713 03714 if (apix <= 0) throw InvalidParameterException("You must specify a positive non zero apix"); 03715 03716 float step = ((float)image->get_attr("sigma"))/2.0f; 03717 03718 int count=0; 03719 size_t n = image->get_size(); 03720 float* d = image->get_data(); 03721 03722 for (size_t i=0; i<n; ++i) { 03723 if (d[i]>=thr) ++count; 03724 } 03725 03726 float max = image->get_attr("maximum"); 03727 float min = image->get_attr("minimum"); 03728 for (int j=0; j<4; j++) { 03729 while (thr<max && count*apix*apix*apix*.81/1000.0>mass) { 03730 thr+=step; 03731 count=0; 03732 for (size_t i=0; i<n; ++i) { 03733 if (d[i]>=thr) ++count; 03734 } 03735 } 03736 03737 step/=4.0; 03738 03739 while (thr>min && count*apix*apix*apix*.81/1000.0<mass) { 03740 thr-=step; 03741 count=0; 03742 for (size_t i=0; i<n; ++i) { 03743 if (d[i]>=thr) ++count; 03744 } 03745 } 03746 03747 step/=4.0; 03748 } 03749 03750 image->mult((float)1.0/thr); 03751 image->update(); 03752 }
const string NormalizeByMassProcessor::NAME = "normalize.bymass" [static] |