EMAN2
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
EMAN::ReconstructorVolumeData Class Reference

This is a Mixin class A class object encapsulating the volume data required by Reconstructors It basically stores two (pointers) to EMData objects and stores the dimensions of the image volume. More...

#include <reconstructor.h>

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

Public Member Functions

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

Protected Member Functions

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

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
 

Private Member Functions

 ReconstructorVolumeData (const ReconstructorVolumeData &that)
 Disallow copy construction. More...
 
ReconstructorVolumeDataoperator= (const ReconstructorVolumeData &)
 Disallow assignment. More...
 

Detailed Description

This is a Mixin class A class object encapsulating the volume data required by Reconstructors It basically stores two (pointers) to EMData objects and stores the dimensions of the image volume.

One EMData object basically stores the real pixel data, the other is used for storing normalization values. This class was originally added simply to encapsulate the the things common to FourierReconstructor, WienerFourierReconstructor and BackProjectionReconstructor. It was never expected to instantiated on its own, and is intended to be a parent of the Reconstructor class. d.woolford May 2007

Definition at line 219 of file reconstructor.h.

Constructor & Destructor Documentation

◆ ReconstructorVolumeData() [1/2]

EMAN::ReconstructorVolumeData::ReconstructorVolumeData ( )
inline

Only constructor All member variables are zeroed.

Definition at line 225 of file reconstructor.h.

◆ ~ReconstructorVolumeData()

virtual EMAN::ReconstructorVolumeData::~ReconstructorVolumeData ( )
inlinevirtual

Destructor safely frees memory.

Definition at line 229 of file reconstructor.h.

229{ free_memory(); }
void free_memory()
Free allocated memorys The inherited class may have allocated image of tmp_data In either case you ca...

References free_memory().

◆ ReconstructorVolumeData() [2/2]

EMAN::ReconstructorVolumeData::ReconstructorVolumeData ( const ReconstructorVolumeData that)
private

Disallow copy construction.

Member Function Documentation

◆ free_memory()

void EMAN::ReconstructorVolumeData::free_memory ( )
inlineprotected

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.

Definition at line 267 of file reconstructor.h.

268 {
269 if (image != 0) {delete image; image = 0;}
270 if ( tmp_data != 0 ) { delete tmp_data; tmp_data = 0; }
271 }

References image, and tmp_data.

Referenced by ~ReconstructorVolumeData().

◆ get_emdata()

const EMData * EMAN::ReconstructorVolumeData::get_emdata ( )
inline

Get the main image pointer, probably redundant (not used)

Definition at line 233 of file reconstructor.h.

233{ return image; }

References image.

◆ normalize_threed()

void ReconstructorVolumeData::normalize_threed ( const bool  sqrt_damp = false,
const bool  wiener = false 
)
protectedvirtual

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.

This means tmp_data is assumed to have have as many x pixels as image.

Definition at line 315 of file reconstructor.cpp.

317{
318 float* norm = tmp_data->get_data();
319 float* rdata = image->get_data();
320
321 size_t nnx=tmp_data->get_xsize();
322 size_t nnxy=tmp_data->get_ysize()*nnx;
323
324// printf("%d %d %d %d %d %d\n",subnx,subny,subnz,image->get_xsize(),image->get_ysize(),image->get_zsize());
325
326 // FIXME should throw a sensible error
327 if ( 0 == norm ) throw NullPointerException("The normalization volume was null!");
328 if ( 0 == rdata ) throw NullPointerException("The complex reconstruction volume was null!");
329
330#ifdef DEBUG_POINT
331 std::complex<float> pv = image->get_complex_at(113,0,23);
332 float pnv = tmp_data->get_value_at(113,0,23);
333 printf("norm: %1.4g\t%1.4g\t%1.4g\n",pv.real()/pnv,pv.imag()/pnv,pnv);
334#endif
335
336 // add_complex_at handles complex conjugate addition, but the normalization image doesn't
337 // take this into account, so we need to sum the appropriate values
338 // only works for whole volumes!
339 if (subx0==0 && subnx==nx && suby0==0 && subny==ny && subz0==0 && subnz==nz) {
340// printf("cc gain correction\n");
341 for (int z=-nz/2; z<nz/2; z++) {
342 for (int y=0; y<=ny/2; y++) {
343 if (z<=0 && (y==0||y==ny/2)) continue;
344 // x=0 plane
345 size_t idx1=(y==0?0:ny-y)*nnx+(z<=0?-z:nz-z)*nnxy;
346 size_t idx2=y*nnx+(z<0?nz+z:z)*nnxy;
347 if (idx1==idx2) continue;
348 float snorm=norm[idx1]+norm[idx2];
349 norm[idx1]=norm[idx2]=snorm;
350
351 // This is the x=nx-1 plane
352 idx1+=nnx-1;
353 idx2+=nnx-1;
354 snorm=norm[idx1]+norm[idx2];
355 norm[idx1]=norm[idx2]=snorm;
356 }
357 }
358 // special cases not handled elsewhere
359 norm[0 + 0*nnx+nz/2*nnxy]*=2;
360 norm[0 +ny/2*nnx+ 0*nnxy]*=2;
361 norm[0 +ny/2*nnx+nz/2*nnxy]*=2;
362 norm[nx/2-1+ 0*nnx+nz/2*nnxy]*=2;
363 norm[nx/2-1+ny/2*nnx+ 0*nnxy]*=2;
364 }
365// else printf("Subregion, no CC plane correction\n");
366
367 // The math is a bit tricky to explain. Wiener filter is basically SNR/(1+SNR)
368 // In this case, data have already been effectively multiplied by SNR (one image at a time),
369 // so without Wiener filter, we just divide by total SNR. With Wiener filter, we just add
370 // 1.0 to total SNR, and we're done --steve
371 float wfilt=0.0;
372 if (wiener) wfilt=1.0;
373
374 // actual normalization
375 for (size_t i = 0; i < (size_t)subnx * subny * subnz; i += 2) {
376 float d = norm[i/2];
377 if (sqrtnorm) d=sqrt(d);
378 if (d == 0) {
379 rdata[i] = 0;
380 rdata[i + 1] = 0;
381 }
382 else {
383// rdata[i]=1.0/d;
384// rdata[i+1]=0.0; // for debugging only
385 rdata[i] /= d+wfilt;
386 rdata[i + 1] /= d+wfilt;
387 }
388 }
389
390
391 // This task should now be handled by use of add_complex_at, which adds both values when appropriate
392
393 // enforce complex conj, only works on subvolumes if the complete conjugate plane is in the volume
394// if (subx0==0 && subnx>1 && subny==ny && subnz==nz) {
395// for (int z=0; z<=nz/2; z++) {
396// for (int y=1; y<=ny; y++) {
397// if (y==0 && z==0) continue;
398// // x=0
399// size_t i=(size_t)(y%ny)*subnx+(size_t)(z%nz)*subnx*subny;
400// size_t i2=(size_t)(ny-y)*subnx+(size_t)((nz-z)%nz)*subnx*subny;
401// float ar=(rdata[i]+rdata[i2])/2.0f;
402// float ai=(rdata[i+1]-rdata[i2+1])/2.0f;
403// rdata[i]=ar;
404// rdata[i2]=ar;
405// rdata[i+1]=ai;
406// rdata[i2+1]=-ai;
407// }
408// }
409// }
410
411// if (subx0+subnx==nx && subnx>1 && subny==ny && subnz==nz) {
412// for (int z=0; z<=nz/2; z++) {
413// for (int y=1; y<=ny; y++) {
414// if (y==0 && z==0) continue;
415// // x=0
416// size_t i=(size_t)(y%ny)*subnx+(size_t)(z%nz)*subnx*subny+subnx-2;
417// size_t i2=(size_t)(ny-y)*subnx+(size_t)((nz-z)%nz)*subnx*subny+subnx-2;
418// float ar=(rdata[i]+rdata[i2])/2.0f;
419// float ai=(rdata[i+1]-rdata[i2+1])/2.0f;
420// rdata[i]=ar;
421// rdata[i2]=ar;
422// rdata[i+1]=ai;
423// rdata[i2+1]=-ai;
424// }
425// }
426// }
427}
#define rdata(i)
Definition: analyzer.cpp:592
EMData * sqrt() const
return square root of current image
#define NullPointerException(desc)
Definition: exception.h:241
#define y(i, j)
Definition: projector.cpp:1516

References image, NullPointerException, nx, ny, nz, rdata, sqrt(), subnx, subny, subnz, subx0, suby0, subz0, tmp_data, and y.

Referenced by EMAN::FourierReconstructorSimple2D::finish(), EMAN::FourierReconstructor::finish(), EMAN::WienerFourierReconstructor::finish(), and EMAN::FourierIterReconstructor::finish().

◆ operator=()

ReconstructorVolumeData & EMAN::ReconstructorVolumeData::operator= ( const ReconstructorVolumeData )
private

Disallow assignment.

◆ zero_memory()

virtual void EMAN::ReconstructorVolumeData::zero_memory ( )
inlineprotectedvirtual

Sends the pixels in tmp_data and image to zero Convenience only.

Definition at line 283 of file reconstructor.h.

284 {
285 if (tmp_data != 0 ) tmp_data->to_zero();
286 if (image != 0 ) image->to_zero();
287 }

References image, and tmp_data.

Member Data Documentation

◆ image

EMData* EMAN::ReconstructorVolumeData::image
protected

◆ nx

int EMAN::ReconstructorVolumeData::nx
protected

◆ nx2

int EMAN::ReconstructorVolumeData::nx2
protected

◆ ny

int EMAN::ReconstructorVolumeData::ny
protected

◆ ny2

int EMAN::ReconstructorVolumeData::ny2
protected

◆ nz

int EMAN::ReconstructorVolumeData::nz
protected

◆ nz2

int EMAN::ReconstructorVolumeData::nz2
protected

◆ subnx

int EMAN::ReconstructorVolumeData::subnx
protected

◆ subny

int EMAN::ReconstructorVolumeData::subny
protected

◆ subnz

int EMAN::ReconstructorVolumeData::subnz
protected

◆ subx0

int EMAN::ReconstructorVolumeData::subx0
protected

◆ suby0

int EMAN::ReconstructorVolumeData::suby0
protected

◆ subz0

int EMAN::ReconstructorVolumeData::subz0
protected

◆ tmp_data

EMData* EMAN::ReconstructorVolumeData::tmp_data
protected

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