EMAN2
Classes | Defines | Functions
emdata_sparx.cpp File Reference
#include <stack>
#include "ctf.h"
#include "emdata.h"
#include <iostream>
#include <cmath>
#include <cstring>
#include <gsl/gsl_sf_bessel.h>
#include <gsl/gsl_errno.h>
#include <vector>
#include <boost/shared_ptr.hpp>
Include dependency graph for emdata_sparx.cpp:

Go to the source code of this file.

Classes

class  ctf_store
class  ctf_store_new

Defines

#define rdata(i, j, k)   rdata[(i-1)+((j-1)+(k-1)*ny)*(size_t)nx]
#define square(x)   ((x)*(x))
#define proj(ix, iy, iz)   proj[ix-1+(iy-1+(iz-1)*ny)*(size_t)nx]
#define pnewimg(ix, iy, iz)   pnewimg[ix-1+(iy-1+(iz-1)*ny)*(size_t)nx]
#define in(i, j, k)   in[i+(j+(k*ny))*(size_t)nx]
#define in(i, j, k)   in[i+(j+(k*ny))*(size_t)nx]
#define QUADPI   3.141592653589793238462643383279502884197
#define DGR_TO_RAD   QUADPI/180
#define rdata(i, j, k)   rdata[(i-1)+((j-1)+(k-1)*ny)*(size_t)nx]
#define X(i)   X[i-1]
#define Y(j)   Y[j-1]
#define Z(k)   Z[k-1]
#define avagadro   (6.023*(double)pow(10.0,23.0))
#define density_protein   (1.36)
#define R   (0.61803399f)
#define C   (1.f-R)
#define QUADPI   3.141592653589793238462643383279502884197
#define DGR_TO_RAD   QUADPI/180
#define fint(i, j, k)   fint[(i-1) + ((j-1) + (k-1)*ny)*(size_t)lsd]
#define fout(i, j, k)   fout[(i-1) + ((j-1) + (k-1)*nyn)*(size_t)lsdn]
#define fint(jx, jy, jz)   fint[jx + (jy + jz*ny)*(size_t)nox]
#define fint(jx, jy, jz)   fint[jx + (jy + jz*ny)*(size_t)nx]
#define fout(jx, jy, jz)   fout[jx + (jy + jz*ny)*(size_t)nx]

Functions

float dist (int lnlen, const float *line_1, const float *line_2)
float dist_r (int lnlen, const float *line_1, const float *line_2)
void swapx (float *a, float *b, float *temp, size_t nbytes)
 Helper function for EMData::fft_shuffle, below.
ostream & operator<< (ostream &os, const Pixel &peak)
float circumference (EMData *emdata, int npixel)

Define Documentation

#define avagadro   (6.023*(double)pow(10.0,23.0))

Definition at line 6121 of file emdata_sparx.cpp.

Referenced by EMAN::EMData::find_3d_threshold().

#define C   (1.f-R)
#define density_protein   (1.36)

Definition at line 6122 of file emdata_sparx.cpp.

Referenced by EMAN::EMData::find_3d_threshold().

#define DGR_TO_RAD   QUADPI/180

Definition at line 6418 of file emdata_sparx.cpp.

#define DGR_TO_RAD   QUADPI/180
#define fint (   i,
  j,
 
)    fint[(i-1) + ((j-1) + (k-1)*ny)*(size_t)lsd]
#define fint (   jx,
  jy,
  jz 
)    fint[jx + (jy + jz*ny)*(size_t)nox]

Definition at line 7518 of file emdata_sparx.cpp.

#define fint (   jx,
  jy,
  jz 
)    fint[jx + (jy + jz*ny)*(size_t)nx]

Definition at line 7518 of file emdata_sparx.cpp.

#define fout (   jx,
  jy,
  jz 
)    fout[jx + (jy + jz*ny)*(size_t)nx]

Definition at line 7519 of file emdata_sparx.cpp.

#define fout (   i,
  j,
 
)    fout[(i-1) + ((j-1) + (k-1)*nyn)*(size_t)lsdn]
#define in (   i,
  j,
 
)    in[i+(j+(k*ny))*(size_t)nx]
#define in (   i,
  j,
 
)    in[i+(j+(k*ny))*(size_t)nx]

Definition at line 2906 of file emdata_sparx.cpp.

#define pnewimg (   ix,
  iy,
  iz 
)    pnewimg[ix-1+(iy-1+(iz-1)*ny)*(size_t)nx]

Definition at line 1160 of file emdata_sparx.cpp.

Referenced by EMAN::EMData::average_circ_sub().

#define proj (   ix,
  iy,
  iz 
)    proj[ix-1+(iy-1+(iz-1)*ny)*(size_t)nx]
#define QUADPI   3.141592653589793238462643383279502884197

Definition at line 6417 of file emdata_sparx.cpp.

#define QUADPI   3.141592653589793238462643383279502884197

Definition at line 6417 of file emdata_sparx.cpp.

#define R   (0.61803399f)
#define rdata (   i,
  j,
 
)    rdata[(i-1)+((j-1)+(k-1)*ny)*(size_t)nx]

Definition at line 5986 of file emdata_sparx.cpp.

#define rdata (   i,
  j,
 
)    rdata[(i-1)+((j-1)+(k-1)*ny)*(size_t)nx]

Definition at line 5986 of file emdata_sparx.cpp.

#define square (   x)    ((x)*(x))
#define X (   i)    X[i-1]
#define Y (   j)    Y[j-1]

Definition at line 5988 of file emdata_sparx.cpp.

Referenced by EMAN::EMData::phase_cog(), and EMAN::Util::WTF().

#define Z (   k)    Z[k-1]

Definition at line 5989 of file emdata_sparx.cpp.

Referenced by EMAN::EMData::phase_cog().


Function Documentation

float circumference ( EMData emdata,
int  npixel 
)

Definition at line 6767 of file emdata_sparx.cpp.

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

Referenced by EMAN::EMData::norm_pad().

{
        int nx = emdata->get_xsize();
        int ny = emdata->get_ysize();
        int nz = emdata->get_zsize();

        float* data = emdata->get_data();
        if( ny==1 && nz==1 ) {
                // 1d case
                float sumf=0.0;
                int   sumn=0;
                for( int i=0; i < npixel; ++i ) {
                        sumf += data[i];
                        sumf += data[nx-1-i];
                        sumn += 2;
                }
                return sumf/sumn;
        }

        if( nz==1 ) {
                float sumf=0.0;
                int   sumn=0;
                int   id=0;
                for( int iy=0; iy < ny; ++iy ) {
                        for( int ix=0; ix < nx; ++ix ) {
                                if( iy<npixel || iy>ny-1-npixel || ix<npixel || ix>nx-1-npixel ) {
                                    sumf += data[id];
                                    sumn += 1;
                                }
                                id++;
                        }
                }

                Assert( id==nx*ny  );
                Assert( sumn == nx*ny - (nx-2*npixel)*(ny-2*npixel) );
                return sumf/sumn;
        }

        // 3d cases;

        float sumf = 0.0;
        size_t   sumn = 0;
        size_t   id = 0;
        for( int iz=0; iz < nz; ++iz) {
                for( int iy=0; iy < ny; ++iy) {
                        for( int ix=0; ix < nx; ++ix ) {
                                if( iz<npixel||iz>nz-1-npixel||iy<npixel||iy>ny-1-npixel||ix<npixel||ix>nx-1-npixel) {
                                        sumf += data[id];
                                        sumn += 1;
                                }
                                id++;
                        }
                }
        }


        Assert( id==(size_t)nx*ny*nz);
        Assert( sumn==(size_t)nx*ny*nz-(size_t)(nx-2*npixel)*(ny-2*npixel)*(nz-2*npixel) );
        return sumf/sumn;
}
float dist ( int  lnlen,
const float *  line_1,
const float *  line_2 
)
float dist_r ( int  lnlen,
const float *  line_1,
const float *  line_2 
)

Definition at line 485 of file emdata_sparx.cpp.

References sqrt().

{
        double dis2 = 0.0;
        for( int i=0; i < lnlen; ++i ) {
                float tmp = line_1[lnlen-1-i] - line_2[i];
                dis2 += tmp*tmp;
        }
        return static_cast<float>(std::sqrt(dis2));
}
ostream& operator<< ( ostream &  os,
const Pixel peak 
)

Definition at line 5148 of file emdata_sparx.cpp.

References EMAN::Pixel::value, EMAN::Pixel::x, EMAN::Pixel::y, and EMAN::Pixel::z.

                                                     {
    os <<  peak.x <<  peak.y << peak.z  << peak.value;
    return os;
}
void swapx ( float *  a,
float *  b,
float *  temp,
size_t  nbytes 
) [inline]

Helper function for EMData::fft_shuffle, below.

Definition at line 4180 of file emdata_sparx.cpp.

Referenced by EMAN::EMData::fft_shuffle().

                                                                  {
        memcpy(temp, a, nbytes);
        memcpy(a, b, nbytes);
        memcpy(b, temp, nbytes);
}