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


Constructor & Destructor Documentation

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

Definition at line 281 of file reconstructor.h.

Referenced by NEW().

00281 {}

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

Definition at line 283 of file reconstructor.h.

00283 { }


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 234 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().

00235 {
00236         normalize_threed();
00237 
00238         image->process_inplace("xform.fourierorigin.tocorner");
00239         image->do_ift_inplace();
00240         image->depad();
00241         image->process_inplace("xform.phaseorigin.tocenter");
00242 
00243         return          image;
00244 }

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

00293 { 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 291 of file reconstructor.h.

References NAME.

00291 { 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 301 of file reconstructor.h.

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

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

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 117 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.

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

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

Definition at line 295 of file reconstructor.h.

References FourierReconstructorSimple2D().

00296                         {
00297                                 return new FourierReconstructorSimple2D();
00298                         }

void FourierReconstructorSimple2D::setup (  )  [virtual]

Initialize the reconstructor.

Implements EMAN::Reconstructor.

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

00097 {
00098         nx = params.set_default("nx",0);
00099 
00100         if ( nx < 0 ) throw InvalidValueException(nx, "nx must be positive");
00101 
00102         bool is_fftodd = (nx % 2 == 1);
00103 
00104         ny = nx;
00105         nx += 2-is_fftodd;
00106 
00107         image = new EMData();
00108         image->set_size(nx, ny);
00109         image->set_complex(true);
00110         image->set_fftodd(is_fftodd);
00111         image->set_ri(true);
00112 
00113         tmp_data = new EMData();
00114         tmp_data->set_size(nx/2, nx);
00115 }


Member Data Documentation

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

Definition at line 309 of file reconstructor.h.

Referenced by get_name().


The documentation for this class was generated from the following files:
Generated on Mon Jul 19 12:44:23 2010 for EMAN2 by  doxygen 1.4.7