EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes
EMAN::FourierReconstructorSimple2D Class Reference

This class originally added for 2D experimentation and prototying. More...

#include <reconstructor.h>

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

List of all members.

Public Member Functions

 FourierReconstructorSimple2D ()
virtual ~FourierReconstructorSimple2D ()
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 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 = "fouriersimple2D"

Detailed Description

This class originally added for 2D experimentation and prototying.

It is basically a replica of the FourierReconstructor, but works in 2D

Author:
David Woolford and Phil Baldwin
Date:
early 2008

Definition at line 283 of file reconstructor.h.


Constructor & Destructor Documentation

EMAN::FourierReconstructorSimple2D::FourierReconstructorSimple2D ( ) [inline]

Definition at line 286 of file reconstructor.h.

Referenced by NEW().

{}
virtual EMAN::FourierReconstructorSimple2D::~FourierReconstructorSimple2D ( ) [inline, virtual]

Definition at line 288 of file reconstructor.h.

{ }

Member Function Documentation

EMData * FourierReconstructorSimple2D::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 246 of file reconstructor.cpp.

References EMAN::EMData::depad(), EMAN::EMData::do_ift_inplace(), EMAN::ReconstructorVolumeData::image, EMAN::ReconstructorVolumeData::normalize_threed(), and EMAN::EMData::process_inplace().

{
        normalize_threed();

        image->process_inplace("xform.fourierorigin.tocorner");
        image->do_ift_inplace();
        image->depad();
        image->process_inplace("xform.phaseorigin.tocenter");

        EMData *ret = image;
        image = 0;
        return  ret;
}
virtual string EMAN::FourierReconstructorSimple2D::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 298 of file reconstructor.h.

{ return "performs 2D reconstruction"; }
virtual string EMAN::FourierReconstructorSimple2D::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 296 of file reconstructor.h.

References NAME.

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

Implements EMAN::FactoryBase.

Definition at line 306 of file reconstructor.h.

References EMAN::EMObject::INT, and EMAN::TypeDict::put().

                        {
                                TypeDict d;
                                d.put("nx", EMObject::INT, "Necessary. The x dimension of the input images.");
//                              d.put("sym", EMObject::STRING, "Symmetry - assumed to be C1 if not specified");
                                return d;
                        }
int FourierReconstructorSimple2D::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 129 of file reconstructor.cpp.

References EMAN::Util::agauss(), EMAN::EMData::do_fft_inplace(), dt, EMAN::EMData::get_data(), EMAN::EMData::get_ndim(), EMAN::Transform::get_rotation(), EMAN::EMData::get_xsize(), EMAN::EMConsts::I2G, EMAN::ReconstructorVolumeData::image, ImageDimensionException, ImageFormatException, EMAN::EMData::is_complex(), norm(), NullPointerException, EMAN::ReconstructorVolumeData::nx, EMAN::ReconstructorVolumeData::ny, EMAN::EMData::process(), rdata, EMAN::ReconstructorVolumeData::tmp_data, and x.

{

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

        if ( slice->get_ndim() != 1 ) throw ImageDimensionException("Image dimension must be 1");

        // I could also test to make sure the image is the right dimensions...
        if (slice->is_complex()) throw ImageFormatException("The image is complex, expecting real");

        EMData* working_slice = slice->process("xform.phaseorigin.tocorner");

        // Fourier transform the slice
        working_slice->do_fft_inplace();

        float* rdata = image->get_data();
        float* norm = tmp_data->get_data();
        float* dat = working_slice->get_data();

        float g[4];
        int offset[4];
        float dt[2];
        offset[0] = 0; offset[1] = 2; offset[2] = nx; offset[3] = nx+2;

        float alt = -((float)(euler.get_rotation("2d"))["alpha"])*M_PI/180.0f;
        for (int x = 0; x < working_slice->get_xsize() / 2; x++) {

                float rx = (float) x;

                float xx = rx*cos(alt);
                float yy = rx*sin(alt);
                float cc = 1.0;

                if (xx < 0) {
                        xx = -xx;
                        yy = -yy;
                        cc = -1.0;
                }

                yy += ny / 2;


                dt[0] = dat[2*x];
                dt[1] = cc * dat[2*x+1];

                // PHIL IS INTERESTED FROM HERE DOWN
                int x0 = (int) floor(xx);
                int y0 = (int) floor(yy);

                int i = 2*x0 + y0*nx;

                float dx = xx - x0;
                float dy = yy - y0;

                g[0] = Util::agauss(1, dx, dy, 0, EMConsts::I2G);
                g[1] = Util::agauss(1, 1 - dx, dy, 0, EMConsts::I2G);
                g[2] = Util::agauss(1, dx, 1 - dy, 0, EMConsts::I2G);
                g[3] = Util::agauss(1, 1 - dx, 1 - dy, 0, EMConsts::I2G);

                // At the extreme we can only do some much...
                if ( x0 == nx-2 ) {
                        int k = i + offset[0];
                        rdata[k] += g[0] * dt[0];
                        rdata[k + 1] += g[0] * dt[1];
                        norm[k/2] += g[0];

                        k = i + offset[2];
                        rdata[k] += g[2] * dt[0];
                        rdata[k + 1] += g[2] * dt[1];
                        norm[k/2] += g[2];
                        continue;

                }
                // capture and accommodate for periodic boundary conditions in the x direction
                if ( x0 > nx-2 ) {
                        int dif = x0 - (nx-2);
                        x0 -= dif;
                }
                // At the extreme we can only do some much...
                if ( y0 == ny -1 ) {
                        int k = i + offset[0];
                        rdata[k] += g[0] * dt[0];
                        rdata[k + 1] += g[0] * dt[1];
                        norm[k/2] += g[0];

                        k = i + offset[1];
                        rdata[k] += g[1] * dt[0];
                        rdata[k + 1] += g[1] * dt[1];
                        norm[k/2] += g[1];
                        continue;
                }
                // capture and accommodate for periodic boundary conditions in the y direction
                if ( y0 > ny-1) {
                        int dif = y0 - (ny-1);
                        y0 -= dif;
                }

                if (x0 >= nx - 2 || y0 >= ny - 1) continue;




                for (int j = 0; j < 4; j++)
                {
                        int k = i + offset[j];
                        rdata[k] += g[j] * dt[0];
                        rdata[k + 1] += g[j] * dt[1];
                        norm[k/2] += g[j];

                }
        }

        return 0;

}
static Reconstructor* EMAN::FourierReconstructorSimple2D::NEW ( ) [inline, static]

Definition at line 300 of file reconstructor.h.

References FourierReconstructorSimple2D().

                        {
                                return new FourierReconstructorSimple2D();
                        }
void FourierReconstructorSimple2D::setup ( ) [virtual]

Member Data Documentation

const string FourierReconstructorSimple2D::NAME = "fouriersimple2D" [static]

Definition at line 314 of file reconstructor.h.

Referenced by get_name().


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