Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

reconstructor.cpp File Reference

#include "reconstructor.h"
#include "plugins/reconstructor_template.h"
#include "ctf.h"
#include "emassert.h"
#include "symmetry.h"
#include <cstring>
#include <fstream>
#include <iomanip>
#include <boost/bind.hpp>
#include <boost/format.hpp>
#include <gsl/gsl_statistics_double.h>
#include <gsl/gsl_fit.h>
#include <iostream>
#include <algorithm>
#include <sstream>

Include dependency graph for reconstructor.cpp:

Include dependency graph

Go to the source code of this file.

Defines

#define tw(i, j, k)   tw[ i-1 + (j-1+(k-1)*iy)*ix ]
#define tw(i, j, k)   tw[ i-1 + (j-1+(k-1)*iy)*ix ]
#define tw(i, j, k)   tw[ i-1 + (j-1+(k-1)*iy)*ix ]
#define tw(i, j, k)   tw[ i-1 + (j-1+(k-1)*iy)*ix ]
#define tw(i, j, k)   tw[ i-1 + (j-1+(k-1)*iy)*ix ]
#define tw(i, j, k)   tw[ i-1 + (j-1+(k-1)*iy)*ix ]

Enumerations

enum  weighting_method { NONE, ESTIMATE, VORONOI }

Functions

template<typename T>
void checked_delete (T *&x)
float max2d (int kc, const vector< float > &pow_a)
float max3d (int kc, const vector< float > &pow_a)
void printImage (const EMData *line)
void circumf (EMData *win, int npad)
void circumf_rect (EMData *win, int npad)


Define Documentation

#define tw i,
j,
 )     tw[ i-1 + (j-1+(k-1)*iy)*ix ]
 

Definition at line 3880 of file reconstructor.cpp.

#define tw i,
j,
 )     tw[ i-1 + (j-1+(k-1)*iy)*ix ]
 

Definition at line 3880 of file reconstructor.cpp.

#define tw i,
j,
 )     tw[ i-1 + (j-1+(k-1)*iy)*ix ]
 

Definition at line 3880 of file reconstructor.cpp.

#define tw i,
j,
 )     tw[ i-1 + (j-1+(k-1)*iy)*ix ]
 

Definition at line 3880 of file reconstructor.cpp.

#define tw i,
j,
 )     tw[ i-1 + (j-1+(k-1)*iy)*ix ]
 

Definition at line 3880 of file reconstructor.cpp.

#define tw i,
j,
 )     tw[ i-1 + (j-1+(k-1)*iy)*ix ]
 

Definition at line 3880 of file reconstructor.cpp.

Referenced by circumf(), and circumf_rect().


Enumeration Type Documentation

enum weighting_method
 

Enumeration values:
NONE 
ESTIMATE 
VORONOI 

Definition at line 1897 of file reconstructor.cpp.

01897 { NONE, ESTIMATE, VORONOI };


Function Documentation

template<typename T>
void checked_delete T *&  x  ) 
 

Definition at line 65 of file reconstructor.cpp.

References x.

Referenced by EMAN::file_store::add_image(), EMAN::newfile_store::add_image(), EMAN::nnSSNR_ctfReconstructor::insert_slice(), EMAN::nn4_ctf_rectReconstructor::insert_slice(), EMAN::nn4_ctfReconstructor::insert_slice(), EMAN::nnSSNR_Reconstructor::insert_slice(), EMAN::nn4_rectReconstructor::insert_slice(), EMAN::nn4Reconstructor::insert_slice(), EMAN::padfft_slice(), EMAN::nn4_ctf_rectReconstructor::~nn4_ctf_rectReconstructor(), EMAN::nn4_ctfReconstructor::~nn4_ctfReconstructor(), EMAN::nn4_rectReconstructor::~nn4_rectReconstructor(), EMAN::nn4Reconstructor::~nn4Reconstructor(), EMAN::nnSSNR_ctfReconstructor::~nnSSNR_ctfReconstructor(), and EMAN::nnSSNR_Reconstructor::~nnSSNR_Reconstructor().

00066 {
00067     typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
00068     (void) sizeof(type_must_be_complete);
00069     delete x;
00070     x = NULL;
00071 }

void circumf EMData win,
int  npad
 

Definition at line 2124 of file reconstructor.cpp.

References abs, EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), and tw.

Referenced by EMAN::nn4_ctfReconstructor::finish(), and EMAN::nn4Reconstructor::finish().

02125 {
02126         float *tw = win->get_data();
02127         //  correct for the fall-off
02128         //  mask and subtract circumference average
02129         int ix = win->get_xsize();
02130         int iy = win->get_ysize();
02131         int iz = win->get_zsize();
02132         int L2 = (ix/2)*(ix/2);
02133         int L2P = (ix/2-1)*(ix/2-1);
02134 
02135         int IP = ix/2+1;
02136         int JP = iy/2+1;
02137         int KP = iz/2+1;
02138 
02139         //  sinc functions tabulated for fall-off
02140         float* sincx = new float[IP+1];
02141         float* sincy = new float[JP+1];
02142         float* sincz = new float[KP+1];
02143 
02144         sincx[0] = 1.0f;
02145         sincy[0] = 1.0f;
02146         sincz[0] = 1.0f;
02147 
02148         float cdf = M_PI/float(npad*2*ix);
02149         for (int i = 1; i <= IP; ++i)  sincx[i] = sin(i*cdf)/(i*cdf);
02150         cdf = M_PI/float(npad*2*iy);
02151         for (int i = 1; i <= JP; ++i)  sincy[i] = sin(i*cdf)/(i*cdf);
02152         cdf = M_PI/float(npad*2*iz);
02153         for (int i = 1; i <= KP; ++i)  sincz[i] = sin(i*cdf)/(i*cdf);
02154         for (int k = 1; k <= iz; ++k) {
02155                 int kkp = abs(k-KP);
02156                 for (int j = 1; j <= iy; ++j) {
02157                         cdf = sincy[abs(j- JP)]*sincz[kkp];
02158                         for (int i = 1; i <= ix; ++i)  tw(i,j,k) /= (sincx[abs(i-IP)]*cdf);
02159                 }
02160         }
02161 
02162         delete[] sincx;
02163         delete[] sincy;
02164         delete[] sincz;
02165 
02166         float  TNR = 0.0f;
02167         size_t m = 0;
02168         for (int k = 1; k <= iz; ++k) {
02169                 for (int j = 1; j <= iy; ++j) {
02170                         for (int i = 1; i <= ix; ++i) {
02171                                 size_t LR = (k-KP)*(k-KP)+(j-JP)*(j-JP)+(i-IP)*(i-IP);
02172                                 if (LR >= (size_t)L2P && LR<=(size_t)L2) {
02173                                         TNR += tw(i,j,k);
02174                                         ++m;
02175                                 }
02176                         }
02177                 }
02178         }
02179 
02180         TNR /=float(m);
02181         
02182         
02183         for (int k = 1; k <= iz; ++k) {
02184                 for (int j = 1; j <= iy; ++j) {
02185                         for (int i = 1; i <= ix; ++i) {
02186                                 size_t LR = (k-KP)*(k-KP)+(j-JP)*(j-JP)+(i-IP)*(i-IP);
02187                                 if (LR<=(size_t)L2) tw(i,j,k) -= TNR;
02188                                 else                tw(i,j,k) = 0.0f;
02189 
02190                         }
02191                 }
02192         }
02193 
02194 }

void circumf_rect EMData win,
int  npad
 

Definition at line 2569 of file reconstructor.cpp.

References abs, EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), and tw.

Referenced by EMAN::nn4_ctf_rectReconstructor::finish(), and EMAN::nn4_rectReconstructor::finish().

02570 {
02571         float *tw = win->get_data();
02572         //  correct for the fall-off
02573         //  mask and subtract circumference average
02574         int ix = win->get_xsize();
02575         int iy = win->get_ysize();
02576         int iz = win->get_zsize();
02577 
02578         int IP = ix/2+1;
02579         int JP = iy/2+1;
02580         int KP = iz/2+1;
02581         
02582         //  sinc functions tabulated for fall-off
02583         float* sincx = new float[IP+1];
02584         float* sincy = new float[JP+1];
02585         float* sincz = new float[KP+1];
02586 
02587         sincx[0] = 1.0f;
02588         sincy[0] = 1.0f;
02589         sincz[0] = 1.0f;
02590 
02591         float cdf = M_PI/float(npad*2*ix);
02592         for (int i = 1; i <= IP; ++i)  sincx[i] = sin(i*cdf)/(i*cdf);
02593         cdf = M_PI/float(npad*2*iy);
02594         for (int i = 1; i <= JP; ++i)  sincy[i] = sin(i*cdf)/(i*cdf);
02595         cdf = M_PI/float(npad*2*iz);
02596         for (int i = 1; i <= KP; ++i)  sincz[i] = sin(i*cdf)/(i*cdf);
02597         for (int k = 1; k <= iz; ++k) {
02598                 int kkp = abs(k-KP);
02599                 for (int j = 1; j <= iy; ++j) {
02600                         cdf = sincy[abs(j- JP)]*sincz[kkp];
02601                         for (int i = 1; i <= ix; ++i)  tw(i,j,k) /= (sincx[abs(i-IP)]*cdf);
02602                 }
02603         }
02604 
02605         delete[] sincx;
02606         delete[] sincy;
02607         delete[] sincz;
02608         
02609         
02610         
02611         float dxx = 1.0/float(0.25*ix*ix);
02612         float dyy = 1.0/float(0.25*iy*iy);
02613         
02614         
02615         
02616         float LR2=(float(ix)/2-1)*(float(ix)/2-1)*dxx;
02617 
02618         float  TNR = 0.0f;
02619         size_t m = 0;
02620         for (int k = 1; k <= iz; ++k) {
02621                 for (int j = 1; j <= iy; ++j) {
02622                         for (int i = 1; i <= ix; ++i) {
02623                                 float LR = (j-JP)*(j-JP)*dyy+(i-IP)*(i-IP)*dxx;
02624                                 if (LR<=1.0f && LR >= LR2) {
02625                                         TNR += tw(i,j,k);
02626                                         ++m;
02627                                 }
02628                         }
02629                 }
02630         }
02631 
02632         TNR /=float(m);
02633         
02634 
02635         for (int k = 1; k <= iz; ++k) {
02636                 for (int j = 1; j <= iy; ++j) {
02637                         for (int i = 1; i <= ix; ++i) {
02638                                 float LR = (j-JP)*(j-JP)*dyy+(i-IP)*(i-IP)*dxx;
02639                                 if (LR<=1.0f)  tw(i,j,k)=tw(i,j,k)-TNR;
02640                                 else            tw(i,j,k) = 0.0f;       
02641                         }
02642                 }
02643         }
02644 
02645 }

float max2d int  kc,
const vector< float > &  pow_a
 

Definition at line 1899 of file reconstructor.cpp.

References abs, and max.

Referenced by EMAN::nn4_rectReconstructor::finish(), and EMAN::nn4Reconstructor::finish().

01900 {
01901         float max = 0.0;
01902         for( int i=-kc; i <= kc; ++i ) {
01903                 for( int j=-kc; j <= kc; ++j ) {
01904                         if( i==0 && j==0 ) continue;
01905                         {
01906                                 int c = 2*kc+1 - std::abs(i) - std::abs(j);
01907                                 max = max + pow_a[c];
01908                         }
01909                 }
01910         }
01911         return max;
01912 }

float max3d int  kc,
const vector< float > &  pow_a
 

Definition at line 1914 of file reconstructor.cpp.

References abs, and max.

Referenced by EMAN::nnSSNR_ctfReconstructor::finish(), EMAN::nn4_ctf_rectReconstructor::finish(), EMAN::nn4_ctfReconstructor::finish(), EMAN::nnSSNR_Reconstructor::finish(), EMAN::nn4_rectReconstructor::finish(), and EMAN::nn4Reconstructor::finish().

01915 {
01916         float max = 0.0;
01917         for( int i=-kc; i <= kc; ++i ) {
01918                 for( int j=-kc; j <= kc; ++j ) {
01919                         for( int k=-kc; k <= kc; ++k ) {
01920                                 if( i==0 && j==0 && k==0 ) continue;
01921                                 // if( i!=0 )
01922                                 {
01923                                         int c = 3*kc+1 - std::abs(i) - std::abs(j) - std::abs(k);
01924                                         max = max + pow_a[c];
01925                                         // max = max + c * c;
01926                                         // max = max + c;
01927                                 }
01928                         }
01929                 }
01930         }
01931         return max;
01932 }

void printImage const EMData line  ) 
 

Definition at line 2032 of file reconstructor.cpp.

References Assert, EMAN::EMData::get_value_at(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), nx, and ny.

02033 {
02034         Assert( line->get_zsize()==1 );
02035 
02036 
02037         int nx = line->get_xsize();
02038         int ny = line->get_ysize();
02039         for( int j=0; j < ny; ++j ) {
02040                 for( int i=0; i < nx; ++i )  printf( "%10.3f ", line->get_value_at(i,j) );
02041                 printf( "\n" );
02042         }
02043 }


Generated on Thu Dec 9 13:46:44 2010 for EMAN2 by  doxygen 1.3.9.1