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

Fourier gridding projection routine. More...

#include <projector.h>

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

List of all members.

Public Member Functions

EMDataproject3d (EMData *image) const
 Project an 3D image into a 2D image.
EMDatabackproject3d (EMData *image) const
 Back-project a 2D image into a 3D image.
string get_name () const
 Get the projector's name.
string get_desc () const
TypeDict get_param_types () const
 Get processor parameter information in a dictionary.

Static Public Member Functions

static ProjectorNEW ()

Static Public Attributes

static const string NAME = "fourier_gridding"

Detailed Description

Fourier gridding projection routine.

See also:
P. A. Penczek, R. Renka, and H. Schomberg, J. Opt. Soc. Am. A _21_, 499-509 (2004)

Definition at line 206 of file projector.h.


Member Function Documentation

EMData * FourierGriddingProjector::backproject3d ( EMData image) const [virtual]

Back-project a 2D image into a 3D image.

Returns:
A 3D image from the backprojection.

Implements EMAN::Projector.

Definition at line 2118 of file projector.cpp.

{
   // no implementation yet
   EMData *ret = new EMData();
   return ret;
}
string EMAN::FourierGriddingProjector::get_desc ( ) const [inline, virtual]

Implements EMAN::Projector.

Definition at line 219 of file projector.h.

                {
                        return "Fourier-space projection using gridding.";
                }
string EMAN::FourierGriddingProjector::get_name ( ) const [inline, virtual]

Get the projector's name.

Each projector is indentified by unique name.

Returns:
The projector's name.

Implements EMAN::Projector.

Definition at line 214 of file projector.h.

References NAME.

                {
                        return NAME;
                }
TypeDict EMAN::FourierGriddingProjector::get_param_types ( ) const [inline, virtual]

Get processor parameter information in a dictionary.

Each parameter has one record in the dictionary. Each record contains its name, data-type, and description.

Returns:
A dictionary containing the parameter info.

Reimplemented from EMAN::Projector.

Definition at line 228 of file projector.h.

References EMAN::EMObject::FLOAT, EMAN::EMObject::FLOATARRAY, EMAN::EMObject::INT, EMAN::TypeDict::put(), EMAN::EMObject::STRING, and EMAN::EMObject::TRANSFORM.

                {
                        TypeDict d;
                        d.put("transform", EMObject::TRANSFORM);
                        d.put("kb_alpha", EMObject::FLOAT);
                        d.put("kb_K", EMObject::FLOAT);
                        d.put("angletype", EMObject::STRING);
                        d.put("anglelist", EMObject::FLOATARRAY);
                        d.put("theta", EMObject::FLOAT);
                        d.put("psi", EMObject::FLOAT);
                        d.put("npad", EMObject::INT);
                        return d;
                }
static Projector* EMAN::FourierGriddingProjector::NEW ( ) [inline, static]

Definition at line 224 of file projector.h.

                {
                        return new FourierGriddingProjector();
                }
EMData * FourierGriddingProjector::project3d ( EMData image) const [virtual]

Project an 3D image into a 2D image.

Returns:
A 2D image from the projection.

Implements EMAN::Projector.

Definition at line 1164 of file projector.cpp.

References anglelist, EMAN::EMData::center_origin_fft(), EMAN::EMData::copy(), EMAN::EMData::divkbsinh(), EMAN::EMData::do_fft_inplace(), EMAN::EMData::do_ift_inplace(), EMAN::EMData::extract_plane(), EMAN::EMData::fft_shuffle(), EMAN::EMData::get_ndim(), EMAN::Transform::get_rotation(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), ImageDimensionException, ImageFormatException, EMAN::EMData::is_complex(), EMAN::EMData::is_shuffled(), EMAN::EMData::norm_pad(), NullPointerException, nx, ny, phi, proj, EMAN::EMData::set_attr(), EMAN::EMData::set_size(), tf(), theta, EMAN::EMData::to_zero(), EMAN::EMData::update(), and EMAN::EMData::window_center().

{
        if (!image) {
                return 0;
        }
        if (3 != image->get_ndim())
                throw ImageDimensionException(
                                                                          "FourierGriddingProjector needs a 3-D volume");
        if (image->is_complex())
                throw ImageFormatException(
                                                                   "FourierGriddingProjector requires a real volume");
        const int npad = params.has_key("npad") ? int(params["npad"]) : 2;
        const int nx = image->get_xsize();
        const int ny = image->get_ysize();
        const int nz = image->get_zsize();
        if (nx != ny || nx != nz)
                throw ImageDimensionException(
                                                                          "FourierGriddingProjector requires nx==ny==nz");
        const int m = Util::get_min(nx,ny,nz);
        const int n = m*npad;

        int K = params["kb_K"];
        if ( K == 0 ) K = 6;
        float alpha = params["kb_alpha"];
        if ( alpha == 0 ) alpha = 1.25;
        Util::KaiserBessel kb(alpha, K, (float)(m/2), K/(2.0f*n), n);

        // divide out gridding weights
        EMData* tmpImage = image->copy();
        tmpImage->divkbsinh(kb);
        // pad and center volume, then FFT and multiply by (-1)**(i+j+k)
        //EMData* imgft = tmpImage->pad_fft(npad);
        //imgft->center_padded();
        EMData* imgft = tmpImage->norm_pad(false, npad);
        imgft->do_fft_inplace();
        imgft->center_origin_fft();
        imgft->fft_shuffle();
        delete tmpImage;

        // Do we have a list of angles?
        int nangles = 0;
        vector<float> anglelist;
        // Do we have a list of angles?
        if (params.has_key("anglelist")) {
                anglelist = params["anglelist"];
                nangles = anglelist.size() / 3;
        } else {
                // This part was modified by David Woolford -
                // Before this the code worked only for SPIDER and EMAN angles,
                // but the framework of the Transform3D allows for a generic implementation
                // as specified here.
                Transform* t3d = params["transform"];
                if ( t3d == NULL ) throw NullPointerException("The transform object (required for projection), was not specified");
                Dict p = t3d->get_rotation("spider");

                string angletype = "SPIDER";
                float phi = p["phi"];
                float theta = p["theta"];
                float psi = p["psi"];
                anglelist.push_back(phi);
                anglelist.push_back(theta);
                anglelist.push_back(psi);
                nangles = 1;
                if(t3d) {delete t3d; t3d=0;}
        }

        // End David Woolford modifications

        // initialize return object
        EMData* ret = new EMData();
        ret->set_size(nx, ny, nangles);
        ret->to_zero();
        // loop over sets of angles
        for (int ia = 0; ia < nangles; ia++) {
                int indx = 3*ia;
                Dict d("type","spider","phi",anglelist[indx],"theta",anglelist[indx+1],"psi",anglelist[indx+2]);
                Transform tf(d);
                EMData* proj = imgft->extract_plane(tf, kb);
                if (proj->is_shuffled()) proj->fft_shuffle();
                proj->center_origin_fft();
                proj->do_ift_inplace();
                EMData* winproj = proj->window_center(m);
                delete proj;
                for (int iy=0; iy < ny; iy++)
                        for (int ix=0; ix < nx; ix++)
                                (*ret)(ix,iy,ia) = (*winproj)(ix,iy);
                delete winproj;
        }
        delete imgft;

        if (!params.has_key("anglelist")) {
                Transform* t3d = params["transform"];
                ret->set_attr("xform.projection",t3d);
                if(t3d) {delete t3d; t3d=0;}
        }
        ret->update();
        return ret;
}

Member Data Documentation

const string FourierGriddingProjector::NAME = "fourier_gridding" [static]

Definition at line 242 of file projector.h.

Referenced by get_name().


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