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=1.0)
 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 282 of file reconstructor.h.


Constructor & Destructor Documentation

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

Definition at line 285 of file reconstructor.h.

Referenced by NEW().

00285 {}

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

Definition at line 287 of file reconstructor.h.

00287 { }


Member Function Documentation

EMData * FourierReconstructorSimple2D::finish ( bool  doift = true  )  [virtual]

Finish reconstruction and return the complete model.

Parameters:
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
Returns:
The result 3D model.

Reimplemented from EMAN::Reconstructor.

Definition at line 244 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().

00245 {
00246         normalize_threed();
00247 
00248         image->process_inplace("xform.fourierorigin.tocorner");
00249         image->do_ift_inplace();
00250         image->depad();
00251         image->process_inplace("xform.phaseorigin.tocenter");
00252 
00253         EMData *ret = image;
00254         image = 0;
00255         return  ret;
00256 }

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

00297 { 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 295 of file reconstructor.h.

References NAME.

00295 { 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 305 of file reconstructor.h.

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

00306                         {
00307                                 TypeDict d;
00308                                 d.put("nx", EMObject::INT, "Necessary. The x dimension of the input images.");
00309 //                              d.put("sym", EMObject::STRING, "Symmetry - assumed to be C1 if not specified");
00310                                 return d;
00311                         }

int FourierReconstructorSimple2D::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.

Parameters:
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
Returns:
0 if OK. 1 if error.

Reimplemented from EMAN::Reconstructor.

Definition at line 127 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.

00128 {
00129 
00130         // Are these exceptions really necessary? (d.woolford)
00131         if (!slice) throw NullPointerException("EMData pointer (input image) is NULL");
00132 
00133         if ( slice->get_ndim() != 1 ) throw ImageDimensionException("Image dimension must be 1");
00134 
00135         // I could also test to make sure the image is the right dimensions...
00136         if (slice->is_complex()) throw ImageFormatException("The image is complex, expecting real");
00137 
00138         EMData* working_slice = slice->process("xform.phaseorigin.tocorner");
00139 
00140         // Fourier transform the slice
00141         working_slice->do_fft_inplace();
00142 
00143         float* rdata = image->get_data();
00144         float* norm = tmp_data->get_data();
00145         float* dat = working_slice->get_data();
00146 
00147         float g[4];
00148         int offset[4];
00149         float dt[2];
00150         offset[0] = 0; offset[1] = 2; offset[2] = nx; offset[3] = nx+2;
00151 
00152         float alt = -((float)(euler.get_rotation("2d"))["alpha"])*M_PI/180.0f;
00153         for (int x = 0; x < working_slice->get_xsize() / 2; x++) {
00154 
00155                 float rx = (float) x;
00156 
00157                 float xx = rx*cos(alt);
00158                 float yy = rx*sin(alt);
00159                 float cc = 1.0;
00160 
00161                 if (xx < 0) {
00162                         xx = -xx;
00163                         yy = -yy;
00164                         cc = -1.0;
00165                 }
00166 
00167                 yy += ny / 2;
00168 
00169 
00170                 dt[0] = dat[2*x];
00171                 dt[1] = cc * dat[2*x+1];
00172 
00173                 // PHIL IS INTERESTED FROM HERE DOWN
00174                 int x0 = (int) floor(xx);
00175                 int y0 = (int) floor(yy);
00176 
00177                 int i = 2*x0 + y0*nx;
00178 
00179                 float dx = xx - x0;
00180                 float dy = yy - y0;
00181 
00182                 g[0] = Util::agauss(1, dx, dy, 0, EMConsts::I2G);
00183                 g[1] = Util::agauss(1, 1 - dx, dy, 0, EMConsts::I2G);
00184                 g[2] = Util::agauss(1, dx, 1 - dy, 0, EMConsts::I2G);
00185                 g[3] = Util::agauss(1, 1 - dx, 1 - dy, 0, EMConsts::I2G);
00186 
00187                 // At the extreme we can only do some much...
00188                 if ( x0 == nx-2 ) {
00189                         int k = i + offset[0];
00190                         rdata[k] += g[0] * dt[0];
00191                         rdata[k + 1] += g[0] * dt[1];
00192                         norm[k/2] += g[0];
00193 
00194                         k = i + offset[2];
00195                         rdata[k] += g[2] * dt[0];
00196                         rdata[k + 1] += g[2] * dt[1];
00197                         norm[k/2] += g[2];
00198                         continue;
00199 
00200                 }
00201                 // capture and accommodate for periodic boundary conditions in the x direction
00202                 if ( x0 > nx-2 ) {
00203                         int dif = x0 - (nx-2);
00204                         x0 -= dif;
00205                 }
00206                 // At the extreme we can only do some much...
00207                 if ( y0 == ny -1 ) {
00208                         int k = i + offset[0];
00209                         rdata[k] += g[0] * dt[0];
00210                         rdata[k + 1] += g[0] * dt[1];
00211                         norm[k/2] += g[0];
00212 
00213                         k = i + offset[1];
00214                         rdata[k] += g[1] * dt[0];
00215                         rdata[k + 1] += g[1] * dt[1];
00216                         norm[k/2] += g[1];
00217                         continue;
00218                 }
00219                 // capture and accommodate for periodic boundary conditions in the y direction
00220                 if ( y0 > ny-1) {
00221                         int dif = y0 - (ny-1);
00222                         y0 -= dif;
00223                 }
00224 
00225                 if (x0 >= nx - 2 || y0 >= ny - 1) continue;
00226 
00227 
00228 
00229 
00230                 for (int j = 0; j < 4; j++)
00231                 {
00232                         int k = i + offset[j];
00233                         rdata[k] += g[j] * dt[0];
00234                         rdata[k + 1] += g[j] * dt[1];
00235                         norm[k/2] += g[j];
00236 
00237                 }
00238         }
00239 
00240         return 0;
00241 
00242 }

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

Definition at line 299 of file reconstructor.h.

References FourierReconstructorSimple2D().

00300                         {
00301                                 return new FourierReconstructorSimple2D();
00302                         }

void FourierReconstructorSimple2D::setup (  )  [virtual]

Initialize the reconstructor.

Implements EMAN::Reconstructor.

Definition at line 106 of file reconstructor.cpp.

References EMAN::ReconstructorVolumeData::image, InvalidValueException, is_fftodd(), EMAN::ReconstructorVolumeData::nx, EMAN::ReconstructorVolumeData::ny, EMAN::FactoryBase::params, EMAN::EMData::set_complex(), EMAN::Dict::set_default(), EMAN::EMData::set_fftodd(), EMAN::EMData::set_ri(), EMAN::EMData::set_size(), and EMAN::ReconstructorVolumeData::tmp_data.

00107 {
00108         nx = params.set_default("nx",0);
00109 
00110         if ( nx < 0 ) throw InvalidValueException(nx, "nx must be positive");
00111 
00112         bool is_fftodd = (nx % 2 == 1);
00113 
00114         ny = nx;
00115         nx += 2-is_fftodd;
00116 
00117         image = new EMData();
00118         image->set_size(nx, ny);
00119         image->set_complex(true);
00120         image->set_fftodd(is_fftodd);
00121         image->set_ri(true);
00122 
00123         tmp_data = new EMData();
00124         tmp_data->set_size(nx/2, nx);
00125 }


Member Data Documentation

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

Definition at line 313 of file reconstructor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Tue Jun 11 12:44:57 2013 for EMAN2 by  doxygen 1.4.7