#include <reconstructor.h>
Inheritance diagram for EMAN::BackProjectionReconstructor:
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=1.0) |
Insert an image slice to the reconstructor. | |
virtual EMData * | finish (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 Reconstructor * | NEW () |
Static Public Attributes | |
static const string | NAME = "back_projection" |
Private Member Functions | |
BackProjectionReconstructor (const BackProjectionReconstructor &that) | |
BackProjectionReconstructor & | operator= (const BackProjectionReconstructor &) |
void | load_default_settings () |
EMData * | preprocess_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. |
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 875 of file reconstructor.h.
EMAN::BackProjectionReconstructor::BackProjectionReconstructor | ( | ) | [inline] |
Definition at line 878 of file reconstructor.h.
References load_default_settings().
Referenced by NEW().
00878 { load_default_settings(); }
virtual EMAN::BackProjectionReconstructor::~BackProjectionReconstructor | ( | ) | [inline, virtual] |
EMAN::BackProjectionReconstructor::BackProjectionReconstructor | ( | const BackProjectionReconstructor & | that | ) | [private] |
EMData * BackProjectionReconstructor::finish | ( | bool | doift = true |
) | [virtual] |
Finish reconstruction and return the complete model.
doift | A 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 |
Reimplemented from EMAN::Reconstructor.
Definition at line 1936 of file reconstructor.cpp.
References EMAN::EMData::add(), EMAN::Symmetry3D::get_nsym(), EMAN::Symmetry3D::get_syms(), EMAN::ReconstructorVolumeData::image, EMAN::EMData::mult(), and EMAN::FactoryBase::params.
01937 { 01938 01939 Symmetry3D* sym = Factory<Symmetry3D>::get((string)params["sym"]); 01940 vector<Transform> syms = sym->get_syms(); 01941 01942 for ( vector<Transform>::const_iterator it = syms.begin(); it != syms.end(); ++it ) { 01943 01944 EMData tmpcopy(*image); 01945 tmpcopy.transform(*it); 01946 image->add(tmpcopy); 01947 } 01948 01949 image->mult(1.0f/(float)sym->get_nsym()); 01950 delete sym; 01951 01952 EMData *ret = image; 01953 image = 0 ; 01954 return ret; 01955 }
virtual string EMAN::BackProjectionReconstructor::get_desc | ( | ) | const [inline, virtual] |
Get a clear, concise description of this class.
Implements EMAN::FactoryBase.
Definition at line 901 of file reconstructor.h.
00902 { 00903 return "Simple (unfiltered) back-projection reconstruction. Weighting by contributing particles in the class average is optional and default behaviour"; 00904 }
virtual string EMAN::BackProjectionReconstructor::get_name | ( | ) | const [inline, virtual] |
Get the unique name of this class (especially for factory based instantiation access).
Implements EMAN::FactoryBase.
Definition at line 896 of file reconstructor.h.
References NAME.
00897 { 00898 return NAME; 00899 }
virtual TypeDict EMAN::BackProjectionReconstructor::get_param_types | ( | ) | const [inline, virtual] |
Implements EMAN::FactoryBase.
Definition at line 911 of file reconstructor.h.
References EMAN::EMObject::FLOAT, EMAN::EMObject::INT, EMAN::TypeDict::put(), and EMAN::EMObject::STRING.
00912 { 00913 TypeDict d; 00914 d.put("size", EMObject::INT, "Necessary. The x and y dimensions of the input images."); 00915 d.put("weight", EMObject::FLOAT, "Optional. A temporary value set prior to slice insertion, indicative of the inserted slice's weight. Default sis 1."); 00916 d.put("sym", EMObject::STRING, "Optional. The symmetry to impose on the final reconstruction. Default is c1"); 00917 d.put("zsample", EMObject::INT, "Optional. The z dimensions of the reconstructed volume."); 00918 return d; 00919 }
int BackProjectionReconstructor::insert_slice | ( | const EMData *const | slice, | |
const Transform & | euler, | |||
const float | weight = 1.0 | |||
) | [virtual] |
Insert an image slice to the reconstructor.
To insert multiple image slices, call this function multiple times.
slice | Image slice. | |
euler | Euler angle of this image slice. | |
weight | A weighting factor for this slice, generally the number of particles in a class-average. May be ignored by some reconstructors |
Reimplemented from EMAN::Reconstructor.
Definition at line 1886 of file reconstructor.cpp.
References EMAN::EMData::add(), EMAN::EMData::get_attr(), EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::has_attr(), EMAN::ReconstructorVolumeData::image, EMAN::Transform::invert(), LOGERR, EMAN::EMData::mult(), EMAN::ReconstructorVolumeData::nx, EMAN::ReconstructorVolumeData::ny, EMAN::ReconstructorVolumeData::nz, EMAN::FactoryBase::params, preprocess_slice(), EMAN::Transform::set_mirror(), EMAN::Transform::set_scale(), EMAN::EMData::set_size(), EMAN::Transform::set_trans(), t, EMAN::ReconstructorVolumeData::tmp_data, EMAN::EMData::transform(), and weight.
01887 { 01888 if (!input) { 01889 LOGERR("try to insert NULL slice"); 01890 return 1; 01891 } 01892 01893 if (input->get_xsize() != input->get_ysize() || input->get_xsize() != nx) { 01894 LOGERR("tried to insert image that was not correction dimensions"); 01895 return 1; 01896 } 01897 01898 Transform * transform; 01899 if ( input->has_attr("xform.projection") ) { 01900 transform = (Transform*) (input->get_attr("xform.projection")); // assignment operator 01901 } else { 01902 transform = new Transform(t); // assignment operator 01903 } 01904 EMData* slice = preprocess_slice(input, t); 01905 01906 float weight = params["weight"]; 01907 slice->mult(weight); 01908 01909 EMData *tmp = new EMData(); 01910 tmp->set_size(nx, ny, nz); 01911 01912 float *slice_data = slice->get_data(); 01913 float *tmp_data = tmp->get_data(); 01914 01915 size_t nxy = nx * ny; 01916 size_t nxy_size = nxy * sizeof(float);; 01917 for (int i = 0; i < nz; ++i) { 01918 memcpy(&tmp_data[nxy * i], slice_data, nxy_size); 01919 } 01920 01921 transform->set_scale(1.0); 01922 transform->set_mirror(false); 01923 transform->set_trans(0,0,0); 01924 transform->invert(); 01925 01926 tmp->transform(*transform); 01927 image->add(*tmp); 01928 01929 if(transform) {delete transform; transform=0;} 01930 delete tmp; 01931 delete slice; 01932 01933 return 0; 01934 }
void EMAN::BackProjectionReconstructor::load_default_settings | ( | ) | [inline, private] |
Definition at line 929 of file reconstructor.h.
References EMAN::FactoryBase::params.
Referenced by BackProjectionReconstructor().
00930 { 00931 params["weight"] = 1.0; 00932 params["use_weights"] = true; 00933 params["size"] = 0; 00934 params["sym"] = "c1"; 00935 params["zsample"] = 0; 00936 }
static Reconstructor* EMAN::BackProjectionReconstructor::NEW | ( | ) | [inline, static] |
Definition at line 906 of file reconstructor.h.
References BackProjectionReconstructor().
00907 { 00908 return new BackProjectionReconstructor(); 00909 }
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.
slice | the slice to be prepocessed | |
t | transform |
InvalidValueException | when the specified padding value is less than the size of the images |
Reimplemented from EMAN::Reconstructor.
Definition at line 1866 of file reconstructor.cpp.
References EMAN::Transform::get_mirror(), EMAN::Transform::get_scale(), EMAN::Transform::get_trans_2d(), EMAN::EMData::process(), EMAN::EMData::process_inplace(), EMAN::Transform::set_rotation(), t, and EMAN::EMData::transform().
Referenced by insert_slice().
01867 { 01868 01869 EMData* return_slice = slice->process("normalize.edgemean"); 01870 return_slice->process_inplace("filter.linearfourier"); 01871 01872 Transform tmp(t); 01873 tmp.set_rotation(Dict("type","eman")); // resets the rotation to 0 implicitly 01874 Vec2f trans = tmp.get_trans_2d(); 01875 float scale = tmp.get_scale(); 01876 bool mirror = tmp.get_mirror(); 01877 if (trans[0] != 0 || trans[1] != 0 || scale != 1.0 ) { 01878 return_slice->transform(tmp); 01879 } else if ( mirror == true ) { 01880 return_slice = slice->process("xform.flip",Dict("axis","x")); 01881 } 01882 01883 return return_slice; 01884 }
void BackProjectionReconstructor::setup | ( | ) | [virtual] |
Initialize the reconstructor.
Implements EMAN::Reconstructor.
Definition at line 1855 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().
01856 { 01857 int size = params["size"]; 01858 image = new EMData(); 01859 nx = size; 01860 ny = size; 01861 if ( (int) params["zsample"] != 0 ) nz = params["zsample"]; 01862 else nz = size; 01863 image->set_size(nx, ny, nz); 01864 }
const string BackProjectionReconstructor::NAME = "back_projection" [static] |