EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | List of all members
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]

Public Member Functions

 BackProjectionReconstructor ()
 
virtual ~BackProjectionReconstructor ()
 
virtual void setup ()
 Initialize the reconstructor. More...
 
virtual int insert_slice (const EMData *const slice, const Transform &euler, const float weight)
 Insert an image slice to the reconstructor. More...
 
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. More...
 
virtual EMDatafinish (bool doift=true)
 Finish reconstruction and return the complete model. More...
 
virtual string get_name () const
 Get the unique name of this class (especially for factory based instantiation access) More...
 
virtual string get_desc () const
 Get a clear, concise description of this class. More...
 
virtual TypeDict get_param_types () const
 
- Public Member Functions inherited from EMAN::Reconstructor
 Reconstructor ()
 
virtual ~Reconstructor ()
 
virtual void setup_seed (EMData *seed, float seed_weight)
 Initialize the reconstructor with a seed volume. More...
 
virtual void setup_seedandweights (EMData *seed, EMData *weight)
 Initialize the reconstructor with a seed volume, as above. More...
 
int insert_slice (const EMData *const slice, const Transform &euler)
 
virtual EMDataprojection (const Transform &euler, int ret_fourier=1)
 This will create a projection from the current reconstruction. More...
 
virtual void clear ()
 set the volume and tmp_volume data to zero, for use in Monte Carlo reconstructors More...
 
void print_params () const
 Print the current parameters to std::out. More...
 
EMObjectoperator[] (const string &key)
 
- Public Member Functions inherited from EMAN::FactoryBase
 FactoryBase ()
 
virtual ~FactoryBase ()
 
Dict get_params () const
 get a copy of the parameters of this class More...
 
void set_params (const Dict &new_params)
 Set new parameters. More...
 
void set_param (const string key, const EMObject val)
 
void insert_params (const Dict &new_params)
 Insert parameters. More...
 
Dict copy_relevant_params (const FactoryBase *const that) const
 
- Public Member Functions inherited from EMAN::ReconstructorVolumeData
 ReconstructorVolumeData ()
 Only constructor All member variables are zeroed. More...
 
virtual ~ReconstructorVolumeData ()
 Destructor safely frees memory. More...
 
const EMDataget_emdata ()
 Get the main image pointer, probably redundant (not used) More...
 

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. More...
 

Additional Inherited Members

- Protected Member Functions inherited from EMAN::ReconstructorVolumeData
void free_memory ()
 Free allocated memorys The inherited class may have allocated image of tmp_data In either case you can safely call this function to delete either of those pointers, even if they bdb:refine_03::threed_00are NULL. More...
 
virtual void normalize_threed (const bool sqrt_damp=false, const bool wiener=false)
 Normalize on the assumption that image is a Fourier volume and that tmp_data is a volume of weights corresponding in size to this Fourier volume. More...
 
virtual void zero_memory ()
 Sends the pixels in tmp_data and image to zero Convenience only. More...
 
- Protected Attributes inherited from EMAN::FactoryBase
Dict params
 This is the dictionary the stores the parameters of the object. More...
 
- Protected Attributes inherited from EMAN::ReconstructorVolumeData
EMDataimage
 Inheriting class allocates this, probably in setup(). More...
 
EMDatatmp_data
 Inheriting class may allocate this, probably in setup() More...
 
int nx
 
int nx2
 
int ny
 
int ny2
 
int nz
 
int nz2
 
int subnx
 
int subny
 
int subnz
 
int subx0
 
int suby0
 
int subz0
 

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 841 of file reconstructor.h.

Constructor & Destructor Documentation

◆ BackProjectionReconstructor() [1/2]

EMAN::BackProjectionReconstructor::BackProjectionReconstructor ( )
inline

Definition at line 844 of file reconstructor.h.

References load_default_settings().

Referenced by NEW().

◆ ~BackProjectionReconstructor()

virtual EMAN::BackProjectionReconstructor::~BackProjectionReconstructor ( )
inlinevirtual

Definition at line 846 of file reconstructor.h.

846{}

◆ BackProjectionReconstructor() [2/2]

EMAN::BackProjectionReconstructor::BackProjectionReconstructor ( const BackProjectionReconstructor that)
private

Member Function Documentation

◆ determine_slice_agreement()

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 2884 of file reconstructor.cpp.

2885{
2886 // Are these exceptions really necessary? (d.woolford)
2887 if (!input_slice) throw NullPointerException("EMData pointer (input image) is NULL");
2888
2889 input_slice->set_attr("reconstruct_norm",1.0f);
2890 input_slice->set_attr("reconstruct_absqual",1.0f);
2891 input_slice->set_attr("reconstruct_weight",1.0f);
2892
2893 return 0;
2894
2895}
#define NullPointerException(desc)
Definition: exception.h:241

References NullPointerException.

◆ finish()

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 2897 of file reconstructor.cpp.

2898{
2899
2900 Symmetry3D* sym = Factory<Symmetry3D>::get((string)params["sym"]);
2901 vector<Transform> syms = sym->get_syms();
2902
2903 for ( vector<Transform>::const_iterator it = syms.begin(); it != syms.end(); ++it ) {
2904
2905// it->printme();
2906 Transform t=*it;
2907 EMData *tmpcopy = image->process("xform",Dict("transform",(EMObject)&t));
2908 image->add(*tmpcopy);
2909 delete tmpcopy;
2910 }
2911
2912 image->mult(1.0f/(float)sym->get_nsym());
2913 delete sym;
2914 if (image->get_xsize()==image->get_ysize() && image->get_ysize()==image->get_zsize()) {
2915 image->process_inplace("mask.sharp",Dict("outer_radius",image->get_xsize()/2-1));
2916 }
2917 else printf("No masking %d %d %d\n",image->get_xsize(),image->get_ysize(),image->get_zsize());
2918
2919 EMData *ret = image;
2920 image = 0 ;
2921 return ret;
2922}
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
EMObject is a wrapper class for types including int, float, double, etc as defined in ObjectType.
Definition: emobject.h:123
Dict params
This is the dictionary the stores the parameters of the object.
Definition: emobject.h:953
static T * get(const string &instance_name)
Definition: emobject.h:781
EMData * image
Inheriting class allocates this, probably in setup().
Symmetry3D - A base class for 3D Symmetry objects.
Definition: symmetry.h:57
virtual int get_nsym() const =0
The total number of unique symmetry operations that will be return by this object when a calling prog...
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

References EMAN::Factory< T >::get(), EMAN::Symmetry3D::get_nsym(), EMAN::Symmetry3D::get_syms(), EMAN::ReconstructorVolumeData::image, and EMAN::FactoryBase::params.

◆ get_desc()

virtual string EMAN::BackProjectionReconstructor::get_desc ( ) const
inlinevirtual

Get a clear, concise description of this class.

Returns
a clear, concise description of this class

Implements EMAN::FactoryBase.

Definition at line 878 of file reconstructor.h.

879 {
880 return "Simple (unfiltered) back-projection reconstruction. Weighting by contributing particles in the class average is optional and default behaviour";
881 }

◆ get_name()

virtual string EMAN::BackProjectionReconstructor::get_name ( ) const
inlinevirtual

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 873 of file reconstructor.h.

874 {
875 return NAME;
876 }

References NAME.

◆ get_param_types()

virtual TypeDict EMAN::BackProjectionReconstructor::get_param_types ( ) const
inlinevirtual
Returns
a TypeDict defining and describing the feasible parameters of this class

Implements EMAN::FactoryBase.

Definition at line 888 of file reconstructor.h.

889 {
890 TypeDict d;
891 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.");
892 d.put("weight", EMObject::FLOAT, "Optional. A temporary value set prior to slice insertion, indicative of the inserted slice's weight. Default sis 1.");
893 d.put("sym", EMObject::STRING, "Optional. The symmetry to impose on the final reconstruction. Default is c1");
894 d.put("verbose", EMObject::BOOL, "Optional. Toggles writing useful information to standard out. Default is false.");
895 return d;
896 }

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

◆ insert_slice()

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 2832 of file reconstructor.cpp.

2833{
2834 if (!input) {
2835 LOGERR("try to insert NULL slice");
2836 return 1;
2837 }
2838
2839 if (input->get_xsize() != input->get_ysize() || input->get_xsize() != nx) {
2840 LOGERR("tried to insert image that was not correction dimensions");
2841 return 1;
2842 }
2843
2844// Transform * transform;
2845// if ( input->has_attr("xform.projection") ) {
2846// transform = (Transform*) (input->get_attr("xform.projection")); // assignment operator
2847// } else {
2848// transform = new Transform(t); // assignment operator
2849// }
2850 EMData* slice = preprocess_slice(input, t);
2851
2852 // Clearly weight isn't a useful concept in back-projection without compensating with an exact-filter
2853// float weight = params["weight"];
2854// slice->mult(weight);
2855
2856 EMData *tmp = new EMData();
2857 tmp->set_size(nx, ny, nz);
2858
2859 float *slice_data = slice->get_data();
2860 float *tmp_data = tmp->get_data();
2861
2862 size_t nxy = nx * ny;
2863 size_t nxy_size = nxy * sizeof(float);;
2864 for (int i = 0; i < nz; ++i) {
2865 memcpy(&tmp_data[nxy * i], slice_data, nxy_size);
2866 }
2867 tmp->update();
2868
2869// transform->set_scale(1.0);
2870// transform->set_mirror(false);
2871// transform->set_trans(0,0,0);
2872// transform->invert();
2873
2874 tmp->transform(t.inverse()); // This was incorrect. inverse() was missing
2875 image->add(*tmp);
2876
2877// if(transform) {delete transform; transform=0;}
2878 delete tmp;
2879 delete slice;
2880
2881 return 0;
2882}
EMData * preprocess_slice(const EMData *const slice, const Transform &t)
While you can just insert unprocessed slices, if you call preprocess_slice yourself,...
void transform(const Transform &t)
Rotate then translate the image.
Definition: emdata.h:295
EMData * tmp_data
Inheriting class may allocate this, probably in setup()
#define LOGERR
Definition: log.h:51

References EMAN::ReconstructorVolumeData::image, EMAN::Transform::inverse(), LOGERR, EMAN::ReconstructorVolumeData::nx, EMAN::ReconstructorVolumeData::ny, EMAN::ReconstructorVolumeData::nz, preprocess_slice(), EMAN::ReconstructorVolumeData::tmp_data, and EMAN::EMData::transform().

◆ load_default_settings()

void EMAN::BackProjectionReconstructor::load_default_settings ( )
inlineprivate

Definition at line 906 of file reconstructor.h.

907 {
908 params["weight"] = 1.0;
909 params["use_weights"] = true;
910 params["sym"] = "c1";
911 params["verbose"] = false;
912 }

References EMAN::FactoryBase::params.

Referenced by BackProjectionReconstructor().

◆ NEW()

static Reconstructor * EMAN::BackProjectionReconstructor::NEW ( )
inlinestatic

Definition at line 883 of file reconstructor.h.

884 {
885 return new BackProjectionReconstructor();
886 }

References BackProjectionReconstructor().

◆ operator=()

BackProjectionReconstructor & EMAN::BackProjectionReconstructor::operator= ( const BackProjectionReconstructor )
private

◆ preprocess_slice()

EMData * BackProjectionReconstructor::preprocess_slice ( const EMData *const  slice,
const Transform t 
)
privatevirtual

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 2806 of file reconstructor.cpp.

2807{
2808
2809// EMData* return_slice = slice->process("normalize.edgemean");
2810// return_slice->process_inplace("filter.linearfourier");
2811
2812 EMData* return_slice;
2813
2814 return_slice = slice->process("filter.linearfourier");
2815// return_slice = slice->copy();
2816
2817// Transform tmp(t);
2818// tmp.set_rotation(Dict("type","eman")); // resets the rotation to 0 implicitly
2819// Vec2f trans = tmp.get_trans_2d();
2820// float scale = tmp.get_scale();
2821// bool mirror = tmp.get_mirror();
2822// if (trans[0] != 0 || trans[1] != 0 || scale != 1.0 ) {
2823// return_slice->transform(tmp);
2824// }
2825// if ( mirror == true ) {
2826// return_slice->process_inplace("xform.flip",Dict("axis","x"));
2827// }
2828
2829 return return_slice;
2830}

Referenced by insert_slice().

◆ setup()

void BackProjectionReconstructor::setup ( )
virtual

Initialize the reconstructor.

Implements EMAN::Reconstructor.

Definition at line 2796 of file reconstructor.cpp.

2797{
2798 image = new EMData();
2799 vector<int> size=params["size"];
2800 nx = size[0];
2801 ny = size[1];
2802 nz = size[2];
2803 image->set_size(nx, ny, nz);
2804}

References EMAN::ReconstructorVolumeData::image, EMAN::ReconstructorVolumeData::nx, EMAN::ReconstructorVolumeData::ny, EMAN::ReconstructorVolumeData::nz, and EMAN::FactoryBase::params.

Member Data Documentation

◆ NAME

const string BackProjectionReconstructor::NAME = "back_projection"
static

Definition at line 898 of file reconstructor.h.

Referenced by get_name().


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