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

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

Definition at line 3884 of file reconstructor.cpp.

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

Definition at line 3884 of file reconstructor.cpp.

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

Definition at line 3884 of file reconstructor.cpp.

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

Definition at line 3884 of file reconstructor.cpp.

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

Definition at line 3884 of file reconstructor.cpp.

Referenced by circumf(), and circumf_rect().


Enumeration Type Documentation

enum weighting_method
 

Enumeration values:
NONE 
ESTIMATE 
VORONOI 

Definition at line 2004 of file reconstructor.cpp.

02004 { 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(), 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 2221 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().

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

void circumf_rect EMData win,
int  npad
 

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

02644 {
02645         float *tw = win->get_data();
02646         //  correct for the fall-off
02647         //  mask and subtract circumference average
02648         int ix = win->get_xsize();
02649         int iy = win->get_ysize();
02650         int iz = win->get_zsize();
02651 
02652         int IP = ix/2+1;
02653         int JP = iy/2+1;
02654         int KP = iz/2+1;
02655         
02656         //  sinc functions tabulated for fall-off
02657         float* sincx = new float[IP+1];
02658         float* sincy = new float[JP+1];
02659         float* sincz = new float[KP+1];
02660 
02661         sincx[0] = 1.0f;
02662         sincy[0] = 1.0f;
02663         sincz[0] = 1.0f;
02664 
02665         float cdf = M_PI/float(npad*2*ix);
02666         for (int i = 1; i <= IP; ++i)  sincx[i] = sin(i*cdf)/(i*cdf);
02667         cdf = M_PI/float(npad*2*iy);
02668         for (int i = 1; i <= JP; ++i)  sincy[i] = sin(i*cdf)/(i*cdf);
02669         cdf = M_PI/float(npad*2*iz);
02670         for (int i = 1; i <= KP; ++i)  sincz[i] = sin(i*cdf)/(i*cdf);
02671         for (int k = 1; k <= iz; ++k) {
02672                 int kkp = abs(k-KP);
02673                 for (int j = 1; j <= iy; ++j) {
02674                         cdf = sincy[abs(j- JP)]*sincz[kkp];
02675                         for (int i = 1; i <= ix; ++i)  tw(i,j,k) /= (sincx[abs(i-IP)]*cdf);
02676                 }
02677         }
02678 
02679         delete[] sincx;
02680         delete[] sincy;
02681         delete[] sincz;
02682         
02683         
02684         
02685         float dxx = 1.0f/float(0.25*ix*ix);
02686         float dyy = 1.0f/float(0.25*iy*iy);
02687         
02688         
02689         
02690         float LR2=(float(ix)/2-1)*(float(ix)/2-1)*dxx;
02691 
02692         float  TNR = 0.0f;
02693         size_t m = 0;
02694         for (int k = 1; k <= iz; ++k) {
02695                 for (int j = 1; j <= iy; ++j) {
02696                         for (int i = 1; i <= ix; ++i) {
02697                                 float LR = (j-JP)*(j-JP)*dyy+(i-IP)*(i-IP)*dxx;
02698                                 if (LR<=1.0f && LR >= LR2) {
02699                                         TNR += tw(i,j,k);
02700                                         ++m;
02701                                 }
02702                         }
02703                 }
02704         }
02705 
02706         TNR /=float(m);
02707         
02708 
02709         for (int k = 1; k <= iz; ++k) {
02710                 for (int j = 1; j <= iy; ++j) {
02711                         for (int i = 1; i <= ix; ++i) {
02712                                 float LR = (j-JP)*(j-JP)*dyy+(i-IP)*(i-IP)*dxx;
02713                                 if (LR<=1.0f)  tw(i,j,k)=tw(i,j,k)-TNR;
02714                                 else            tw(i,j,k) = 0.0f;       
02715                         }
02716                 }
02717         }
02718 
02719 }

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

Definition at line 2006 of file reconstructor.cpp.

References abs, and max.

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

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

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

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

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

void printImage const EMData line  ) 
 

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

02127 {
02128         Assert( line->get_zsize()==1 );
02129 
02130 
02131         int nx = line->get_xsize();
02132         int ny = line->get_ysize();
02133         for( int j=0; j < ny; ++j ) {
02134                 for( int i=0; i < nx; ++i )  printf( "%10.3f ", line->get_value_at(i,j) );
02135                 printf( "\n" );
02136         }
02137 }


Generated on Tue Jul 12 13:50:33 2011 for EMAN2 by  doxygen 1.3.9.1