EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
EMAN::SegmentSubunitProcessor Class Reference

This tries to extract a single subunit from a symmetric structure. More...

#include <processor.h>

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

Public Member Functions

virtual void process_inplace (EMData *image)
 To process an image in-place. More...
 
virtual string get_name () const
 Get the processor's name. More...
 
virtual string get_desc () const
 Get the descrition of this specific processor. More...
 
virtual TypeDict get_param_types () const
 Get processor parameter information in a dictionary. 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 = "segment.subunit"
 

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

This tries to extract a single subunit from a symmetric structure.

The borders between subunits may well be structurally ambiguous.

Parameters
symSymmetry of map
thrDensity threshold

Definition at line 7736 of file processor.h.

Member Function Documentation

◆ get_desc()

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

7747 {
7748 return "This will attempt to mask out a single subunit from a symmetric structure. There may be some ambiguity at the intersection, so the result may not be unambiguous.";
7749 }

◆ get_name()

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

7742 {
7743 return NAME;
7744 }
static const string NAME
Definition: processor.h:7765

References NAME.

◆ get_param_types()

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

7757 {
7758 TypeDict d;
7759 d.put("thr", EMObject::FLOAT, "Minimum density to consider for extraction");
7760 d.put("sym", EMObject::STRING, "Symmetry");
7761// d.put("seed", EMObject::EMDATA, "An (optional) single level mask volume to use as a seed after symmetrizing");
7762 return d;
7763 }
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::TypeDict::put(), and EMAN::EMObject::STRING.

◆ NEW()

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

Definition at line 7751 of file processor.h.

7752 {
7753 return new SegmentSubunitProcessor();
7754 }
This tries to extract a single subunit from a symmetric structure.
Definition: processor.h:7737

◆ process_inplace()

void SegmentSubunitProcessor::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 7238 of file processor.cpp.

7239{
7240 if (!image) {
7241 LOGWARN("NULL Image");
7242 return;
7243 }
7244
7245 float thr = params["thr"];
7246 string symname=(string)params["sym"];
7247 Symmetry3D* sym = Factory<Symmetry3D>::get(symname);
7248
7249 int nx = image->get_xsize();
7250 int ny = image->get_ysize();
7251 int nz = image->get_zsize();
7252
7253 if (ny == 1 || nz==1) {
7254 LOGERR("Error: segment.subunit works only in 3-D");
7255 return;
7256 }
7257
7258 // there are other strategies which might allow us to avoid the extra copy, but this will have to do for now
7259 EMData *image1=new EMData(nx,ny,nz);
7260 image1->to_zero();
7261 EMData *image2=image->copy();
7262
7263 // We're using image2 here temporarily to seed image1. We will reinitialize it when done
7264 image2->process_inplace("mask.sharp",Dict("inner_radius",(int)nz/5)); // we don't want to seed too close to the middle
7265 IntPoint ml=image2->calc_max_location(); // highest pixel value, now we symmetrize
7266
7267 // Seed the multi-level mask
7268 int i=0;
7269 vector<Transform> transforms = sym->get_syms();
7270 for(vector<Transform>::const_iterator trans_it = transforms.begin(); trans_it != transforms.end(); trans_it++) {
7271 Transform t = *trans_it;
7272 i++;
7273 Vec3f xf = t.transform(ml[0]-nx/2,ml[1]-ny/2,ml[2]-nz/2);
7274 image1->set_value_at((int)(xf[0]+nx/2),(int)(xf[1]+ny/2),(int)(xf[2]+nz/2),(float)i);
7275 }
7276 memcpy(image2->get_data(),image1->get_data(),image1->get_size()*sizeof(float)); // copy the seed from image 1 to image 2
7277
7278
7279
7280 // We progressively lower the threshold, sort of like a very coarse watershed
7281 float max=(float)image->get_attr("maximum");
7282 float gap=max-thr;
7283 if (gap<=0) throw InvalidParameterException("SegmentSubunitProcessor: threshold must be < max value");
7284
7285 for (int ti=0; ti<12; ti++) {
7286 float thr2=max-(ti+1)*gap/12.0;
7287 printf("threshold %1.4f\n",thr2);
7288 int change=1;
7289 while (change) {
7290 change=0;
7291 for (int z = 1; z < nz - 1; z++) {
7292 for (int y = 1; y < ny - 1; y++) {
7293 for (int x = 1; x < nx - 1; x++) {
7294 // Skip the voxel if already part of a mask or if below threshold
7295 if (image1->get_value_at(x,y,z)>0 || image->get_value_at(x,y,z)<thr2) continue;
7296
7297 // Note that this produces a directional bias in the case of ambiguous pixels
7298 // While this could be improved upon slightly, there can be truly ambiguous cases
7299 // and at least this method is deterministic
7300 if (image1->get_value_at(x-1,y,z)>0) { image2->set_value_at_fast(x,y,z,image1->get_value_at(x-1,y,z)); change=1; }
7301 else if (image1->get_value_at(x+1,y,z)>0) { image2->set_value_at_fast(x,y,z,image1->get_value_at(x+1,y,z)); change=1; }
7302 else if (image1->get_value_at(x,y-1,z)>0) { image2->set_value_at_fast(x,y,z,image1->get_value_at(x,y-1,z)); change=1; }
7303 else if (image1->get_value_at(x,y+1,z)>0) { image2->set_value_at_fast(x,y,z,image1->get_value_at(x,y+1,z)); change=1; }
7304 else if (image1->get_value_at(x,y,z-1)>0) { image2->set_value_at_fast(x,y,z,image1->get_value_at(x,y,z-1)); change=1; }
7305 else if (image1->get_value_at(x,y,z+1)>0) { image2->set_value_at_fast(x,y,z,image1->get_value_at(x,y,z+1)); change=1; }
7306
7307 }
7308 }
7309 }
7310 memcpy(image1->get_data(),image2->get_data(),image1->get_size()*sizeof(float));
7311 }
7312// char fs[20];
7313// sprintf(fs,"lvl%d.hdf",ti);
7314// image1->write_image(fs);
7315 }
7316
7317// image1->write_image("multilev.hdf");
7318// image1->process_inplace("threshold.abovetozero",Dict("maxval",(float)1.01f));
7319// image->mult(*image1);
7320
7321 // our final return value is the multilevel mask
7322 memcpy(image->get_data(),image1->get_data(),image1->get_size()*sizeof(float));
7323
7324 delete image1;
7325 delete image2;
7326 delete sym;
7327 image->update();
7328}
Dict is a dictionary to store <string, EMObject> pair.
Definition: emobject.h:385
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
static T * get(const string &instance_name)
Definition: emobject.h:781
IntPoint defines an integer-coordinate point in a 1D/2D/3D space.
Definition: geometry.h:192
Symmetry3D - A base class for 3D Symmetry objects.
Definition: symmetry.h:57
virtual vector< Transform > get_syms() const
Definition: symmetry.cpp:1224
A Transform object is a somewhat specialized object designed specifically for EMAN2/Sparx storage of ...
Definition: transform.h:75
Vec2f transform(const float &x, const float &y) const
Transform 2D coordinates using the internal transformation matrix.
Definition: transform.h:417
#define InvalidParameterException(desc)
Definition: exception.h:361
#define LOGWARN
Definition: log.h:53
#define LOGERR
Definition: log.h:51
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

References EMAN::Factory< T >::get(), EMAN::Symmetry3D::get_syms(), InvalidParameterException, LOGERR, LOGWARN, EMAN::Processor::params, EMAN::Transform::transform(), x, and y.

Member Data Documentation

◆ NAME

const string SegmentSubunitProcessor::NAME = "segment.subunit"
static

Definition at line 7765 of file processor.h.

Referenced by get_name().


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