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:

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)
EMDataEMAN::padfft_slice (const EMData *const slice, const Transform &t, int npad)
 Direct Fourier inversion Reconstructor.
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)
void EMAN::dump_reconstructors ()
map< string, vector< string > > EMAN::dump_reconstructors_list ()


Define Documentation

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

Definition at line 3906 of file reconstructor.cpp.

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

Definition at line 3906 of file reconstructor.cpp.

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

Definition at line 3906 of file reconstructor.cpp.

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

Definition at line 3906 of file reconstructor.cpp.

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

Definition at line 3906 of file reconstructor.cpp.

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

Definition at line 3906 of file reconstructor.cpp.

Referenced by circumf(), and circumf_rect().


Enumeration Type Documentation

enum weighting_method

Enumerator:
NONE 
ESTIMATE 
VORONOI 

Definition at line 2020 of file reconstructor.cpp.

02020 { NONE, ESTIMATE, VORONOI };


Function Documentation

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

Definition at line 69 of file reconstructor.cpp.

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(), and EMAN::padfft_slice().

00070 {
00071     typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
00072     (void) sizeof(type_must_be_complete);
00073     delete x;
00074     x = NULL;
00075 }

void circumf ( EMData win,
int  npad 
)

Definition at line 2237 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().

02238 {
02239         float *tw = win->get_data();
02240         //  correct for the fall-off
02241         //  mask and subtract circumference average
02242         int ix = win->get_xsize();
02243         int iy = win->get_ysize();
02244         int iz = win->get_zsize();
02245         int L2 = (ix/2)*(ix/2);
02246         int L2P = (ix/2-1)*(ix/2-1);
02247 
02248         int IP = ix/2+1;
02249         int JP = iy/2+1;
02250         int KP = iz/2+1;
02251 
02252         //  sinc functions tabulated for fall-off
02253         float* sincx = new float[IP+1];
02254         float* sincy = new float[JP+1];
02255         float* sincz = new float[KP+1];
02256 
02257         sincx[0] = 1.0f;
02258         sincy[0] = 1.0f;
02259         sincz[0] = 1.0f;
02260 
02261         float cdf = M_PI/float(npad*2*ix);
02262         for (int i = 1; i <= IP; ++i)  sincx[i] = sin(i*cdf)/(i*cdf);
02263         cdf = M_PI/float(npad*2*iy);
02264         for (int i = 1; i <= JP; ++i)  sincy[i] = sin(i*cdf)/(i*cdf);
02265         cdf = M_PI/float(npad*2*iz);
02266         for (int i = 1; i <= KP; ++i)  sincz[i] = sin(i*cdf)/(i*cdf);
02267         for (int k = 1; k <= iz; ++k) {
02268                 int kkp = abs(k-KP);
02269                 for (int j = 1; j <= iy; ++j) {
02270                         cdf = sincy[abs(j- JP)]*sincz[kkp];
02271                         for (int i = 1; i <= ix; ++i)  tw(i,j,k) /= (sincx[abs(i-IP)]*cdf);
02272                 }
02273         }
02274 
02275         delete[] sincx;
02276         delete[] sincy;
02277         delete[] sincz;
02278 
02279         float  TNR = 0.0f;
02280         size_t m = 0;
02281         for (int k = 1; k <= iz; ++k) {
02282                 for (int j = 1; j <= iy; ++j) {
02283                         for (int i = 1; i <= ix; ++i) {
02284                                 size_t LR = (k-KP)*(k-KP)+(j-JP)*(j-JP)+(i-IP)*(i-IP);
02285                                 if (LR >= (size_t)L2P && LR<=(size_t)L2) {
02286                                         TNR += tw(i,j,k);
02287                                         ++m;
02288                                 }
02289                         }
02290                 }
02291         }
02292 
02293         TNR /=float(m);
02294         
02295         
02296         for (int k = 1; k <= iz; ++k) {
02297                 for (int j = 1; j <= iy; ++j) {
02298                         for (int i = 1; i <= ix; ++i) {
02299                                 size_t LR = (k-KP)*(k-KP)+(j-JP)*(j-JP)+(i-IP)*(i-IP);
02300                                 if (LR<=(size_t)L2) tw(i,j,k) -= TNR;
02301                                 else                tw(i,j,k) = 0.0f;
02302 
02303                         }
02304                 }
02305         }
02306 
02307 }

void circumf_rect ( EMData win,
int  npad 
)

Definition at line 2666 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().

02667 {
02668         float *tw = win->get_data();
02669         //  correct for the fall-off
02670         //  mask and subtract circumference average
02671         int ix = win->get_xsize();
02672         int iy = win->get_ysize();
02673         int iz = win->get_zsize();
02674 
02675         int IP = ix/2+1;
02676         int JP = iy/2+1;
02677         int KP = iz/2+1;
02678         
02679         //  sinc functions tabulated for fall-off
02680         float* sincx = new float[IP+1];
02681         float* sincy = new float[JP+1];
02682         float* sincz = new float[KP+1];
02683 
02684         sincx[0] = 1.0f;
02685         sincy[0] = 1.0f;
02686         sincz[0] = 1.0f;
02687 
02688         float cdf = M_PI/float(npad*2*ix);
02689         for (int i = 1; i <= IP; ++i)  sincx[i] = sin(i*cdf)/(i*cdf);
02690         cdf = M_PI/float(npad*2*iy);
02691         for (int i = 1; i <= JP; ++i)  sincy[i] = sin(i*cdf)/(i*cdf);
02692         cdf = M_PI/float(npad*2*iz);
02693         for (int i = 1; i <= KP; ++i)  sincz[i] = sin(i*cdf)/(i*cdf);
02694         for (int k = 1; k <= iz; ++k) {
02695                 int kkp = abs(k-KP);
02696                 for (int j = 1; j <= iy; ++j) {
02697                         cdf = sincy[abs(j- JP)]*sincz[kkp];
02698                         for (int i = 1; i <= ix; ++i)  tw(i,j,k) /= (sincx[abs(i-IP)]*cdf);
02699                 }
02700         }
02701 
02702         delete[] sincx;
02703         delete[] sincy;
02704         delete[] sincz;
02705         
02706         
02707         
02708         float dxx = 1.0f/float(0.25*ix*ix);
02709         float dyy = 1.0f/float(0.25*iy*iy);
02710         
02711         
02712         
02713         float LR2=(float(ix)/2-1)*(float(ix)/2-1)*dxx;
02714 
02715         float  TNR = 0.0f;
02716         size_t m = 0;
02717         for (int k = 1; k <= iz; ++k) {
02718                 for (int j = 1; j <= iy; ++j) {
02719                         for (int i = 1; i <= ix; ++i) {
02720                                 float LR = (j-JP)*(j-JP)*dyy+(i-IP)*(i-IP)*dxx;
02721                                 if (LR<=1.0f && LR >= LR2) {
02722                                         TNR += tw(i,j,k);
02723                                         ++m;
02724                                 }
02725                         }
02726                 }
02727         }
02728 
02729         TNR /=float(m);
02730         
02731 
02732         for (int k = 1; k <= iz; ++k) {
02733                 for (int j = 1; j <= iy; ++j) {
02734                         for (int i = 1; i <= ix; ++i) {
02735                                 float LR = (j-JP)*(j-JP)*dyy+(i-IP)*(i-IP)*dxx;
02736                                 if (LR<=1.0f)  tw(i,j,k)=tw(i,j,k)-TNR;
02737                                 else            tw(i,j,k) = 0.0f;       
02738                         }
02739                 }
02740         }
02741 
02742 }

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

Definition at line 2022 of file reconstructor.cpp.

References abs, and max.

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

02023 {
02024         float max = 0.0;
02025         for( int i=-kc; i <= kc; ++i ) {
02026                 for( int j=-kc; j <= kc; ++j ) {
02027                         if( i==0 && j==0 ) continue;
02028                         {
02029                                 int c = 2*kc+1 - std::abs(i) - std::abs(j);
02030                                 max = max + pow_a[c];
02031                         }
02032                 }
02033         }
02034         return max;
02035 }

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

Definition at line 2037 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().

02038 {
02039         float max = 0.0;
02040         for( int i=-kc; i <= kc; ++i ) {
02041                 for( int j=-kc; j <= kc; ++j ) {
02042                         for( int k=-kc; k <= kc; ++k ) {
02043                                 if( i==0 && j==0 && k==0 ) continue;
02044                                 // if( i!=0 )
02045                                 {
02046                                         int c = 3*kc+1 - std::abs(i) - std::abs(j) - std::abs(k);
02047                                         max = max + pow_a[c];
02048                                         // max = max + c * c;
02049                                         // max = max + c;
02050                                 }
02051                         }
02052                 }
02053         }
02054         return max;
02055 }

void printImage ( const EMData line  ) 

Definition at line 2142 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.

02143 {
02144         Assert( line->get_zsize()==1 );
02145 
02146 
02147         int nx = line->get_xsize();
02148         int ny = line->get_ysize();
02149         for( int j=0; j < ny; ++j ) {
02150                 for( int i=0; i < nx; ++i )  printf( "%10.3f ", line->get_value_at(i,j) );
02151                 printf( "\n" );
02152         }
02153 }


Generated on Tue Jun 11 12:41:41 2013 for EMAN2 by  doxygen 1.4.7