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

EMAN::SymSearchProcessor Class Reference

Identifiy the best symmetry in the given symmetry list for each pixel and then apply the best symmetry to each pixel. More...

#include <processor.h>

Inheritance diagram for EMAN::SymSearchProcessor:

Inheritance graph
[legend]
Collaboration diagram for EMAN::SymSearchProcessor:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual void process_inplace (EMData *image)
 To process an image in-place.
virtual string get_name () const
 Get the processor's name.
virtual string get_desc () const
 Get the descrition of this specific processor.
virtual TypeDict get_param_types () const
 Get processor parameter information in a dictionary.

Static Public Member Functions

ProcessorNEW ()

Static Public Attributes

const string NAME = "misc.symsearch"

Detailed Description

Identifiy the best symmetry in the given symmetry list for each pixel and then apply the best symmetry to each pixel.

Author:
Wen Jiang <wjiang@bcm.tmc.edu>
Date:
2005-1-9
Parameters:
sym[in] the list of symmetries to search
thresh[in] the minimal level of symmetry to be accepted (0-1)
output_symlabel[in] if output the symmetry label map in which the pixel value is the index of symmetry in the symmetry list
symlabel_map[out] the optional return map when output_symlabel=1

Definition at line 5230 of file processor.h.


Member Function Documentation

virtual string EMAN::SymSearchProcessor::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 5240 of file processor.h.

05241                 {
05242                         return "Identifiy the best symmetry in the given symmetry list for each pixel and then apply the best symmetry to each pixel.";
05243                 }

virtual string EMAN::SymSearchProcessor::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 5235 of file processor.h.

05236                 {
05237                         return NAME;
05238                 }

virtual TypeDict EMAN::SymSearchProcessor::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 5250 of file processor.h.

References EMAN::TypeDict::put().

05251                 {
05252                         TypeDict d;
05253                         d.put("sym", EMObject::STRINGARRAY, "the list of symmetries to search");
05254                         d.put("thresh", EMObject::FLOAT, "the minimal level of symmetry to be accepted (0-1)");
05255                         d.put("output_symlabel", EMObject::INT, "if output the symmetry label map in which the pixel value is the index of symmetry in the symmetry list");
05256                         d.put("symlabel_map", EMObject::EMDATA, "the optional return map when output_symlabel=1");
05257                         return d;
05258                 }

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

Definition at line 5245 of file processor.h.

05246                 {
05247                         return new SymSearchProcessor();
05248                 }

void SymSearchProcessor::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 5876 of file processor.cpp.

References EMAN::EMData::copy(), data, EMAN::Util::fast_floor(), EMAN::EMData::get_data(), EMAN::Symmetry3D::get_symmetries(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), LOGWARN, nx, ny, EMAN::Dict::put(), EMAN::Dict::size(), t, EMAN::EMData::to_zero(), EMAN::Util::trilinear_interpolate(), v, x, and y.

05877 {
05878         if (!image) {
05879                 LOGWARN("NULL Image");
05880                 return;
05881         }
05882         float thresh = params["thresh"];
05883         int output_symlabel = params["output_symlabel"];
05884 
05885         // set up all the symmetry transforms for all the searched symmetries
05886         const vector<string> sym_list = params["sym"];
05887         int sym_num = sym_list.size();
05888         vector< vector< Transform > > transforms(sym_num);
05889         vector< float* > symvals(sym_num);
05890         for (int i =0; i < sym_num; i++) {
05891                 vector<Transform> sym_transform =  Symmetry3D::get_symmetries(sym_list[i]);
05892                 transforms[i] = sym_transform;
05893                 symvals[i] = new float[sym_transform.size()]; // new float(nsym);
05894         }
05895 
05896         EMData *orig = image->copy();
05897 
05898         image->to_zero();
05899 
05900         int nx= image->get_xsize();
05901         int ny= image->get_ysize();
05902         int nz= image->get_zsize();
05903         int xy = nx * ny;
05904         float * data = image->get_data();
05905         float * sdata = orig->get_data();
05906 
05907         EMData *symlabel = 0;
05908         float * ldata = symlabel->get_data();
05909         if (output_symlabel) {
05910                 symlabel = image->copy();
05911                 symlabel->to_zero();
05912                 ldata = symlabel->get_data();
05913         }
05914 
05915         for (int k = 0; k < nz; k++) {
05916                 for (int j = 0; j < ny; j++) {
05917                         for(int i = 0; i < nx; i++) {
05918                                 size_t index = (size_t)k * nx * ny + j * nx + i;
05919                                 float val = sdata[ index ];
05920                                 float bestmean = val, bestsymlevel = FLT_MAX;
05921                                 int bestsym = 0;
05922                                 for( int sym = 0; sym< sym_num; sym++) {
05923                                         int cur_sym_num = transforms[sym].size();
05924                                         float *symval = symvals[sym];
05925                                         // first find out all the symmetry related location values
05926                                         for( int s = 0; s < cur_sym_num; s++){
05927                                                 Transform r = transforms[sym][s];
05928                                                 float x2 = (float)(r[0][0] * (i-nx/2) + r[0][1] * (j-ny/2) + r[0][2] * (k-nz/2) + nx / 2);
05929                                                 float y2 = (float)(r[1][0] * (i-nx/2) + r[1][1] * (j-ny/2) + r[1][2] * (k-nz/2) + ny / 2);
05930                                                 float z2 = (float)(r[2][0] * (i-nx/2) + r[2][1] * (j-ny/2) + r[2][2] * (k-nz/2) + nz / 2);
05931 
05932                                                 if (x2 >= 0 && y2 >= 0 && z2 >= 0 && x2 < (nx - 1) && y2 < (ny - 1)
05933                                                         && z2 < (nz - 1)) {
05934                                                         float x = (float)Util::fast_floor(x2);
05935                                                         float y = (float)Util::fast_floor(y2);
05936                                                         float z = (float)Util::fast_floor(z2);
05937 
05938                                                         float t = x2 - x;
05939                                                         float u = y2 - y;
05940                                                         float v = z2 - z;
05941 
05942                                                         size_t ii = x + y * nx + z * (size_t)xy;
05943 
05944                                                         symval[s]=
05945                                                                 Util::trilinear_interpolate(sdata[ii], sdata[ii + 1], sdata[ii + nx],
05946                                                                                                                         sdata[ii + nx + 1], sdata[ii + nx * ny],
05947                                                                                                                         sdata[ii + xy + 1], sdata[ii + xy + nx],
05948                                                                                                                         sdata[ii + xy + nx + 1], t, u, v);
05949                                                 }
05950                                                 else {
05951                                                         symval[s] = 0.0 ;
05952                                                 }
05953                                         }
05954                                         float tmean=0, tsigma=0;
05955                                         for( int s = 0; s < cur_sym_num; s++) {
05956                                                 tmean += symval[s];
05957                                                 tsigma += symval[s] * symval[s];
05958                                         }
05959                                         tmean /= cur_sym_num;
05960                                         tsigma = tsigma/cur_sym_num - tmean*tmean;
05961                                         if (tsigma < bestsymlevel ) {
05962                                                 bestsymlevel = tsigma;
05963                                                 bestmean = tmean;
05964                                                 bestsym = sym;
05965                                         }
05966                                 }
05967                                 if ( bestsymlevel > thresh) {
05968                                         if (output_symlabel) ldata[index] = (float)bestsym;
05969                                         data[index] = bestmean;
05970                                 }
05971                                 else {
05972                                         if (output_symlabel) ldata[index] = -1;
05973                                         data[index] = val;
05974                                 }
05975                         }
05976                 }
05977         }
05978         if( orig )
05979         {
05980                 delete orig;
05981                 orig = 0;
05982         }
05983         for (int i =0; i < sym_num; i++) {
05984                 if( symvals[i] )
05985                 {
05986                         delete symvals[i];
05987                         symvals[i] = 0;
05988                 }
05989         }
05990         if (symlabel) params.put("symlabel_map", EMObject(symlabel));
05991 }


Member Data Documentation

const string SymSearchProcessor::NAME = "misc.symsearch" [static]
 

Definition at line 181 of file processor.cpp.


The documentation for this class was generated from the following files:
Generated on Tue Jul 12 13:51:22 2011 for EMAN2 by  doxygen 1.3.9.1