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

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

Definition at line 3981 of file reconstructor.cpp.

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

Definition at line 3981 of file reconstructor.cpp.

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

Definition at line 3981 of file reconstructor.cpp.

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

Definition at line 3981 of file reconstructor.cpp.

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

Definition at line 3981 of file reconstructor.cpp.

Referenced by circumf(), and circumf_rect().


Enumeration Type Documentation

enum weighting_method
 

Enumeration values:
NONE 
ESTIMATE 
VORONOI 

Definition at line 1999 of file reconstructor.cpp.

01999 { NONE, ESTIMATE, VORONOI };


Function Documentation

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

Definition at line 69 of file reconstructor.cpp.

References x.

Referenced by EMAN::file_store::add_image(), EMAN::newfile_store::add_image(), 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().

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 2226 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().

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

void circumf_rect EMData win,
int  npad
 

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

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

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

Definition at line 2001 of file reconstructor.cpp.

References abs, and max.

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

02002 {
02003         float max = 0.0;
02004         for( int i=-kc; i <= kc; ++i ) {
02005                 for( int j=-kc; j <= kc; ++j ) {
02006                         if( i==0 && j==0 ) continue;
02007                         {
02008                                 int c = 2*kc+1 - std::abs(i) - std::abs(j);
02009                                 max = max + pow_a[c];
02010                         }
02011                 }
02012         }
02013         return max;
02014 }

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

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

02017 {
02018         float max = 0.0;
02019         for( int i=-kc; i <= kc; ++i ) {
02020                 for( int j=-kc; j <= kc; ++j ) {
02021                         for( int k=-kc; k <= kc; ++k ) {
02022                                 if( i==0 && j==0 && k==0 ) continue;
02023                                 // if( i!=0 )
02024                                 {
02025                                         int c = 3*kc+1 - std::abs(i) - std::abs(j) - std::abs(k);
02026                                         max = max + pow_a[c];
02027                                         // max = max + c * c;
02028                                         // max = max + c;
02029                                 }
02030                         }
02031                 }
02032         }
02033         return max;
02034 }

void printImage const EMData line  ) 
 

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

02135 {
02136         Assert( line->get_zsize()==1 );
02137 
02138 
02139         int nx = line->get_xsize();
02140         int ny = line->get_ysize();
02141         for( int j=0; j < ny; ++j ) {
02142                 for( int i=0; i < nx; ++i )  printf( "%10.3f ", line->get_value_at(i,j) );
02143                 printf( "\n" );
02144         }
02145 }


Generated on Thu Mar 10 22:59:23 2011 for EMAN2 by  doxygen 1.3.9.1