#include <reconstructor.h>
Inheritance diagram for EMAN::FourierReconstructorSimple2D:
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 EMData * | finish (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 Reconstructor * | NEW () |
Static Public Attributes | |
static const string | NAME = "fouriersimple2D" |
It is basically a replica of the FourierReconstructor, but works in 2D
Definition at line 282 of file reconstructor.h.
EMAN::FourierReconstructorSimple2D::FourierReconstructorSimple2D | ( | ) | [inline] |
virtual EMAN::FourierReconstructorSimple2D::~FourierReconstructorSimple2D | ( | ) | [inline, virtual] |
EMData * FourierReconstructorSimple2D::finish | ( | bool | doift = true |
) | [virtual] |
Finish reconstruction and return the complete model.
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 |
Reimplemented from EMAN::Reconstructor.
Definition at line 242 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().
00243 { 00244 normalize_threed(); 00245 00246 image->process_inplace("xform.fourierorigin.tocorner"); 00247 image->do_ift_inplace(); 00248 image->depad(); 00249 image->process_inplace("xform.phaseorigin.tocenter"); 00250 00251 EMData *ret = image; 00252 image = 0; 00253 return ret; 00254 }
virtual string EMAN::FourierReconstructorSimple2D::get_desc | ( | ) | const [inline, virtual] |
Get a clear, concise description of this class.
Implements EMAN::FactoryBase.
Definition at line 297 of file reconstructor.h.
virtual string EMAN::FourierReconstructorSimple2D::get_name | ( | ) | const [inline, virtual] |
Get the unique name of this class (especially for factory based instantiation access).
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] |
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.
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 |
Reimplemented from EMAN::Reconstructor.
Definition at line 125 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.
00126 { 00127 00128 // Are these exceptions really necessary? (d.woolford) 00129 if (!slice) throw NullPointerException("EMData pointer (input image) is NULL"); 00130 00131 if ( slice->get_ndim() != 1 ) throw ImageDimensionException("Image dimension must be 1"); 00132 00133 // I could also test to make sure the image is the right dimensions... 00134 if (slice->is_complex()) throw ImageFormatException("The image is complex, expecting real"); 00135 00136 EMData* working_slice = slice->process("xform.phaseorigin.tocorner"); 00137 00138 // Fourier transform the slice 00139 working_slice->do_fft_inplace(); 00140 00141 float* rdata = image->get_data(); 00142 float* norm = tmp_data->get_data(); 00143 float* dat = working_slice->get_data(); 00144 00145 float g[4]; 00146 int offset[4]; 00147 float dt[2]; 00148 offset[0] = 0; offset[1] = 2; offset[2] = nx; offset[3] = nx+2; 00149 00150 float alt = -((float)(euler.get_rotation("2d"))["alpha"])*M_PI/180.0f; 00151 for (int x = 0; x < working_slice->get_xsize() / 2; x++) { 00152 00153 float rx = (float) x; 00154 00155 float xx = rx*cos(alt); 00156 float yy = rx*sin(alt); 00157 float cc = 1.0; 00158 00159 if (xx < 0) { 00160 xx = -xx; 00161 yy = -yy; 00162 cc = -1.0; 00163 } 00164 00165 yy += ny / 2; 00166 00167 00168 dt[0] = dat[2*x]; 00169 dt[1] = cc * dat[2*x+1]; 00170 00171 // PHIL IS INTERESTED FROM HERE DOWN 00172 int x0 = (int) floor(xx); 00173 int y0 = (int) floor(yy); 00174 00175 int i = 2*x0 + y0*nx; 00176 00177 float dx = xx - x0; 00178 float dy = yy - y0; 00179 00180 g[0] = Util::agauss(1, dx, dy, 0, EMConsts::I2G); 00181 g[1] = Util::agauss(1, 1 - dx, dy, 0, EMConsts::I2G); 00182 g[2] = Util::agauss(1, dx, 1 - dy, 0, EMConsts::I2G); 00183 g[3] = Util::agauss(1, 1 - dx, 1 - dy, 0, EMConsts::I2G); 00184 00185 // At the extreme we can only do some much... 00186 if ( x0 == nx-2 ) { 00187 int k = i + offset[0]; 00188 rdata[k] += g[0] * dt[0]; 00189 rdata[k + 1] += g[0] * dt[1]; 00190 norm[k/2] += g[0]; 00191 00192 k = i + offset[2]; 00193 rdata[k] += g[2] * dt[0]; 00194 rdata[k + 1] += g[2] * dt[1]; 00195 norm[k/2] += g[2]; 00196 continue; 00197 00198 } 00199 // capture and accommodate for periodic boundary conditions in the x direction 00200 if ( x0 > nx-2 ) { 00201 int dif = x0 - (nx-2); 00202 x0 -= dif; 00203 } 00204 // At the extreme we can only do some much... 00205 if ( y0 == ny -1 ) { 00206 int k = i + offset[0]; 00207 rdata[k] += g[0] * dt[0]; 00208 rdata[k + 1] += g[0] * dt[1]; 00209 norm[k/2] += g[0]; 00210 00211 k = i + offset[1]; 00212 rdata[k] += g[1] * dt[0]; 00213 rdata[k + 1] += g[1] * dt[1]; 00214 norm[k/2] += g[1]; 00215 continue; 00216 } 00217 // capture and accommodate for periodic boundary conditions in the y direction 00218 if ( y0 > ny-1) { 00219 int dif = y0 - (ny-1); 00220 y0 -= dif; 00221 } 00222 00223 if (x0 >= nx - 2 || y0 >= ny - 1) continue; 00224 00225 00226 00227 00228 for (int j = 0; j < 4; j++) 00229 { 00230 int k = i + offset[j]; 00231 rdata[k] += g[j] * dt[0]; 00232 rdata[k + 1] += g[j] * dt[1]; 00233 norm[k/2] += g[j]; 00234 00235 } 00236 } 00237 00238 return 0; 00239 00240 }
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 104 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.
00105 { 00106 nx = params.set_default("nx",0); 00107 00108 if ( nx < 0 ) throw InvalidValueException(nx, "nx must be positive"); 00109 00110 bool is_fftodd = (nx % 2 == 1); 00111 00112 ny = nx; 00113 nx += 2-is_fftodd; 00114 00115 image = new EMData(); 00116 image->set_size(nx, ny); 00117 image->set_complex(true); 00118 image->set_fftodd(is_fftodd); 00119 image->set_ri(true); 00120 00121 tmp_data = new EMData(); 00122 tmp_data->set_size(nx/2, nx); 00123 }
const string FourierReconstructorSimple2D::NAME = "fouriersimple2D" [static] |