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

EMAN::nn4Reconstructor Class Reference

#include <reconstructor.h>

Inheritance diagram for EMAN::nn4Reconstructor:

Inheritance graph
[legend]
Collaboration diagram for EMAN::nn4Reconstructor:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 nn4Reconstructor ()
 nn4Reconstructor (const string &symmetry, int size, int npad)
virtual ~nn4Reconstructor ()
virtual void setup ()
 Initialize the reconstructor.
virtual int insert_slice (const EMData *const slice, const Transform &euler, const float weight=1.0)
 Insert an image slice to the reconstructor.
virtual EMDatafinish (bool doift=true)
 Finish reconstruction and return the complete model.
virtual string get_name () const
 Get the unique name of this class (especially for factory based instantiation access).
virtual string get_desc () const
 Get a clear, concise description of this class.
virtual TypeDict get_param_types () const
void setup (const string &symmetry, int size, int npad)
int insert_padfft_slice (EMData *padded, const Transform &trans, int mult=1)

Static Public Member Functions

ReconstructorNEW ()

Static Public Attributes

const string NAME = "nn4"

Private Member Functions

void buildFFTVolume ()
void buildNormVolume ()
void load_default_settings ()

Private Attributes

EMDatam_volume
EMDatam_wptr
EMDatam_result
bool m_delete_volume
bool m_delete_weight
string m_symmetry
int m_weighting
int m_vnx
int m_vny
int m_vnz
int m_npad
int m_nsym
int m_ndim
int m_vnzp
int m_vnyp
int m_vnxp
int m_vnzc
int m_vnyc
int m_vnxc
float m_wghta
float m_wghtb
float m_osnr

Constructor & Destructor Documentation

nn4Reconstructor::nn4Reconstructor  ) 
 

Definition at line 1973 of file reconstructor.cpp.

References m_result, m_volume, and m_wptr.

01974 {
01975         m_volume = NULL;
01976         m_wptr   = NULL;
01977         m_result = NULL;
01978 }

nn4Reconstructor::nn4Reconstructor const string &  symmetry,
int  size,
int  npad
 

Definition at line 1980 of file reconstructor.cpp.

References load_default_settings(), m_result, m_volume, m_wptr, EMAN::Reconstructor::print_params(), and setup().

01981 {
01982         m_volume = NULL;
01983         m_wptr   = NULL;
01984         m_result = NULL;
01985         setup( symmetry, size, npad );
01986         load_default_settings();
01987         print_params();
01988 }

nn4Reconstructor::~nn4Reconstructor  )  [virtual]
 

Definition at line 1990 of file reconstructor.cpp.

References checked_delete(), m_result, m_volume, and m_wptr.

01991 {
01992         if( m_delete_volume ) checked_delete(m_volume);
01993 
01994         if( m_delete_weight ) checked_delete( m_wptr );
01995 
01996         checked_delete( m_result );
01997 }


Member Function Documentation

void nn4Reconstructor::buildFFTVolume  )  [private]
 

Definition at line 2083 of file reconstructor.cpp.

References EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::Dict::has_key(), m_delete_volume, m_npad, m_vnxp, m_vnyp, m_vnzp, m_volume, EMAN::EMData::set_array_offsets(), EMAN::EMData::set_attr(), EMAN::EMData::set_complex(), EMAN::EMData::set_fftodd(), EMAN::EMData::set_fftpad(), EMAN::EMData::set_nxc(), EMAN::EMData::set_ri(), EMAN::EMData::set_size(), and EMAN::EMData::to_zero().

Referenced by setup().

02083                                       {
02084         int offset = 2 - m_vnxp%2;
02085 
02086         if( params.has_key("fftvol") ) {
02087                 m_volume = params["fftvol"];
02088                 m_delete_volume = false;
02089         } else {
02090                 m_volume = new EMData();
02091                 m_delete_volume = true;
02092         }
02093 
02094         if( m_volume->get_xsize() != m_vnxp+offset && m_volume->get_ysize() != m_vnyp && m_volume->get_zsize() != m_vnzp ) {
02095                 m_volume->set_size(m_vnxp+offset,m_vnyp,m_vnzp);
02096                 m_volume->to_zero();
02097         }
02098         // ----------------------------------------------------------------
02099         // Added by Zhengfan Yang on 03/15/07
02100         // Original author: please check whether my revision is correct and
02101         // other Reconstructor need similiar revision.
02102         if ( m_vnxp % 2 == 0 )  m_volume->set_fftodd(0);
02103         else                    m_volume->set_fftodd(1);
02104         // ----------------------------------------------------------------
02105 
02106         m_volume->set_nxc(m_vnxp/2);
02107         m_volume->set_complex(true);
02108         m_volume->set_ri(true);
02109         m_volume->set_fftpad(true);
02110         m_volume->set_attr("npad", m_npad);
02111         m_volume->set_array_offsets(0,1,1);
02112 }

void nn4Reconstructor::buildNormVolume  )  [private]
 

Definition at line 2114 of file reconstructor.cpp.

References EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::Dict::has_key(), m_delete_weight, m_vnxc, m_vnyp, m_vnzp, m_wptr, EMAN::EMData::set_array_offsets(), EMAN::EMData::set_size(), and EMAN::EMData::to_zero().

Referenced by setup().

02114                                        {
02115 
02116         if( params.has_key("weight") ) {
02117                 m_wptr = params["weight"];
02118                 m_delete_weight = false;
02119         } else {
02120                 m_wptr = new EMData();
02121                 m_delete_weight = true;
02122         }
02123 
02124         if( m_wptr->get_xsize() != m_vnxc+1 &&
02125                 m_wptr->get_ysize() != m_vnyp &&
02126                 m_wptr->get_zsize() != m_vnzp ) {
02127                 m_wptr->set_size(m_vnxc+1,m_vnyp,m_vnzp);
02128                 m_wptr->to_zero();
02129         }
02130 
02131         m_wptr->set_array_offsets(0,1,1);
02132 }

EMData * nn4Reconstructor::finish bool  doift = true  )  [virtual]
 

Finish reconstruction and return the complete model.

Parameters:
doift A flag indicating whether the returned object should be guaranteed to be in real-space (true) or should be left in whatever space the reconstructor generated
Returns:
The result 3D model.

Reimplemented from EMAN::Reconstructor.

Definition at line 2299 of file reconstructor.cpp.

References abs, circumf(), EMAN::EMData::copy(), EMAN::EMData::depad(), EMAN::EMData::do_ift_inplace(), EMAN::EMData::get_attr(), m_ndim, m_result, m_vnyc, m_vnyp, m_volume, m_weighting, m_wghta, m_wptr, max, max2d(), max3d(), EMAN::EMData::set_array_offsets(), and EMAN::EMData::symplane0().

02300 {
02301         if( m_ndim==3 ) {
02302                 m_volume->symplane0(m_wptr);
02303         } else {
02304                 for( int i=1; i <= m_vnyp; ++i ) {
02305 
02306                         if( (*m_wptr)(0, i, 1)==0.0 ) {
02307                                 int j = m_vnyp + 1 - i;
02308                                 (*m_wptr)(0, i, 1) = (*m_wptr)(0, j, 1);
02309                                 (*m_volume)(0, i, 1) = (*m_volume)(0, j, 1);
02310                                 (*m_volume)(1, i, 1) = (*m_volume)(1, j, 1);
02311                         }
02312                 }
02313         }
02314 
02315 
02316         int box = 7;
02317         int kc = (box-1)/2;
02318         vector< float > pow_a( m_ndim*kc+1, 1.0 );
02319         for( unsigned int i=1; i < pow_a.size(); ++i ) pow_a[i] = pow_a[i-1] * exp(m_wghta);
02320         pow_a.back()=0.0;
02321 
02322         float alpha = 0.0;
02323         if( m_ndim==3) {
02324                 int vol = box*box*box;
02325                 float max = max3d( kc, pow_a );
02326                 alpha = ( 1.0f - 1.0f/(float)vol ) / max;
02327         } else {
02328                 int ara = box*box;
02329                 float max = max2d( kc, pow_a );
02330                 alpha = ( 1.0f - 1.0f/(float)ara ) / max;
02331         }
02332 
02333         int ix,iy,iz;
02334         for (iz = 1; iz <= m_vnzp; iz++) {
02335                 for (iy = 1; iy <= m_vnyp; iy++) {
02336                         for (ix = 0; ix <= m_vnxc; ix++) {
02337                                 if ( (*m_wptr)(ix,iy,iz) > 0) {//(*v) should be treated as complex!!
02338                                         float tmp;
02339                                         tmp = (-2*((ix+iy+iz)%2)+1)/((*m_wptr)(ix,iy,iz)+m_osnr);
02340 
02341                                         if( m_weighting == ESTIMATE ) {
02342                                                 int cx = ix;
02343                                                 int cy = (iy<=m_vnyc) ? iy - 1 : iy - 1 - m_vnyp;
02344                                                 int cz = (iz<=m_vnzc) ? iz - 1 : iz - 1 - m_vnzp;
02345                                                 float sum = 0.0;
02346                                                 for( int ii = -kc; ii <= kc; ++ii ) {
02347                                                         int nbrcx = cx + ii;
02348                                                         if( nbrcx >= m_vnxc ) continue;
02349                                                         for( int jj= -kc; jj <= kc; ++jj ) {
02350                                                                 int nbrcy = cy + jj;
02351                                                                 if( nbrcy <= -m_vnyc || nbrcy >= m_vnyc ) continue;
02352 
02353                                                                 int kcz = (m_ndim==3) ? kc : 0;
02354                                                                 for( int kk = -kcz; kk <= kcz; ++kk ) {
02355                                                                         int nbrcz = cz + kk;
02356                                                                         if( nbrcz <= -m_vnyc || nbrcz >= m_vnyc ) continue;
02357                                                                         if( nbrcx < 0 ) {
02358                                                                                 nbrcx = -nbrcx;
02359                                                                                 nbrcy = -nbrcy;
02360                                                                                 nbrcz = -nbrcz;
02361                                                                         }
02362                                                                         int nbrix = nbrcx;
02363                                                                         int nbriy = nbrcy >= 0 ? nbrcy + 1 : nbrcy + 1 + m_vnyp;
02364                                                                         int nbriz = nbrcz >= 0 ? nbrcz + 1 : nbrcz + 1 + m_vnzp;
02365                                                                         if( (*m_wptr)( nbrix, nbriy, nbriz ) == 0 ) {
02366                                                                                 int c = m_ndim*kc+1 - std::abs(ii) - std::abs(jj) - std::abs(kk);
02367                                                                                 sum = sum + pow_a[c];
02368                                                                         }
02369                                                                 }
02370                                                         }
02371                                                 }
02372                                                 float wght = 1.0f / ( 1.0f - alpha * sum );
02373                                                 tmp = tmp * wght;
02374                                         }
02375                                         (*m_volume)(2*ix,iy,iz)   *= tmp;
02376                                         (*m_volume)(2*ix+1,iy,iz) *= tmp;
02377                                 }
02378                         }
02379                 }
02380         }
02381 
02382         //if(m_ndim==2) printImage( m_volume );
02383 
02384         // back fft
02385         m_volume->do_ift_inplace();
02386 
02387         // EMData* win = m_volume->window_center(m_vnx);
02388         int npad = m_volume->get_attr("npad");
02389         m_volume->depad();
02390         circumf( m_volume, npad );
02391         m_volume->set_array_offsets( 0, 0, 0 );
02392 
02393         m_result = m_volume->copy();
02394         return m_result;
02395 }

virtual string EMAN::nn4Reconstructor::get_desc  )  const [inline, virtual]
 

Get a clear, concise description of this class.

Returns:
a clear, concise description of this class

Implements EMAN::FactoryBase.

Definition at line 758 of file reconstructor.h.

00759                 {
00760                         return "Direct Fourier inversion routine";
00761                 }

virtual string EMAN::nn4Reconstructor::get_name  )  const [inline, virtual]
 

Get the unique name of this class (especially for factory based instantiation access).

Returns:
the unique name of this class

Implements EMAN::FactoryBase.

Definition at line 753 of file reconstructor.h.

00754                 {
00755                         return NAME;
00756                 }

virtual TypeDict EMAN::nn4Reconstructor::get_param_types  )  const [inline, virtual]
 

Returns:
a TypeDict defining and describing the feasible parameters of this class

Implements EMAN::FactoryBase.

Definition at line 768 of file reconstructor.h.

References EMAN::TypeDict::put().

00769                 {
00770                         TypeDict d;
00771                         d.put("size",           EMObject::INT);
00772                         d.put("npad",           EMObject::INT);
00773                         d.put("sign",           EMObject::INT);
00774                         d.put("ndim",           EMObject::INT);
00775                         d.put("snr",            EMObject::FLOAT);
00776                         d.put("symmetry",       EMObject::STRING);
00777                         d.put("snr",            EMObject::FLOAT);
00778                         d.put("fftvol",         EMObject::EMDATA);
00779                         d.put("weight",         EMObject::EMDATA);
00780                         d.put("weighting",      EMObject::INT);
00781                         return d;
00782                 }

int nn4Reconstructor::insert_padfft_slice EMData padded,
const Transform trans,
int  mult = 1
 

Definition at line 2210 of file reconstructor.cpp.

References Assert, EMAN::Transform::get_sym(), m_symmetry, m_volume, m_wptr, mult(), EMAN::EMData::nn(), and t.

02211 {
02212         Assert( padfft != NULL );
02213         // insert slice for all symmetry related positions
02214 
02215         for (int isym=0; isym < m_nsym; isym++) {
02216                 Transform tsym = t.get_sym(m_symmetry, isym);
02217         
02218                 m_volume->nn( m_wptr, padfft, tsym, mult);
02219         }
02220         return 0;
02221 }

virtual int EMAN::nn4Reconstructor::insert_slice const EMData *const   slice,
const Transform euler,
const float  weight = 1.0
[virtual]
 

Insert an image slice to the reconstructor.

To insert multiple image slices, call this function multiple times.

Parameters:
slice Image slice.
euler Euler angle of this image slice.
weight A weighting factor for this slice, generally the number of particles in a class-average. May be ignored by some reconstructors
Returns:
0 if OK. 1 if error.

Reimplemented from EMAN::Reconstructor.

void EMAN::nn4Reconstructor::load_default_settings  )  [inline, private]
 

Definition at line 809 of file reconstructor.h.

Referenced by nn4Reconstructor().

00810                 {
00811                         //params["use_weights"] = false;
00812                 }

Reconstructor* EMAN::nn4Reconstructor::NEW  )  [inline, static]
 

Definition at line 763 of file reconstructor.h.

00764                 {
00765                         return new nn4Reconstructor();
00766                 }

void nn4Reconstructor::setup const string &  symmetry,
int  size,
int  npad
 

Definition at line 2056 of file reconstructor.cpp.

References buildFFTVolume(), buildNormVolume(), EMAN::Transform::get_nsym(), m_ndim, m_npad, m_nsym, m_symmetry, m_vnx, m_vnxc, m_vnxp, m_vny, m_vnyc, m_vnyp, m_vnz, m_vnzc, m_vnzp, m_weighting, and m_wghta.

02057 {
02058         m_weighting = ESTIMATE;
02059         m_wghta = 0.2f;
02060 
02061         m_symmetry = symmetry;
02062         m_npad = npad;
02063         m_nsym = Transform::get_nsym(m_symmetry);
02064 
02065         m_vnx = size;
02066         m_vny = size;
02067         m_vnz = (m_ndim==3) ? size : 1;
02068 
02069         m_vnxp = size*npad;
02070         m_vnyp = size*npad;
02071         m_vnzp = (m_ndim==3) ? size*npad : 1;
02072 
02073         m_vnxc = m_vnxp/2;
02074         m_vnyc = m_vnyp/2;
02075         m_vnzc = (m_ndim==3) ? m_vnzp/2 : 1;
02076 
02077         buildFFTVolume();
02078         buildNormVolume();
02079 
02080 }

void nn4Reconstructor::setup  )  [virtual]
 

Initialize the reconstructor.

Implements EMAN::Reconstructor.

Definition at line 2037 of file reconstructor.cpp.

References EMAN::Dict::has_key(), m_ndim, and m_osnr.

Referenced by nn4Reconstructor().

02038 {
02039         int size = params["size"];
02040         int npad = params["npad"];
02041 
02042 
02043         string symmetry;
02044         if( params.has_key("symmetry") )  symmetry = params["symmetry"].to_str();
02045         else                               symmetry = "c1";
02046 
02047         if( params.has_key("ndim") )  m_ndim = params["ndim"];
02048         else                          m_ndim = 3;
02049 
02050         if( params.has_key( "snr" ) )  m_osnr = 1.0f/float( params["snr"] );
02051         else                           m_osnr = 0.0;
02052 
02053         setup( symmetry, size, npad );
02054 }


Member Data Documentation

bool EMAN::nn4Reconstructor::m_delete_volume [private]
 

Definition at line 794 of file reconstructor.h.

Referenced by buildFFTVolume().

bool EMAN::nn4Reconstructor::m_delete_weight [private]
 

Definition at line 795 of file reconstructor.h.

Referenced by buildNormVolume().

int EMAN::nn4Reconstructor::m_ndim [private]
 

Definition at line 801 of file reconstructor.h.

Referenced by finish(), and setup().

int EMAN::nn4Reconstructor::m_npad [private]
 

Definition at line 799 of file reconstructor.h.

Referenced by buildFFTVolume(), and setup().

int EMAN::nn4Reconstructor::m_nsym [private]
 

Definition at line 800 of file reconstructor.h.

Referenced by setup().

float EMAN::nn4Reconstructor::m_osnr [private]
 

Definition at line 808 of file reconstructor.h.

Referenced by setup().

EMData* EMAN::nn4Reconstructor::m_result [private]
 

Definition at line 793 of file reconstructor.h.

Referenced by finish(), nn4Reconstructor(), and ~nn4Reconstructor().

string EMAN::nn4Reconstructor::m_symmetry [private]
 

Definition at line 796 of file reconstructor.h.

Referenced by insert_padfft_slice(), and setup().

int EMAN::nn4Reconstructor::m_vnx [private]
 

Definition at line 798 of file reconstructor.h.

Referenced by setup().

int EMAN::nn4Reconstructor::m_vnxc [private]
 

Definition at line 803 of file reconstructor.h.

Referenced by buildNormVolume(), and setup().

int EMAN::nn4Reconstructor::m_vnxp [private]
 

Definition at line 802 of file reconstructor.h.

Referenced by buildFFTVolume(), and setup().

int EMAN::nn4Reconstructor::m_vny [private]
 

Definition at line 798 of file reconstructor.h.

Referenced by setup().

int EMAN::nn4Reconstructor::m_vnyc [private]
 

Definition at line 803 of file reconstructor.h.

Referenced by finish(), and setup().

int EMAN::nn4Reconstructor::m_vnyp [private]
 

Definition at line 802 of file reconstructor.h.

Referenced by buildFFTVolume(), buildNormVolume(), finish(), and setup().

int EMAN::nn4Reconstructor::m_vnz [private]
 

Definition at line 798 of file reconstructor.h.

Referenced by setup().

int EMAN::nn4Reconstructor::m_vnzc [private]
 

Definition at line 803 of file reconstructor.h.

Referenced by setup().

int EMAN::nn4Reconstructor::m_vnzp [private]
 

Definition at line 802 of file reconstructor.h.

Referenced by buildFFTVolume(), buildNormVolume(), and setup().

EMData* EMAN::nn4Reconstructor::m_volume [private]
 

Definition at line 791 of file reconstructor.h.

Referenced by buildFFTVolume(), finish(), insert_padfft_slice(), nn4Reconstructor(), and ~nn4Reconstructor().

int EMAN::nn4Reconstructor::m_weighting [private]
 

Definition at line 797 of file reconstructor.h.

Referenced by finish(), and setup().

float EMAN::nn4Reconstructor::m_wghta [private]
 

Definition at line 806 of file reconstructor.h.

Referenced by finish(), and setup().

float EMAN::nn4Reconstructor::m_wghtb [private]
 

Definition at line 807 of file reconstructor.h.

EMData* EMAN::nn4Reconstructor::m_wptr [private]
 

Definition at line 792 of file reconstructor.h.

Referenced by buildNormVolume(), finish(), insert_padfft_slice(), nn4Reconstructor(), and ~nn4Reconstructor().

const string nn4Reconstructor::NAME = "nn4" [static]
 

Definition at line 81 of file reconstructor.cpp.


The documentation for this class was generated from the following files:
Generated on Thu Mar 10 23:00:43 2011 for EMAN2 by  doxygen 1.3.9.1