EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Member Functions | List of all members
EMAN::WienerFourierReconstructor Class Reference

Fourier space 3D reconstruction This is a modified version of the normal FourierReconstructor which is aware of the SSNR information stored in individual class-average headers as "ctf_snr_total" and "ctf_wiener_filtered". More...

#include <reconstructor.h>

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

Public Member Functions

 WienerFourierReconstructor ()
 Default constructor calls load_default_settings() More...
 
virtual ~WienerFourierReconstructor ()
 Deconstructor calls free_memory() More...
 
virtual int insert_slice (const EMData *const slice, const Transform &euler, const float weight)
 Insert a slice into a 3D volume, in a given orientation. More...
 
virtual int determine_slice_agreement (EMData *slice, const Transform &euler, const float weight=1.0, bool sub=true)
 Compares a slice to the current reconstruction volume and computes a normalization factor and quality. More...
 
virtual EMDatafinish (bool doift=true)
 Get the reconstructed volume Normally will return the volume in real-space with the requested size. More...
 
virtual string get_name () const
 Get the unique name of the reconstructor. More...
 
virtual string get_desc () const
 Get the one line description of the reconstructor. More...
 
- Public Member Functions inherited from EMAN::FourierReconstructor
 FourierReconstructor ()
 Default constructor calls load_default_settings() More...
 
virtual ~FourierReconstructor ()
 Deconstructor calls free_memory() More...
 
virtual void setup ()
 Setup the Fourier reconstructor. More...
 
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...
 
virtual EMDatapreprocess_slice (const EMData *const slice, const Transform &t=Transform())
 Preprocess the slice prior to insertion into the 3D volume this Fourier tranforms the slice and make sure all the pixels are in the right position it always returns a copy of the provided slice, so it should be deleted by someone eventually. More...
 
virtual EMDataprojection (const Transform &euler, int ret_fourier)
 Generates a projection by extracting a slice in Fourier space. More...
 
virtual void clear ()
 clear the volume and tmp_data for use in Monte Carlo reconstructions More...
 
virtual TypeDict get_param_types () const
 Get the parameter types of this object. More...
 
- Public Member Functions inherited from EMAN::Reconstructor
 Reconstructor ()
 
virtual ~Reconstructor ()
 
int insert_slice (const EMData *const slice, const Transform &euler)
 
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 ()
 Factory incorporation uses the pointer of this function. More...
 
- Static Public Member Functions inherited from EMAN::FourierReconstructor
static ReconstructorNEW ()
 Factory incorporation uses the pointer of this function. More...
 

Static Public Attributes

static const string NAME = "wiener_fourier"
 
- Static Public Attributes inherited from EMAN::FourierReconstructor
static const string NAME = "fourier"
 

Protected Member Functions

virtual void do_insert_slice_work (const EMData *const input_slice, const Transform &euler, const float weight)
 
virtual void do_compare_slice_work (EMData *input_slice, const Transform &euler, float weight)
 A function to perform the nuts and bolts of comparing an image slice. More...
 
virtual bool pixel_at (const float &xx, const float &yy, const float &zz, float *dt)
 This is a mode-2 pixel extractor. More...
 
- Protected Member Functions inherited from EMAN::FourierReconstructor
virtual void load_default_settings ()
 Load default settings. More...
 
virtual void free_memory ()
 Frees the memory owned by this object (but not parent objects) Deletes the FourierPixelInserter3D pointer. More...
 
virtual void load_inserter ()
 Load the pixel inserter based on the information in params. More...
 
virtual void do_insert_slice_work (const EMData *const input_slice, const Transform &euler, const float weight, const bool corners=false)
 A function to perform the nuts and bolts of inserting an image slice. More...
 
- 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...
 

Private Member Functions

 WienerFourierReconstructor (const WienerFourierReconstructor &that)
 A pixel inserter pointer which inserts pixels into the 3D volume using one of a variety of insertion methods. More...
 
WienerFourierReconstructoroperator= (const WienerFourierReconstructor &)
 Disallow assignment. More...
 

Additional Inherited Members

- Protected Attributes inherited from EMAN::FourierReconstructor
FourierPixelInserter3Dinserter
 A pixel inserter pointer which inserts pixels into the 3D volume using one of a variety of insertion methods. 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

Fourier space 3D reconstruction This is a modified version of the normal FourierReconstructor which is aware of the SSNR information stored in individual class-average headers as "ctf_snr_total" and "ctf_wiener_filtered".

It will perform a reconstruction with a nonisotropic Wiener filter applied to the final reconstruction, and will 'undo' the Wiener filter on the individual class-averages if ctf_wiener_filtered is set. This represents something which was not possible to accomplish in EMAN1, and should produce superior results, with proper anisotropic filtering. Still, the filtration makes the assumption that the original SNR estimates were accurate, and that the data will average completely coherently, which is not truly the case. This may produce models which are somewhat underfiltered in the Wiener sense, but since B-factor corrections are not applied in the ctf.auto averager, this effect is likely already more than compensated for.

Definition at line 579 of file reconstructor.h.

Constructor & Destructor Documentation

◆ WienerFourierReconstructor() [1/2]

EMAN::WienerFourierReconstructor::WienerFourierReconstructor ( )
inline

Default constructor calls load_default_settings()

Definition at line 585 of file reconstructor.h.

585{};

Referenced by NEW().

◆ ~WienerFourierReconstructor()

virtual EMAN::WienerFourierReconstructor::~WienerFourierReconstructor ( )
inlinevirtual

Deconstructor calls free_memory()

Definition at line 590 of file reconstructor.h.

590{ }

◆ WienerFourierReconstructor() [2/2]

EMAN::WienerFourierReconstructor::WienerFourierReconstructor ( const WienerFourierReconstructor that)
private

A pixel inserter pointer which inserts pixels into the 3D volume using one of a variety of insertion methods.

Disallow copy construction

Member Function Documentation

◆ determine_slice_agreement()

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

Compares a slice to the current reconstruction volume and computes a normalization factor and quality.

Normalization and quality are returned via attributes set in the passed slice. You may freely mix calls to determine_slice_agreement with calls to insert_slice, but note that determine_slice_agreement can only use information from slices that have already been inserted. Attributes set in the slice are: reconstruct_norm the relative normalization factor which should be applied before inserting the slice reconstruct_qual a scaled quality factor (larger better) for this slice as compared to the existing reconstruction reconstruct_absqual the absolute (not scaled based on weight) quality factor comparing this slice to the existing reconstruction reconstruct_weight the summed weights from all voxels intersecting with the inserted slice, larger -> more overlap with other slices

Parameters
input_sliceThe EMData slice to be compared
eulerThe orientation of the slice as a Transform object
weightThis is ignored except for it's sign, since the SSNR from the particle header is used instead
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::FourierReconstructor.

Definition at line 1734 of file reconstructor.cpp.

1735{
1736 // Are these exceptions really necessary? (d.woolford)
1737 if (!input_slice) throw NullPointerException("EMData pointer (input image) is NULL");
1738
1739 Transform * rotation;
1740 rotation = new Transform(arg); // assignment operator
1741
1742 EMData *slice;
1743 if (input_slice->get_attr_default("reconstruct_preproc",(int) 0)) slice=input_slice->copy();
1744 else slice = preprocess_slice( input_slice, *rotation);
1745
1746
1747 // We must use only the rotational component of the transform, scaling, translation and mirroring
1748 // are not implemented in Fourier space, but are in preprocess_slice
1749 rotation->set_scale(1.0);
1750 rotation->set_mirror(false);
1751 rotation->set_trans(0,0,0);
1752
1753// tmp_data->write_image("dbug.hdf",0);
1754
1755 // Remove the current slice first (not threadsafe, but otherwise performance would be awful)
1756 if (sub) do_insert_slice_work(slice, *rotation, -weight);
1757
1758 // Compare
1759 do_compare_slice_work(slice, *rotation,weight);
1760
1761 input_slice->set_attr("reconstruct_norm",slice->get_attr("reconstruct_norm"));
1762 input_slice->set_attr("reconstruct_absqual",slice->get_attr("reconstruct_absqual"));
1763// input_slice->set_attr("reconstruct_qual",slice->get_attr("reconstruct_qual"));
1764 input_slice->set_attr("reconstruct_weight",slice->get_attr("reconstruct_weight"));
1765
1766 // Now put the slice back
1767 if (sub) do_insert_slice_work(slice, *rotation, weight);
1768
1769
1770 delete rotation;
1771 delete slice;
1772
1773// image->update();
1774 return 0;
1775
1776}
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
virtual EMData * preprocess_slice(const EMData *const slice, const Transform &t=Transform())
Preprocess the slice prior to insertion into the 3D volume this Fourier tranforms the slice and make ...
A Transform object is a somewhat specialized object designed specifically for EMAN2/Sparx storage of ...
Definition: transform.h:75
void set_mirror(const bool x_mirror)
Set whether or not x_mirroring is occurring.
Definition: transform.cpp:1238
void set_scale(const float &scale)
Set the scale.
Definition: transform.cpp:1123
void set_trans(const float &x, const float &y, const float &z=0)
Set the post translation component.
Definition: transform.cpp:1036
virtual void do_compare_slice_work(EMData *input_slice, const Transform &euler, float weight)
A function to perform the nuts and bolts of comparing an image slice.
virtual void do_insert_slice_work(const EMData *const input_slice, const Transform &euler, const float weight)
void sub(float f)
subtract a float number to each pixel value of the image.
#define NullPointerException(desc)
Definition: exception.h:241

References do_compare_slice_work(), do_insert_slice_work(), NullPointerException, EMAN::FourierReconstructor::preprocess_slice(), EMAN::Transform::set_mirror(), EMAN::Transform::set_scale(), EMAN::Transform::set_trans(), and sub().

◆ do_compare_slice_work()

void WienerFourierReconstructor::do_compare_slice_work ( EMData input_slice,
const Transform euler,
float  weight 
)
protectedvirtual

A function to perform the nuts and bolts of comparing an image slice.

Parameters
input_slicethe slice to insert into the 3D volume
eulera transform storing the slice euler angle

Reimplemented from EMAN::FourierReconstructor.

Definition at line 1778 of file reconstructor.cpp.

1779{
1780
1781 float dt[3]; // This stores the complex and weight from the volume
1782 float dt2[2]; // This stores the local image complex
1783 float *dat = input_slice->get_data();
1784 vector<Transform> syms = Symmetry3D::get_symmetries((string)params["sym"]);
1785
1786 float inx=(float)(input_slice->get_xsize()); // x/y dimensions of the input image
1787 float iny=(float)(input_slice->get_ysize());
1788
1789 double dot=0; // summed pixel*weight dot product
1790 double vweight=0; // sum of weights
1791 double power=0; // sum of inten*weight from volume
1792 double power2=0; // sum of inten*weight from image
1793 for ( vector<Transform>::const_iterator it = syms.begin(); it != syms.end(); ++it ) {
1794 Transform t3d = arg*(*it);
1795 for (int y = -iny/2; y < iny/2; y++) {
1796 for (int x = 0; x <= inx/2; x++) {
1797 if (x==0 && y==0) continue; // We don't want to use the Fourier origin
1798
1799 float rx = (float) x/(inx-2); // coords relative to Nyquist=.5
1800 float ry = (float) y/iny;
1801
1802// if ((rx * rx + Util::square(ry - max_input_dim / 2)) > rl)
1803// continue;
1804
1805 Vec3f coord(rx,ry,0);
1806 coord = coord*t3d; // transpose multiplication
1807 float xx = coord[0]; // transformed coordinates in terms of Nyquist
1808 float yy = coord[1];
1809 float zz = coord[2];
1810
1811
1812 if (fabs(xx)>0.5 || fabs(yy)>=0.5 || fabs(zz)>=0.5) continue;
1813
1814 // Map back to actual pixel coordinates in output volume
1815 xx=xx*(nx-2);
1816 yy=yy*ny;
1817 zz=zz*nz;
1818
1819
1820 int idx = (int)(x * 2 + inx*(y<0?iny+y:y));
1821 dt2[0] = dat[idx];
1822 dt2[1] = dat[idx+1];
1823
1824 // value returned indirectly in dt
1825 if (!pixel_at(xx,yy,zz,dt) || dt[2]<=0) continue;
1826
1827// printf("%f\t%f\t%f\t%f\t%f\n",dt[0],dt[1],dt[2],dt2[0],dt2[1]);
1828 dot+=(dt[0]*dt2[0]+dt[1]*dt2[1])*dt[2];
1829 vweight+=dt[2];
1830 power+=(dt[0]*dt[0]+dt[1]*dt[1])*dt[2];
1831 power2+=(dt2[0]*dt2[0]+dt2[1]*dt2[1])*dt[2];
1832 }
1833 }
1834 }
1835
1836 dot/=sqrt(power*power2); // normalize the dot product
1837// input_slice->set_attr("reconstruct_norm",(float)(power2<=0?1.0:sqrt(power/power2)/(inx*iny)));
1838 input_slice->set_attr("reconstruct_norm",(float)(power2<=0?1.0:sqrt(power/power2)));
1839 input_slice->set_attr("reconstruct_absqual",(float)dot);
1840 float rw=weight<=0?1.0f:1.0f/weight;
1841 input_slice->set_attr("reconstruct_qual",(float)(dot*rw/((rw-1.0)*dot+1.0))); // here weight is a proxy for SNR
1842 input_slice->set_attr("reconstruct_weight",(float)vweight/(float)(subnx*subny*subnz));
1843// printf("** %g\t%g\t%g\t%g ##\n",dot,vweight,power,power2);
1844 //printf("** %f %f %f ##\n",(float)(power2<=0?1.0:sqrt(power/power2)/(inx*iny)),(float)dot,(float)(dot*weight/((weight-1.0)*dot+1.0)));
1845}
Dict params
This is the dictionary the stores the parameters of the object.
Definition: emobject.h:953
static vector< Transform > get_symmetries(const string &symmetry)
Definition: symmetry.cpp:1240
virtual bool pixel_at(const float &xx, const float &yy, const float &zz, float *dt)
This is a mode-2 pixel extractor.
EMData * power(int n) const
return a image to the power of n
EMData * sqrt() const
return square root of current image
double dot(const Vector3 &w, const Vector3 &v)
Definition: vecmath.h:305
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

References EMAN::dot(), EMAN::Symmetry3D::get_symmetries(), EMAN::ReconstructorVolumeData::nx, EMAN::ReconstructorVolumeData::ny, EMAN::ReconstructorVolumeData::nz, EMAN::FactoryBase::params, pixel_at(), power(), sqrt(), EMAN::ReconstructorVolumeData::subnx, EMAN::ReconstructorVolumeData::subny, EMAN::ReconstructorVolumeData::subnz, x, and y.

Referenced by determine_slice_agreement().

◆ do_insert_slice_work()

void WienerFourierReconstructor::do_insert_slice_work ( const EMData *const  input_slice,
const Transform euler,
const float  weight 
)
protectedvirtual

Definition at line 1679 of file reconstructor.cpp.

1680{
1681
1682 vector<Transform> syms = Symmetry3D::get_symmetries((string)params["sym"]);
1683
1684 float inx=(float)(input_slice->get_xsize()); // x/y dimensions of the input image
1685 float iny=(float)(input_slice->get_ysize());
1686
1687 int undo_wiener=(int)input_slice->get_attr_default("ctf_wiener_filtered",0); // indicates whether we need to undo a wiener filter before insertion
1688// if (undo_wiener) throw UnexpectedBehaviorException("wiener_fourier does not yet accept already Wiener filtered class-averages. Suggest using ctf.auto averager for now.");
1689
1690 vector<float> snr=input_slice->get_attr("ctf_snr_total");
1691 float sub=1.0;
1692 if (inweight<0) sub=-1.0;
1693 float weight;
1694
1695 for ( vector<Transform>::const_iterator it = syms.begin(); it != syms.end(); ++it ) {
1696 Transform t3d = arg*(*it);
1697 for (int y = -iny/2; y < iny/2; y++) {
1698 for (int x = 0; x <= inx/2; x++) {
1699
1700 float rx = (float) x/(inx-2.0f); // coords relative to Nyquist=.5
1701 float ry = (float) y/iny;
1702
1703 // This deals with the SNR weight
1704 float rn = (float)hypot(rx,ry);
1705 if (rn>=.5) continue; // no SNR in the corners, and we're going to mask them later anyway
1706 rn*=snr.size()*2.0f;
1707 int rni=(int)floor(rn);
1708 if ((unsigned int)rni>=snr.size()-1) weight=snr[snr.size()-1]*sub;
1709 else {
1710 rn-=rni;
1711 weight=Util::linear_interpolate(snr[rni],snr[rni+1],rn);
1712 }
1713// if (weight>500.0) printf("%f %d %d %f %f %d %f\n",weight,x,y,rx,ry,rni);
1714
1715 Vec3f coord(rx,ry,0);
1716 coord = coord*t3d; // transpose multiplication
1717 float xx = coord[0]; // transformed coordinates in terms of Nyquist
1718 float yy = coord[1];
1719 float zz = coord[2];
1720
1721 // Map back to real pixel coordinates in output volume
1722 xx=xx*(nx-2);
1723 yy=yy*ny;
1724 zz=zz*nz;
1725
1726// printf("%f\n",weight);
1727 if (undo_wiener) inserter->insert_pixel(xx,yy,zz,(input_slice->get_complex_at(x,y))*((weight+1.0f)/weight),weight*sub);
1728 else inserter->insert_pixel(xx,yy,zz,input_slice->get_complex_at(x,y),weight*sub);
1729 }
1730 }
1731 }
1732}
virtual bool insert_pixel(const float &xx, const float &yy, const float &zz, const std::complex< float > dt, const float &weight=1.0)=0
Insert a complex pixel [dt[0]+dt[1]i] at (float) coordinate [xx,yy,zz] with weighting into a discrete...
FourierPixelInserter3D * inserter
A pixel inserter pointer which inserts pixels into the 3D volume using one of a variety of insertion ...
static float linear_interpolate(float p1, float p2, float t)
Calculate linear interpolation.
Definition: util.h:518

References EMAN::Symmetry3D::get_symmetries(), EMAN::FourierPixelInserter3D::insert_pixel(), EMAN::FourierReconstructor::inserter, EMAN::Util::linear_interpolate(), EMAN::ReconstructorVolumeData::nx, EMAN::ReconstructorVolumeData::ny, EMAN::ReconstructorVolumeData::nz, EMAN::FactoryBase::params, sub(), x, and y.

Referenced by determine_slice_agreement(), and insert_slice().

◆ finish()

EMData * WienerFourierReconstructor::finish ( bool  doift = true)
virtual

Get the reconstructed volume Normally will return the volume in real-space with the requested size.

The calling application is responsible for removing any padding.

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 real space reconstructed volume

Reimplemented from EMAN::FourierReconstructor.

Definition at line 1921 of file reconstructor.cpp.

1922{
1923
1924 bool sqrtnorm=params.set_default("sqrtnorm",false);
1925 normalize_threed(sqrtnorm,true); // true is the wiener filter
1926
1927 if (doift) {
1928 image->do_ift_inplace();
1929 image->depad();
1930 image->process_inplace("xform.phaseorigin.tocenter");
1931 }
1932
1933 image->update();
1934
1935 if (params.has_key("savenorm") && strlen((const char *)params["savenorm"])>0) {
1936 if (tmp_data->get_ysize()%2==0 && tmp_data->get_zsize()%2==0) tmp_data->process_inplace("xform.fourierorigin.tocenter");
1937 tmp_data->write_image((const char *)params["savenorm"]);
1938 }
1939
1940 delete tmp_data;
1941 tmp_data=0;
1942 EMData *ret=image;
1943 image=0;
1944
1945 return ret;
1946}
type set_default(const string &key, type val)
Default setting behavior This can be achieved using a template - d.woolford Jan 2008 (before there wa...
Definition: emobject.h:569
bool has_key(const string &key) const
Ask the Dictionary if it as a particular key.
Definition: emobject.h:511
EMData * image
Inheriting class allocates this, probably in setup().
EMData * tmp_data
Inheriting class may allocate this, probably in setup()
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 c...

References EMAN::Dict::has_key(), EMAN::ReconstructorVolumeData::image, EMAN::ReconstructorVolumeData::normalize_threed(), EMAN::FactoryBase::params, EMAN::Dict::set_default(), and EMAN::ReconstructorVolumeData::tmp_data.

◆ get_desc()

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

Get the one line description of the reconstructor.

Reimplemented from EMAN::FourierReconstructor.

Definition at line 640 of file reconstructor.h.

641 {
642 return "Reconstruction via direct Fourier methods using one of a variety of different kernels, most of which are Gaussian based. This version also incorporates a nonisotropic Wiener filter based on SNR estimates stored in the class-average headers by the ctf.auto averager.";
643 }

◆ get_name()

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

Get the unique name of the reconstructor.

Reimplemented from EMAN::FourierReconstructor.

Definition at line 633 of file reconstructor.h.

634 {
635 return NAME;
636 }

References NAME.

◆ insert_slice()

int WienerFourierReconstructor::insert_slice ( const EMData *const  slice,
const Transform euler,
const float  weight 
)
virtual

Insert a slice into a 3D volume, in a given orientation.

Returns
0 if successful, 1 otherwise
Parameters
slicethe image slice to be inserted into the 3D volume
eulerEuler angle of this image slice.
weightThis is ignored in this reconstructor, since the SSNR from the particle header is used instead
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::FourierReconstructor.

Definition at line 1643 of file reconstructor.cpp.

1644{
1645 // Are these exceptions really necessary? (d.woolford)
1646 if (!input_slice) throw NullPointerException("EMData pointer (input image) is NULL");
1647
1648 Transform * rotation;
1649/* if ( input_slice->has_attr("xform.projection") ) {
1650 rotation = (Transform*) (input_slice->get_attr("xform.projection")); // assignment operator
1651 } else {*/
1652 rotation = new Transform(arg); // assignment operator
1653// }
1654
1655 if (!input_slice->has_attr("ctf_snr_total"))
1656 throw NotExistingObjectException("ctf_snr_total","No SNR information present in class-average. Must use the ctf.auto or ctfw.auto averager.");
1657
1658 EMData *slice;
1659 if (input_slice->get_attr_default("reconstruct_preproc",(int) 0)) slice=input_slice->copy();
1660 else slice = preprocess_slice( input_slice, *rotation);
1661
1662
1663 // We must use only the rotational component of the transform, scaling, translation and mirroring
1664 // are not implemented in Fourier space, but are in preprocess_slice
1665 rotation->set_scale(1.0);
1666 rotation->set_mirror(false);
1667 rotation->set_trans(0,0,0);
1668
1669 // Finally to the pixel wise slice insertion
1670 do_insert_slice_work(slice, *rotation, weight);
1671
1672 delete rotation; rotation=0;
1673 delete slice;
1674
1675// image->update();
1676 return 0;
1677}
#define NotExistingObjectException(objname, desc)
Definition: exception.h:130

References do_insert_slice_work(), NotExistingObjectException, NullPointerException, EMAN::FourierReconstructor::preprocess_slice(), EMAN::Transform::set_mirror(), EMAN::Transform::set_scale(), and EMAN::Transform::set_trans().

◆ NEW()

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

Factory incorporation uses the pointer of this function.

Returns
a Reconstructor pointer to a newly allocated WienerFourierReconstructor

Definition at line 648 of file reconstructor.h.

649 {
650 return new WienerFourierReconstructor();
651 }
WienerFourierReconstructor()
Default constructor calls load_default_settings()

References WienerFourierReconstructor().

◆ operator=()

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

Disallow assignment.

◆ pixel_at()

bool WienerFourierReconstructor::pixel_at ( const float &  xx,
const float &  yy,
const float &  zz,
float *  dt 
)
protectedvirtual

This is a mode-2 pixel extractor.

Parameters
xx,yy,zzvoxel coordinates (need not be integers)
dtfloat pointer with 3 floats allocated for returned complex value and weight sum

Reimplemented from EMAN::FourierReconstructor.

Definition at line 1847 of file reconstructor.cpp.

1848{
1849 int x0 = (int) floor(xx);
1850 int y0 = (int) floor(yy);
1851 int z0 = (int) floor(zz);
1852
1853 float *rdata=image->get_data();
1854 float *norm=tmp_data->get_data();
1855 float normsum=0,normsum2=0;
1856
1857 dt[0]=dt[1]=dt[2]=0.0;
1858
1859 if (nx==subnx) { // normal full reconstruction
1860 if (x0<-nx2-1 || y0<-ny2-1 || z0<-nz2-1 || x0>nx2 || y0>ny2 || z0>nz2 ) return false;
1861
1862 // no error checking on add_complex_fast, so we need to be careful here
1863 int x1=x0+1;
1864 int y1=y0+1;
1865 int z1=z0+1;
1866 if (x0<-nx2) x0=-nx2;
1867 if (x1>nx2) x1=nx2;
1868 if (y0<-ny2) y0=-ny2;
1869 if (y1>ny2) y1=ny2;
1870 if (z0<-nz2) z0=-nz2;
1871 if (z1>nz2) z1=nz2;
1872
1873 size_t idx=0;
1874 float r, gg;
1875 for (int k = z0 ; k <= z1; k++) {
1876 for (int j = y0 ; j <= y1; j++) {
1877 for (int i = x0; i <= x1; i ++) {
1878 r = Util::hypot3sq((float) i - xx, j - yy, k - zz);
1879 idx=image->get_complex_index_fast(i,j,k);
1880 gg = Util::fast_exp(-r / EMConsts::I2G);
1881
1882 dt[0]+=gg*rdata[idx];
1883 dt[1]+=(i<0?-1.0f:1.0f)*gg*rdata[idx+1];
1884 dt[2]+=norm[idx/2]*gg;
1885 normsum2+=gg;
1886 normsum+=gg*norm[idx/2];
1887 }
1888 }
1889 }
1890 if (normsum==0) return false;
1891 dt[0]/=normsum;
1892 dt[1]/=normsum;
1893 dt[2]/=normsum2;
1894// printf("%1.2f,%1.2f,%1.2f\t%1.3f\t%1.3f\t%1.3f\t%1.3f\t%1.3f\n",xx,yy,zz,dt[0],dt[1],dt[2],rdata[idx],rdata[idx+1]);
1895 return true;
1896 }
1897 else { // for subvolumes, not optimized yet
1898 size_t idx;
1899 float r, gg;
1900 for (int k = z0 ; k <= z0 + 1; k++) {
1901 for (int j = y0 ; j <= y0 + 1; j++) {
1902 for (int i = x0; i <= x0 + 1; i ++) {
1903 r = Util::hypot3sq((float) i - xx, j - yy, k - zz);
1904 idx=image->get_complex_index(i,j,k,subx0,suby0,subz0,nx,ny,nz);
1905 gg = Util::fast_exp(-r / EMConsts::I2G)*norm[idx/2];
1906
1907 dt[0]+=gg*rdata[idx];
1908 dt[1]+=(i<0?-1.0f:1.0f)*gg*rdata[idx+1];
1909 dt[2]+=norm[idx/2];
1910 normsum+=gg;
1911 }
1912 }
1913 }
1914
1915 if (normsum==0) return false;
1916 return true;
1917 }
1918}
#define rdata(i)
Definition: analyzer.cpp:592
static const float I2G
Definition: emobject.h:72
static int hypot3sq(int x, int y, int z)
Euclidean distance function squared in 3D: f(x,y,z) = (x*x + y*y + z*z);.
Definition: util.h:805
static float fast_exp(const float &f)
Returns an approximate of exp(x) using a cached table uses actual exp(x) outside the cached range.
Definition: util.cpp:788

References EMAN::Util::fast_exp(), EMAN::Util::hypot3sq(), EMAN::EMConsts::I2G, EMAN::ReconstructorVolumeData::image, EMAN::ReconstructorVolumeData::nx, EMAN::ReconstructorVolumeData::nx2, EMAN::ReconstructorVolumeData::ny, EMAN::ReconstructorVolumeData::ny2, EMAN::ReconstructorVolumeData::nz, EMAN::ReconstructorVolumeData::nz2, rdata, EMAN::ReconstructorVolumeData::subnx, EMAN::ReconstructorVolumeData::subx0, EMAN::ReconstructorVolumeData::suby0, EMAN::ReconstructorVolumeData::subz0, and EMAN::ReconstructorVolumeData::tmp_data.

Referenced by do_compare_slice_work().

Member Data Documentation

◆ NAME

const string WienerFourierReconstructor::NAME = "wiener_fourier"
static

Definition at line 653 of file reconstructor.h.

Referenced by get_name().


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