EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions
EMAN::BackProjectionReconstructor Class Reference

Real space 3D reconstruction using back projection. More...

#include <reconstructor.h>

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

List of all members.

Public Member Functions

 BackProjectionReconstructor ()
virtual ~BackProjectionReconstructor ()
virtual void setup ()
 Initialize the reconstructor.
virtual int insert_slice (const EMData *const slice, const Transform &euler, const float weight)
 Insert an image slice to the reconstructor.
virtual int determine_slice_agreement (EMData *slice, const Transform &euler, const float weight=1.0, bool sub=true)
 Dummy function which always returns the same values.
virtual EMDatafinish (bool doift=true)
 Finish reconstruction and return the complete model.
virtual string get_name () const
 Get the unique name of this class (especially for factory based instantiation access)
virtual string get_desc () const
 Get a clear, concise description of this class.
virtual TypeDict get_param_types () const

Static Public Member Functions

static ReconstructorNEW ()

Static Public Attributes

static const string NAME = "back_projection"

Private Member Functions

 BackProjectionReconstructor (const BackProjectionReconstructor &that)
BackProjectionReconstructoroperator= (const BackProjectionReconstructor &)
void load_default_settings ()
EMDatapreprocess_slice (const EMData *const slice, const Transform &t)
 While you can just insert unprocessed slices, if you call preprocess_slice yourself, and insert the returned slice instead, repeatedly, it can save a fair bit of computation.

Detailed Description

Real space 3D reconstruction using back projection.

Back-projection is a method of 3D reconstruction from 2D projections. It is based on superposing 3D functions ("back-projection bodies") obtained by translating the 2D projections along the directions of projection.

Definition at line 876 of file reconstructor.h.


Constructor & Destructor Documentation

EMAN::BackProjectionReconstructor::BackProjectionReconstructor ( ) [inline]

Definition at line 879 of file reconstructor.h.

References load_default_settings().

Referenced by NEW().

virtual EMAN::BackProjectionReconstructor::~BackProjectionReconstructor ( ) [inline, virtual]

Definition at line 881 of file reconstructor.h.

{}
EMAN::BackProjectionReconstructor::BackProjectionReconstructor ( const BackProjectionReconstructor that) [private]

Member Function Documentation

int BackProjectionReconstructor::determine_slice_agreement ( EMData slice,
const Transform euler,
const float  weight = 1.0,
bool  sub = true 
) [virtual]

Dummy function which always returns the same values.

It could be implemented, but isn't, as this reconstructor is really just for testing.

Parameters:
input_sliceThe EMData slice to be compared
eulerThe orientation of the slice as a Transform object
weightA weighting factor for this slice, generally the number of particles in a class-average. May be ignored by some reconstructors
subFlag indicating whether to subtract the slice from the volume before comparing. May be ignored by some reconstructors
Returns:
0 if OK. 1 if error.
Exceptions:
NullPointerExceptionif the input EMData pointer is null
ImageFormatExceptionif the image is complex as opposed to real

Reimplemented from EMAN::Reconstructor.

Definition at line 1945 of file reconstructor.cpp.

References NullPointerException, and EMAN::EMData::set_attr().

{
        // Are these exceptions really necessary? (d.woolford)
        if (!input_slice) throw NullPointerException("EMData pointer (input image) is NULL");

        input_slice->set_attr("reconstruct_norm",1.0f);
        input_slice->set_attr("reconstruct_absqual",1.0f);
        input_slice->set_attr("reconstruct_weight",1.0f);

        return 0;

}
EMData * BackProjectionReconstructor::finish ( bool  doift = true) [virtual]

Finish reconstruction and return the complete model.

Parameters:
doiftA flag indicating whether the returned object should be guaranteed to be in real-space (true) or should be left in whatever space the reconstructor generated
Returns:
The result 3D model.

Reimplemented from EMAN::Reconstructor.

Definition at line 1958 of file reconstructor.cpp.

References EMAN::EMData::add(), EMAN::Symmetry3D::get_nsym(), EMAN::Symmetry3D::get_syms(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::ReconstructorVolumeData::image, EMAN::EMData::mult(), EMAN::FactoryBase::params, EMAN::EMData::process(), EMAN::EMData::process_inplace(), and t.

{

        Symmetry3D* sym = Factory<Symmetry3D>::get((string)params["sym"]);
        vector<Transform> syms = sym->get_syms();

        for ( vector<Transform>::const_iterator it = syms.begin(); it != syms.end(); ++it ) {

//              it->printme();
                Transform t=*it;
                EMData *tmpcopy = image->process("xform",Dict("transform",(EMObject)&t));
                image->add(*tmpcopy);
                delete tmpcopy;
        }

        image->mult(1.0f/(float)sym->get_nsym());
        delete sym;
        if (image->get_xsize()==image->get_ysize() && image->get_ysize()==image->get_zsize()) {
                image->process_inplace("mask.sharp",Dict("outer_radius",image->get_xsize()/2-1));
        }
        else printf("No masking %d %d %d\n",image->get_xsize(),image->get_ysize(),image->get_zsize());
                
        EMData *ret = image;
        image = 0 ;
        return ret;
}
virtual string EMAN::BackProjectionReconstructor::get_desc ( ) const [inline, virtual]

Get a clear, concise description of this class.

Returns:
a clear, concise description of this class

Implements EMAN::FactoryBase.

Definition at line 913 of file reconstructor.h.

                {
                        return "Simple (unfiltered) back-projection reconstruction. Weighting by contributing particles in the class average is optional and default behaviour";
                }
virtual string EMAN::BackProjectionReconstructor::get_name ( ) const [inline, virtual]

Get the unique name of this class (especially for factory based instantiation access)

Returns:
the unique name of this class

Implements EMAN::FactoryBase.

Definition at line 908 of file reconstructor.h.

References NAME.

                {
                        return NAME;
                }
virtual TypeDict EMAN::BackProjectionReconstructor::get_param_types ( ) const [inline, virtual]
Returns:
a TypeDict defining and describing the feasible parameters of this class

Implements EMAN::FactoryBase.

Definition at line 923 of file reconstructor.h.

References EMAN::EMObject::BOOL, EMAN::EMObject::FLOAT, EMAN::EMObject::INTARRAY, EMAN::TypeDict::put(), and EMAN::EMObject::STRING.

                {
                        TypeDict d;
                        d.put("size", EMObject::INTARRAY, "Required. The dimensions of the real-space output volume, including any padding (must be handled by the calling application). Assumed that apix x/y/z identical.");
                        d.put("weight", EMObject::FLOAT, "Optional. A temporary value set prior to slice insertion, indicative of the inserted slice's weight. Default sis 1.");
                        d.put("sym", EMObject::STRING, "Optional. The symmetry to impose on the final reconstruction. Default is c1");
                        d.put("verbose", EMObject::BOOL, "Optional. Toggles writing useful information to standard out. Default is false.");
                        return d;
                }
int BackProjectionReconstructor::insert_slice ( const EMData *const  slice,
const Transform euler,
const float  weight 
) [virtual]

Insert an image slice to the reconstructor.

To insert multiple image slices, call this function multiple times.

Parameters:
sliceImage slice.
eulerEuler angle of this image slice.
weightA weighting factor for this slice, generally the number of particles in a class-average. May be ignored by some reconstructors
Returns:
0 if OK. 1 if error.

Reimplemented from EMAN::Reconstructor.

Definition at line 1893 of file reconstructor.cpp.

References EMAN::EMData::add(), EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::ReconstructorVolumeData::image, LOGERR, EMAN::ReconstructorVolumeData::nx, EMAN::ReconstructorVolumeData::ny, EMAN::ReconstructorVolumeData::nz, preprocess_slice(), EMAN::EMData::set_size(), EMAN::ReconstructorVolumeData::tmp_data, EMAN::EMData::transform(), and EMAN::EMData::update().

{
        if (!input) {
                LOGERR("try to insert NULL slice");
                return 1;
        }

        if (input->get_xsize() != input->get_ysize() || input->get_xsize() != nx) {
                LOGERR("tried to insert image that was not correction dimensions");
                return 1;
        }

//      Transform * transform;
//      if ( input->has_attr("xform.projection") ) {
//              transform = (Transform*) (input->get_attr("xform.projection")); // assignment operator
//      } else {
//              transform = new Transform(t); // assignment operator
//      }
        EMData* slice = preprocess_slice(input, t);

        // Clearly weight isn't a useful concept in back-projection without compensating with an exact-filter
//      float weight = params["weight"];
//      slice->mult(weight);

        EMData *tmp = new EMData();
        tmp->set_size(nx, ny, nz);

        float *slice_data = slice->get_data();
        float *tmp_data = tmp->get_data();

        size_t nxy = nx * ny;
        size_t nxy_size = nxy * sizeof(float);;
        for (int i = 0; i < nz; ++i) {
                memcpy(&tmp_data[nxy * i], slice_data, nxy_size);
        }
        tmp->update();

//      transform->set_scale(1.0);
//      transform->set_mirror(false);
//      transform->set_trans(0,0,0);
//      transform->invert();

        tmp->transform(t);
        image->add(*tmp);

//      if(transform) {delete transform; transform=0;}
        delete tmp;
        delete slice;

        return 0;
}
void EMAN::BackProjectionReconstructor::load_default_settings ( ) [inline, private]

Definition at line 941 of file reconstructor.h.

References EMAN::FactoryBase::params.

Referenced by BackProjectionReconstructor().

                {
                        params["weight"] = 1.0;
                        params["use_weights"] = true;
                        params["sym"] = "c1";
                        params["verbose"] = false;
                }
static Reconstructor* EMAN::BackProjectionReconstructor::NEW ( ) [inline, static]

Definition at line 918 of file reconstructor.h.

References BackProjectionReconstructor().

                {
                        return new BackProjectionReconstructor();
                }
BackProjectionReconstructor& EMAN::BackProjectionReconstructor::operator= ( const BackProjectionReconstructor ) [private]
EMData * BackProjectionReconstructor::preprocess_slice ( const EMData *const  slice,
const Transform t 
) [private, virtual]

While you can just insert unprocessed slices, if you call preprocess_slice yourself, and insert the returned slice instead, repeatedly, it can save a fair bit of computation.

The default operation just returns a copy of the image, as the preprocessing is reconstructor-specific.

Returns:
the processed slice
Parameters:
slicethe slice to be prepocessed
ttransform
Exceptions:
InvalidValueExceptionwhen the specified padding value is less than the size of the images

Reimplemented from EMAN::Reconstructor.

Definition at line 1867 of file reconstructor.cpp.

References EMAN::EMData::process().

Referenced by insert_slice().

{

//      EMData* return_slice = slice->process("normalize.edgemean");
//      return_slice->process_inplace("filter.linearfourier");

        EMData* return_slice;

        return_slice = slice->process("filter.linearfourier");
//      return_slice = slice->copy();
        
//      Transform tmp(t);
//      tmp.set_rotation(Dict("type","eman")); // resets the rotation to 0 implicitly
//      Vec2f trans = tmp.get_trans_2d();
//      float scale = tmp.get_scale();
//      bool mirror = tmp.get_mirror();
//      if (trans[0] != 0 || trans[1] != 0 || scale != 1.0 ) {
//              return_slice->transform(tmp);
//      } 
//      if ( mirror == true ) {
//              return_slice->process_inplace("xform.flip",Dict("axis","x"));
//      }

        return return_slice;
}
void BackProjectionReconstructor::setup ( ) [virtual]

Initialize the reconstructor.

Implements EMAN::Reconstructor.

Definition at line 1857 of file reconstructor.cpp.

References EMAN::ReconstructorVolumeData::image, EMAN::ReconstructorVolumeData::nx, EMAN::ReconstructorVolumeData::ny, EMAN::ReconstructorVolumeData::nz, EMAN::FactoryBase::params, and EMAN::EMData::set_size().

{
        image = new EMData();
        vector<int> size=params["size"];
        nx = size[0];
        ny = size[1];
        nz = size[2];
        image->set_size(nx, ny, nz);
}

Member Data Documentation

const string BackProjectionReconstructor::NAME = "back_projection" [static]

Definition at line 933 of file reconstructor.h.

Referenced by get_name().


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