EMAN2
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions
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 objectsd 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]

List of all members.

Public Member Functions

 ReconstructorVolumeData ()
 Only constructor All member variables are zeroed.
virtual ~ReconstructorVolumeData ()
 Destructor safely frees memory.
const EMDataget_emdata ()
 Get the main image pointer, probably redundant (not used)

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.
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.
virtual void zero_memory ()
 Sends the pixels in tmp_data and image to zero Convenience only.

Protected Attributes

EMDataimage
 Inheriting class allocates this, probably in setup().
EMDatatmp_data
 Inheriting class may allocate this, probably in setup()
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.
ReconstructorVolumeDataoperator= (const ReconstructorVolumeData &)
 Disallow assignment.

Detailed Description

This is a Mixin class A class object encapsulating the volume data required by Reconstructors It basically stores two (pointers) to EMData objectsd 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 207 of file reconstructor.h.


Constructor & Destructor Documentation

EMAN::ReconstructorVolumeData::ReconstructorVolumeData ( ) [inline]

Only constructor All member variables are zeroed.

Definition at line 213 of file reconstructor.h.

: image(0), tmp_data(0), nx(0), ny(0), nz(0), subnx(0), subny(0), subnz(0), subx0(0), suby0(0), subz0(0) {}
virtual EMAN::ReconstructorVolumeData::~ReconstructorVolumeData ( ) [inline, virtual]

Destructor safely frees memory.

Definition at line 217 of file reconstructor.h.

References free_memory().

{ free_memory(); }
EMAN::ReconstructorVolumeData::ReconstructorVolumeData ( const ReconstructorVolumeData that) [private]

Disallow copy construction.


Member Function Documentation

void EMAN::ReconstructorVolumeData::free_memory ( ) [inline, protected]

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.

Reimplemented in EMAN::FourierReconstructor, and EMAN::FourierPlaneReconstructor.

Definition at line 248 of file reconstructor.h.

References image, and tmp_data.

Referenced by ~ReconstructorVolumeData().

                        {
                                if (image != 0)  {delete image; image = 0;}
                                if ( tmp_data != 0 ) { delete tmp_data; tmp_data = 0; }
                        }
const EMData* EMAN::ReconstructorVolumeData::get_emdata ( ) [inline]

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

Definition at line 221 of file reconstructor.h.

References image.

{ return image; }
void ReconstructorVolumeData::normalize_threed ( const bool  sqrt_damp = false,
const bool  wiener = false 
) [protected, virtual]

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

References EMAN::EMData::get_data(), image, norm(), NullPointerException, nx, ny, nz, rdata, sqrt(), subnx, subny, subnz, subx0, tmp_data, and y.

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

{
        float* norm = tmp_data->get_data();
        float* rdata = image->get_data();

//      printf("%d %d %d %d %d %d\n",subnx,subny,subnz,image->get_xsize(),image->get_ysize(),image->get_zsize());

        // FIXME should throw a sensible error
        if ( 0 == norm ) throw NullPointerException("The normalization volume was null!");
        if ( 0 == rdata ) throw NullPointerException("The complex reconstruction volume was null!");

        // The math is a bit tricky to explain. Wiener filter is basically SNR/(1+SNR)
        // In this case, data have already been effectively multiplied by SNR (one image at a time),
        // so without Wiener filter, we just divide by total SNR. With Wiener filter, we just add
        // 1.0 to total SNR, and we're done             --steve
        float wfilt=0.0;
        if (wiener) wfilt=1.0;          
        
        for (size_t i = 0; i < (size_t)subnx * subny * subnz; i += 2) {
                float d = norm[i/2];
                if (sqrt_damp) d*=sqrt(d);
                if (d == 0) {
                        rdata[i] = 0;
                        rdata[i + 1] = 0;
                }
                else {
//                      rdata[i]=1.0/d;
//                      rdata[i+1]=0.0;         // for debugging only
                        rdata[i] /= d+wfilt;
                        rdata[i + 1] /= d+wfilt;
                }
        }

        // enforce complex conj, only works on subvolumes if the complete conjugate plane is in the volume
        if (subx0==0 && subnx>1 && subny==ny && subnz==nz) {
                for (int z=0; z<=nz/2; z++) {
                        for (int y=1; y<=ny; y++) {
                                if (y==0 && z==0) continue;
                                // x=0
                                size_t i=(size_t)(y%ny)*subnx+(size_t)(z%nz)*subnx*subny;
                                size_t i2=(size_t)(ny-y)*subnx+(size_t)((nz-z)%nz)*subnx*subny;
                                float ar=(rdata[i]+rdata[i2])/2.0f;
                                float ai=(rdata[i+1]-rdata[i2+1])/2.0f;
                                rdata[i]=ar;
                                rdata[i2]=ar;
                                rdata[i+1]=ai;
                                rdata[i2+1]=-ai;
                        }
                }
        }

        if (subx0+subnx==nx && subnx>1 && subny==ny && subnz==nz) {
                for (int z=0; z<=nz/2; z++) {
                        for (int y=1; y<=ny; y++) {
                                if (y==0 && z==0) continue;
                                // x=0
                                size_t i=(size_t)(y%ny)*subnx+(size_t)(z%nz)*subnx*subny+subnx-2;
                                size_t i2=(size_t)(ny-y)*subnx+(size_t)((nz-z)%nz)*subnx*subny+subnx-2;
                                float ar=(rdata[i]+rdata[i2])/2.0f;
                                float ai=(rdata[i+1]-rdata[i2+1])/2.0f;
                                rdata[i]=ar;
                                rdata[i2]=ar;
                                rdata[i+1]=ai;
                                rdata[i2+1]=-ai;
                        }
                }
        }
}
ReconstructorVolumeData& EMAN::ReconstructorVolumeData::operator= ( const ReconstructorVolumeData ) [private]

Disallow assignment.

virtual void EMAN::ReconstructorVolumeData::zero_memory ( ) [inline, protected, virtual]

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

Definition at line 264 of file reconstructor.h.

References image, tmp_data, and EMAN::EMData::to_zero().

                        {
                                if (tmp_data != 0 ) tmp_data->to_zero();
                                if (image != 0 ) image->to_zero();
                        }

Member Data Documentation


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