EMAN2
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
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]

Public Member Functions

 FourierReconstructorSimple2D ()
 
virtual ~FourierReconstructorSimple2D ()
 
virtual void setup ()
 Initialize the reconstructor. More...
 
virtual int insert_slice (const EMData *const slice, const Transform &euler, const float weight)
 Insert an image slice to the reconstructor. More...
 
virtual EMDatafinish (bool doift=true)
 Finish reconstruction and return the complete model. More...
 
virtual string get_name () const
 Get the unique name of this class (especially for factory based instantiation access) More...
 
virtual string get_desc () const
 Get a clear, concise description of this class. More...
 
virtual TypeDict get_param_types () const
 
- Public Member Functions inherited from EMAN::Reconstructor
 Reconstructor ()
 
virtual ~Reconstructor ()
 
virtual void setup_seed (EMData *seed, float seed_weight)
 Initialize the reconstructor with a seed volume. More...
 
virtual void setup_seedandweights (EMData *seed, EMData *weight)
 Initialize the reconstructor with a seed volume, as above. More...
 
virtual EMDatapreprocess_slice (const EMData *const slice, const Transform &t=Transform())
 While you can just insert unprocessed slices, if you call preprocess_slice yourself, and insert the returned slice instead, repeatedly, it can save a fair bit of computation. More...
 
int insert_slice (const EMData *const slice, const Transform &euler)
 
virtual int determine_slice_agreement (EMData *slice, const Transform &euler, const float weight=1.0, bool sub=true)
 Compares a slice to the current reconstruction volume and computes a normalization factor and quality. More...
 
virtual EMDataprojection (const Transform &euler, int ret_fourier=1)
 This will create a projection from the current reconstruction. More...
 
virtual void clear ()
 set the volume and tmp_volume data to zero, for use in Monte Carlo reconstructors More...
 
void print_params () const
 Print the current parameters to std::out. More...
 
EMObjectoperator[] (const string &key)
 
- Public Member Functions inherited from EMAN::FactoryBase
 FactoryBase ()
 
virtual ~FactoryBase ()
 
Dict get_params () const
 get a copy of the parameters of this class More...
 
void set_params (const Dict &new_params)
 Set new parameters. More...
 
void set_param (const string key, const EMObject val)
 
void insert_params (const Dict &new_params)
 Insert parameters. More...
 
Dict copy_relevant_params (const FactoryBase *const that) const
 
- Public Member Functions inherited from EMAN::ReconstructorVolumeData
 ReconstructorVolumeData ()
 Only constructor All member variables are zeroed. More...
 
virtual ~ReconstructorVolumeData ()
 Destructor safely frees memory. More...
 
const EMDataget_emdata ()
 Get the main image pointer, probably redundant (not used) More...
 

Static Public Member Functions

static ReconstructorNEW ()
 

Static Public Attributes

static const string NAME = "fouriersimple2D"
 

Additional Inherited Members

- Protected Member Functions inherited from EMAN::ReconstructorVolumeData
void free_memory ()
 Free allocated memorys The inherited class may have allocated image of tmp_data In either case you can safely call this function to delete either of those pointers, even if they bdb:refine_03::threed_00are NULL. More...
 
virtual void normalize_threed (const bool sqrt_damp=false, const bool wiener=false)
 Normalize on the assumption that image is a Fourier volume and that tmp_data is a volume of weights corresponding in size to this Fourier volume. More...
 
virtual void zero_memory ()
 Sends the pixels in tmp_data and image to zero Convenience only. More...
 
- Protected Attributes inherited from EMAN::FactoryBase
Dict params
 This is the dictionary the stores the parameters of the object. More...
 
- Protected Attributes inherited from EMAN::ReconstructorVolumeData
EMDataimage
 Inheriting class allocates this, probably in setup(). More...
 
EMDatatmp_data
 Inheriting class may allocate this, probably in setup() More...
 
int nx
 
int nx2
 
int ny
 
int ny2
 
int nz
 
int nz2
 
int subnx
 
int subny
 
int subnz
 
int subx0
 
int suby0
 
int subz0
 

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

Constructor & Destructor Documentation

◆ FourierReconstructorSimple2D()

EMAN::FourierReconstructorSimple2D::FourierReconstructorSimple2D ( )
inline

Definition at line 305 of file reconstructor.h.

305{}

Referenced by NEW().

◆ ~FourierReconstructorSimple2D()

virtual EMAN::FourierReconstructorSimple2D::~FourierReconstructorSimple2D ( )
inlinevirtual

Definition at line 307 of file reconstructor.h.

307{ }

Member Function Documentation

◆ finish()

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 301 of file reconstructor.cpp.

302{
304
305 image->process_inplace("xform.fourierorigin.tocorner");
306 image->do_ift_inplace();
307 image->depad();
308 image->process_inplace("xform.phaseorigin.tocenter");
309
310 EMData *ret = image;
311 image = 0;
312 return ret;
313}
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
EMData * image
Inheriting class allocates this, probably in setup().
virtual void normalize_threed(const bool sqrt_damp=false, const bool wiener=false)
Normalize on the assumption that image is a Fourier volume and that tmp_data is a volume of weights c...

References EMAN::ReconstructorVolumeData::image, and EMAN::ReconstructorVolumeData::normalize_threed().

◆ get_desc()

virtual string EMAN::FourierReconstructorSimple2D::get_desc ( ) const
inlinevirtual

Get a clear, concise description of this class.

Returns
a clear, concise description of this class

Implements EMAN::FactoryBase.

Definition at line 317 of file reconstructor.h.

317{ return "performs 2D reconstruction"; }

◆ get_name()

virtual string EMAN::FourierReconstructorSimple2D::get_name ( ) const
inlinevirtual

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

315{ return NAME; }

References NAME.

◆ get_param_types()

virtual TypeDict EMAN::FourierReconstructorSimple2D::get_param_types ( ) const
inlinevirtual
Returns
a TypeDict defining and describing the feasible parameters of this class

Implements EMAN::FactoryBase.

Definition at line 325 of file reconstructor.h.

326 {
327 TypeDict d;
328 d.put("nx", EMObject::INT, "Necessary. The x dimension of the input images.");
329// d.put("sym", EMObject::STRING, "Symmetry - assumed to be C1 if not specified");
330 return d;
331 }

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

◆ insert_slice()

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 184 of file reconstructor.cpp.

185{
186
187 // Are these exceptions really necessary? (d.woolford)
188 if (!slice) throw NullPointerException("EMData pointer (input image) is NULL");
189
190 if ( slice->get_ndim() != 1 ) throw ImageDimensionException("Image dimension must be 1");
191
192 // I could also test to make sure the image is the right dimensions...
193 if (slice->is_complex()) throw ImageFormatException("The image is complex, expecting real");
194
195 EMData* working_slice = slice->process("xform.phaseorigin.tocorner");
196
197 // Fourier transform the slice
198 working_slice->do_fft_inplace();
199
200 float* rdata = image->get_data();
201 float* norm = tmp_data->get_data();
202 float* dat = working_slice->get_data();
203
204 float g[4];
205 int offset[4];
206 float dt[2];
207 offset[0] = 0; offset[1] = 2; offset[2] = nx; offset[3] = nx+2;
208
209 float alt = -((float)(euler.get_rotation("2d"))["alpha"])*M_PI/180.0f;
210 for (int x = 0; x < working_slice->get_xsize() / 2; x++) {
211
212 float rx = (float) x;
213
214 float xx = rx*cos(alt);
215 float yy = rx*sin(alt);
216 float cc = 1.0;
217
218 if (xx < 0) {
219 xx = -xx;
220 yy = -yy;
221 cc = -1.0;
222 }
223
224 yy += ny / 2;
225
226
227 dt[0] = dat[2*x];
228 dt[1] = cc * dat[2*x+1];
229
230 // PHIL IS INTERESTED FROM HERE DOWN
231 int x0 = (int) floor(xx);
232 int y0 = (int) floor(yy);
233
234 int i = 2*x0 + y0*nx;
235
236 float dx = xx - x0;
237 float dy = yy - y0;
238
239 g[0] = Util::agauss(1, dx, dy, 0, EMConsts::I2G);
240 g[1] = Util::agauss(1, 1 - dx, dy, 0, EMConsts::I2G);
241 g[2] = Util::agauss(1, dx, 1 - dy, 0, EMConsts::I2G);
242 g[3] = Util::agauss(1, 1 - dx, 1 - dy, 0, EMConsts::I2G);
243
244 // At the extreme we can only do some much...
245 if ( x0 == nx-2 ) {
246 int k = i + offset[0];
247 rdata[k] += g[0] * dt[0];
248 rdata[k + 1] += g[0] * dt[1];
249 norm[k/2] += g[0];
250
251 k = i + offset[2];
252 rdata[k] += g[2] * dt[0];
253 rdata[k + 1] += g[2] * dt[1];
254 norm[k/2] += g[2];
255 continue;
256
257 }
258 // capture and accommodate for periodic boundary conditions in the x direction
259 if ( x0 > nx-2 ) {
260 int dif = x0 - (nx-2);
261 x0 -= dif;
262 }
263 // At the extreme we can only do some much...
264 if ( y0 == ny -1 ) {
265 int k = i + offset[0];
266 rdata[k] += g[0] * dt[0];
267 rdata[k + 1] += g[0] * dt[1];
268 norm[k/2] += g[0];
269
270 k = i + offset[1];
271 rdata[k] += g[1] * dt[0];
272 rdata[k + 1] += g[1] * dt[1];
273 norm[k/2] += g[1];
274 continue;
275 }
276 // capture and accommodate for periodic boundary conditions in the y direction
277 if ( y0 > ny-1) {
278 int dif = y0 - (ny-1);
279 y0 -= dif;
280 }
281
282 if (x0 >= nx - 2 || y0 >= ny - 1) continue;
283
284
285
286
287 for (int j = 0; j < 4; j++)
288 {
289 int k = i + offset[j];
290 rdata[k] += g[j] * dt[0];
291 rdata[k + 1] += g[j] * dt[1];
292 norm[k/2] += g[j];
293
294 }
295 }
296
297 return 0;
298
299}
#define rdata(i)
Definition: analyzer.cpp:592
static const float I2G
Definition: emobject.h:72
EMData * tmp_data
Inheriting class may allocate this, probably in setup()
Dict get_rotation(const string &euler_type="eman") const
Get a rotation in any Euler format.
Definition: transform.cpp:829
static float agauss(float a, float dx, float dy, float dz, float d)
Calculate Gaussian value.
Definition: util.h:912
#define ImageFormatException(desc)
Definition: exception.h:147
#define ImageDimensionException(desc)
Definition: exception.h:166
#define NullPointerException(desc)
Definition: exception.h:241
#define x(i)
Definition: projector.cpp:1517

References EMAN::Util::agauss(), EMAN::Transform::get_rotation(), EMAN::EMConsts::I2G, EMAN::ReconstructorVolumeData::image, ImageDimensionException, ImageFormatException, NullPointerException, EMAN::ReconstructorVolumeData::nx, EMAN::ReconstructorVolumeData::ny, rdata, EMAN::ReconstructorVolumeData::tmp_data, and x.

◆ NEW()

static Reconstructor * EMAN::FourierReconstructorSimple2D::NEW ( )
inlinestatic

Definition at line 319 of file reconstructor.h.

320 {
321 return new FourierReconstructorSimple2D();
322 }

References FourierReconstructorSimple2D().

◆ setup()

void FourierReconstructorSimple2D::setup ( )
virtual

Initialize the reconstructor.

Implements EMAN::Reconstructor.

Definition at line 163 of file reconstructor.cpp.

164{
165 nx = params.set_default("nx",0);
166
167 if ( nx < 0 ) throw InvalidValueException(nx, "nx must be positive");
168
169 bool is_fftodd = (nx % 2 == 1);
170
171 ny = nx;
172 nx += 2-is_fftodd;
173
174 image = new EMData();
175 image->set_size(nx, ny);
176 image->set_complex(true);
177 image->set_fftodd(is_fftodd);
178 image->set_ri(true);
179
180 tmp_data = new EMData();
181 tmp_data->set_size(nx/2, nx);
182}
type set_default(const string &key, type val)
Default setting behavior This can be achieved using a template - d.woolford Jan 2008 (before there wa...
Definition: emobject.h:569
Dict params
This is the dictionary the stores the parameters of the object.
Definition: emobject.h:953
bool is_fftodd() const
Does this image correspond to a (real-space) odd nx?
#define InvalidValueException(val, desc)
Definition: exception.h:285

References EMAN::ReconstructorVolumeData::image, InvalidValueException, is_fftodd(), EMAN::ReconstructorVolumeData::nx, EMAN::ReconstructorVolumeData::ny, EMAN::FactoryBase::params, EMAN::Dict::set_default(), and EMAN::ReconstructorVolumeData::tmp_data.

Member Data Documentation

◆ NAME

const string FourierReconstructorSimple2D::NAME = "fouriersimple2D"
static

Definition at line 333 of file reconstructor.h.

Referenced by get_name().


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