EMAN::EMData Class Reference
[unit test in Python]

EMData stores an image's data and defines core image processing routines. More...

#include <emdata.h>

Collaboration diagram for EMAN::EMData:

Collaboration graph
[legend]

List of all members.

Public Types

enum  FFTPLACE { FFT_OUT_OF_PLACE, FFT_IN_PLACE }
enum  WINDOWPLACE { WINDOW_OUT_OF_PLACE, WINDOW_IN_PLACE }

Public Member Functions

void read_image (const string &filename, int img_index=0, bool header_only=false, const Region *region=0, bool is_3d=false)
 For all image I/O.
void write_image (const string &filename, int img_index=0, EMUtil::ImageType imgtype=EMUtil::IMAGE_UNKNOWN, bool header_only=false, const Region *region=0, EMUtil::EMDataType filestoragetype=EMUtil::EM_FLOAT, bool use_host_endian=true)
 write the header and data out to an image.
void append_image (const string &filename, EMUtil::ImageType imgtype=EMUtil::IMAGE_UNKNOWN, bool header_only=false)
 append to an image file; If the file doesn't exist, create one.
void write_lst (const string &filename, const string &reffile="", int refn=-1, const string &comment="")
 Append data to a LST image file.
void print_image (const string str=string(""), ostream &out=std::cout)
 Print the image data to a file stream (standard out by default).
EMDataget_fft_amplitude ()
 For anything read/set image's information.
EMDataget_fft_amplitude2D ()
 return the amplitudes of the 2D FFT including the left half PRB
Exceptions:
ImageFormatException If the image is not a complex image.

EMDataget_fft_phase ()
 return the phases of the FFT including the left half
float * get_data () const
 Get the image pixel density data in a 1D float array.
const float *const get_const_data () const
 Get the image pixel density data in a 1D float array - const version of get_data.
void set_data (float *data, const int x, const int y, const int z)
 Set the data explicitly data pointer must be allocated using malloc!
void write_data (string fsp, size_t loc, const Region *const area=0, const int file_nx=0, const int file_ny=0, const int file_nz=0)
 Dump the image pixel data in native byte order to a disk file.
void read_data (string fsp, size_t loc, const Region *area=0, const int file_nx=0, const int file_ny=0, const int file_nz=0)
 Read the image pixel data in native byte order from a disk file.
void update ()
 Mark EMData as changed, statistics, etc will be updated at need.
bool has_ctff () const
 check whether the image physical file has the CTF info or not.
float calc_center_density ()
 Calculates the density value at the peak of the image histogram, sort of like the mode of the density.
float calc_sigma_diff ()
 Calculates sigma above and below the mean and returns the difference between them.
IntPoint calc_min_location () const
 Calculates the coordinates of the minimum-value pixel.
IntPoint calc_max_location () const
 Calculates the coordinates of the maximum-value pixel.
IntPoint calc_max_location_wrap (const int maxshiftx=-1, const int maxshifty=-1, const int maxshiftz=-1)
 Calculates the wrapped coordinates of the maximum value This function is useful in the context of Fourier correlation you can call this function to find the correct translational shift when using calc_ccf etc.
FloatPoint calc_center_of_mass ()
 Calculate the center of mass using an algorithm written by S Ludtke.
int calc_min_index () const
 Calculates the index of minimum-value pixel when assuming all pixels are in a 1D array.
int calc_max_index () const
 Calculates the index of maximum-value pixel when assuming all pixels are in a 1D array.
vector< Pixelcalc_highest_locations (float threshold)
 Calculate and return a sorted list of pixels whose values are above a specified threshold.
float get_edge_mean () const
 Calculates the mean pixel values around the (1 pixel) edge of the image.
float get_circle_mean ()
 Calculates the circular edge mean by applying a circular mask on 'this' image.
Ctfget_ctf () const
 Get ctf parameter of this image.
void set_ctf (Ctf *ctf)
 Set the CTF parameter of this image.
Vec3f get_translation () const
 Get 'this' image's translation vector from the original location.
void set_translation (const Vec3f &t)
 Set 'this' images' translation vector from the original location.
void set_translation (float dx, float dy, float dz)
 Set 'this' images' translation vector from the original location.
Transform3D get_transform () const
 Get the 3D orientation of 'this' image.
void set_rotation (float az, float alt, float phi)
 Define the 3D orientation of this particle, also used to indicate relative rotations for reconstructions.
void set_rotation (const Transform3D &t3d)
 Define the 3D orientation of this particle Orientation information is extracted from a Transform3D object and stored internally in EMAN (az,alt,phi) format.
void set_size (int nx, int ny=1, int nz=1)
 Resize this EMData's main board memory pointer.
void set_complex_size (int nx, int ny=1, int nz=1)
 Resize 'this' complex image.
void set_path (const string &new_path)
 Set the path.
void set_pathnum (int n)
 Set the number of paths.
MArray2D get_2dview () const
 Get image raw pixel data in a 2D multi-array format.
MArray3D get_3dview () const
 Get image raw pixel data in a 3D multi-array format.
MCArray2D get_2dcview () const
 Get complex image raw pixel data in a 2D multi-array format.
MCArray3D get_3dcview () const
 Get complex image raw pixel data in a 3D multi-array format.
MCArray3Dget_3dcviewptr () const
 Get pointer to a complex image raw pixel data in a 3D multi-array format.
MArray2D get_2dview (int x0, int y0) const
 Get image raw pixel data in a 2D multi-array format.
MArray3D get_3dview (int x0, int y0, int z0) const
 Get image raw pixel data in a 3D multi-array format.
MCArray2D get_2dcview (int x0, int y0) const
 Get complex image raw pixel data in a 2D multi-array format.
MCArray3D get_3dcview (int x0, int y0, int z0) const
 Get complex image raw pixel data in a 3D multi-array format.
EMObject get_attr (const string &attr_name) const
 The generic way to get any image header information given a header attribute name.
EMObject get_attr_default (const string &attr_name, const EMObject &em_obj=EMObject()) const
 The generic way to get any image header information given a header attribute name.
void set_attr (const string &key, EMObject val)
 Set a header attribute's value.
void set_attr_python (const string &key, EMObject val)
 Set a header attribute's value from Python.
bool has_attr (const string &key) const
 Ask if the header has a particular attribute.
Dict get_attr_dict () const
 Get the image attribute dictionary containing all the image attribute names and attribute values.
void set_attr_dict (const Dict &new_dict)
 Merge the new values with the existing dictionary.
void del_attr (const string &attr_name)
 Delete the attribute from dictionary.
void del_attr_dict (const vector< string > &del_keys)
 Delete the attributes from the dictionary.
int get_xsize () const
 Get the image x-dimensional size.
int get_ysize () const
 Get the image y-dimensional size.
int get_zsize () const
 Get the image z-dimensional size.
size_t get_size () const
 Get the number of allocated floats in the image (nx*ny*nz).
vector< float > get_data_as_vector () const
 Get the pixel data as a vector.
int get_ndim () const
 Get image dimension.
bool is_shuffled () const
 Has this image been shuffled?
bool is_FH () const
 Is this a FH image?
bool is_complex () const
 Is this a complex image?
bool is_real () const
 Is this a real image?
void set_shuffled (bool is_shuffled)
 Mark this image as a shuffled image.
void set_FH (bool is_FH)
 Mark this complex image as a FH image.
void set_complex (bool is_complex)
 Mark this image as a complex image.
bool is_complex_x () const
 Is this image a 1D FFT image in X direction?
void set_complex_x (bool is_complex_x)
 Marks this image a 1D FFT image in X direction.
bool is_flipped () const
 Is this image flipped?
void set_flipped (bool is_flipped)
 Mark this image as flipped.
bool is_ri () const
 Is this image a real/imaginary format complex image?
void set_ri (bool is_ri)
 Mark this image as a real/imaginary format complex image.
bool is_fftpadded () const
 Is this image already extended along x for ffts?
void set_fftpad (bool is_fftpadded)
 Mark this image as already extended along x for ffts.
bool is_fftodd () const
 Does this image correspond to a (real-space) odd nx?
void set_fftodd (bool is_fftodd)
 Mark this image as having (real-space) odd nx.
void set_nxc (int nxc)
 Set the number of complex elements along x.
int get_flags () const
void set_flags (int f)
int get_changecount () const
void set_changecount (int c)
int get_xoff () const
int get_yoff () const
int get_zoff () const
void set_xyzoff (int x, int y, int z)
void scale_pixel (float scale_factor) const
 Scale the angstrom per pixel of this image by a uniform amount Alters the EMData metadata I had to make this function public for access from the Processors (David Woolford).
string get_path () const
int get_pathnum () const
std::string get_data_pickle () const
void set_data_pickle (std::string vf)
int get_supp_pickle () const
void set_supp_pickle (int i)
vector< Vec3imask_contig_region (const float &val, const Vec3i &seed)
void process_inplace (const string &processorname, const Dict &params=Dict())
 For modular class functions, process, align, etc.
void process_inplace (Processor *p)
 Call the process_inplace with an instance od Processor, usually this instancecan be get by (in Python) Processors.get("name", {'k':v, 'k':v}).
EMDataprocess (const string &processorname, const Dict &params=Dict()) const
 Apply a processor with its parameters on a copy of this image, return result as a a new image.
EMDataprocess (Processor *p) const
 Call the process with an instance od Processor, usually this instance can be get by (in Python) Processors.get("name", {'k':v, 'k':v}).
float cmp (const string &cmpname, EMData *with, const Dict &params=Dict())
 Compare this image with another image.
EMDataalign (const string &aligner_name, EMData *to_img, const Dict &params=Dict(), const string &cmp_name="dot", const Dict &cmp_params=Dict())
 Align this image with another image and return the result image.
vector< Dictxform_align_nbest (const string &aligner_name, EMData *to_img, const Dict &params=Dict(), const unsigned int nsoln=1, const string &cmp_name="dot", const Dict &cmp_params=Dict())
 Align this image with another image, return the parameters of the "n best" solutions See Aligner::xform_align_nbest for more comments.
EMDataproject (const string &projector_name, const Dict &params=Dict())
 Calculate the projection of this image and return the result.
EMDataproject (const string &projector_name, const Transform &t3d)
 Calculate the projection of this image and return the result.
EMDatabackproject (const string &projector_name, const Dict &params=Dict())
 Calculate the backprojection of this image (stack) and return the result.
EMDatado_fft () const
 For fft, wavelet, insert data.
EMDatado_fft_inplace ()
 Do FFT inplace.
EMDatado_ift ()
 return the inverse fourier transform (IFT) image of the current image.
EMDatado_ift_inplace ()
std::string render_amp8 (int x, int y, int xsize, int ysize, int bpl, float scale, int min_gray, int max_gray, float min_render, float max_render, float gamma, int flags)
 Render the image into an 8-bit image.
std::string render_ap24 (int x, int y, int xsize, int ysize, int bpl, float scale, int min_gray, int max_gray, float min_render, float max_render, float gamma, int flags)
 Render the image into an 8-bit image.
void render_amp24 (int x, int y, int xsize, int ysize, int bpl, float scale, int min_gray, int max_gray, float min_render, float max_render, void *ref, void cmap(void *, int coord, unsigned char *tri))
 Render the image into a 24-bit image.
void ri2ap ()
 convert the complex image from real/imaginary to amplitude/phase
void ap2ri ()
 convert the complex image from amplitude/phase to real/imaginary
void ri2inten ()
 convert the complex image from real/imaginary to Intensity/0.
EMDatabispecRotTransInvN (int N, int NK)
 This computes the rotational and translational bispectral invariants of an image.
EMDatabispecRotTransInvDirect (int type=0)
 This computes the rotational and translational bispectral invariants of an image.
void insert_clip (const EMData *const block, const IntPoint &origin)
 Insert a clip into this image.
void insert_scaled_sum (EMData *block, const FloatPoint &center, float scale=1.0, float mult_factor=1.0)
 Add a scaled image into another image at a specified location.
EMDatacopy () const
 For get/set values, basic math operations, operators.
EMDatacopy_head () const
 Make an image with a copy of the current image's header.
void add (float f, int keepzero=0)
 add a number to each pixel value of the image.
void add (const EMData &image)
 add a same-size image to this image pixel by pixel.
void addsquare (const EMData &image)
 add the squared value of each pixel from a same-size image to this image.
void sub (float f)
 subtract a float number to each pixel value of the image.
void sub (const EMData &image)
 subtract a same-size image from this image pixel by pixel.
void subsquare (const EMData &image)
 subtract the squared value of each pixel from a same-size image to this image.
void mult (int n)
 multiply an integer number to each pixel value of the image.
void mult (float f)
 multiply a float number to each pixel value of the image.
void mult (const EMData &image, bool prevent_complex_multiplication=false)
 multiply each pixel of this image with each pixel of some other same-size image.
void mult_complex_efficient (const EMData &em, const int radius)
void div (float f)
 make each pixel value divided by a float number.
void div (const EMData &image)
 make each pixel value divided by pixel value of another same-size image.
void to_zero ()
 Set all the pixel value = 0.
void to_one ()
 set all the pixel values = 1.
void to_value (const float &value)
 set all the pixel values to a value.
float dot (EMData *with)
 Dot product 2 images.
EMDataget_row (int row_index) const
 Get one row of a 1D/2D image.
void set_row (const EMData *data, int row_index)
 Set one row of a 1D/2D image.
EMDataget_col (int col_index) const
 Get one column of a 2D images.
void set_col (const EMData *data, int col_index)
 Set one column of a 2D image.
float get_value_at (int x, int y, int z) const
 Get the pixel density value at coordinates (x,y,z).
float get_value_at (int x, int y) const
 Get the pixel density value at coordinates (x,y).
float get_value_at (size_t i) const
 Get the pixel density value given an index 'i' assuming the pixles are stored in a 1D array.
std::complex< float > get_complex_at (int x, int y)
 Get complex<float> value at x,y.
float get_value_at_wrap (int x, int y, int z) const
 Get the pixel density value at coordinates (x,y,z).
float & get_value_at_wrap (int x, int y, int z)
float get_value_at_wrap (int x, int y) const
 Get the pixel density value at coordinates (x,y).
float & get_value_at_wrap (int x, int y)
float get_value_at_wrap (int x) const
 Get the pixel density value at coordinates (x).
float & get_value_at_wrap (int x)
float sget_value_at (int x, int y, int z) const
 A safer, slower way to get the pixel density value at coordinates (x,y,z).
float sget_value_at (int x, int y) const
 A safer, slower way to get the pixel density value at coordinates (x,y).
float sget_value_at (size_t i) const
 A safer, slower way to get the pixel density value given an index 'i' assuming the pixles are stored in a 1D array.
float sget_value_at_interp (float x, float y) const
 Get pixel density value at interpolation of (x,y).
float sget_value_at_interp (float x, float y, float z) const
 Get the pixel density value at interpolation of (x,y,z).
void set_value_at (int x, int y, int z, float v)
 Set the pixel density value at coordinates (x,y,z).
void set_value_at_fast (int x, int y, int z, float v)
 Set the pixel density value at coordinates (x,y,z).
void set_value_at (int x, int y, float v)
 Set the pixel density value at coordinates (x,y).
void set_value_at_fast (int x, int y, float v)
 Set the pixel density value at coordinates (x,y).
void set_value_at (int x, float v)
 Set the pixel density value at coordinate (x).
void set_value_at_fast (int x, float v)
 Set the pixel density value at coordinate (x).
void free_memory ()
 Free memory associated with this EMData Called in destructor and in assignment operator.
EMDataoperator+= (float n)
EMDataoperator-= (float n)
EMDataoperator*= (float n)
EMDataoperator/= (float n)
EMDataoperator+= (const EMData &em)
EMDataoperator-= (const EMData &em)
EMDataoperator*= (const EMData &em)
EMDataoperator/= (const EMData &em)
bool operator== (const EMData &that) const
float & operator() (const int ix, const int iy, const int iz) const
 Overload operator() for array indexing.
float & operator() (const int ix, const int iy) const
float & operator() (const int ix) const
void set_array_offsets (const int xoff_=0, const int yoff_=0, const int zoff_=0)
 Set the array offsets.
void set_array_offsets (vector< int > offsets)
vector< int > get_array_offsets ()
std::complex< float > & cmplx (const int ix, const int iy, const int iz)
 Return reference to complex elements.
std::complex< float > & cmplx (const int ix, const int iy)
std::complex< float > & cmplx (const int ix)
EMDatapower (int n) const
 return a image to the power of n
EMDatasqrt () const
 return square root of current image
EMDatalog () const
 return natural logarithm image for a image
EMDatalog10 () const
 return base 10 logarithm image for a image
EMDatareal () const
 return real part of a complex image as a real image format, if this image is a real image, return a copy of this image.
EMDataimag () const
 return imaginary part of a complex image as a real image format.
EMDataabsi () const
 For a real image, it returns a same size image with abs() of each pixel.
EMDataamplitude () const
 return amplitude part of a complex image as a real image format
EMDataphase () const
 return phase part of a complex image as a real image format
EMDatareal2complex (float img=0.0f) const
 create a complex image from a real image, this complex image is in real/imaginary format
EMDatareal2FH (float OverSamplekB)
 This is the header of EMData stay in sparx directory.
EMDataFH2F (int Size, float OverSamplekB, int IntensityFlag=0)
 returns the fourier version of the image from the FH version.
EMDataFH2Real (int Size, float OverSamplekB, int IntensityFlag=0)
 returns the real version of the image from the FH version.
EMDatarotavg ()
 Create a (1-D) rotationally averaged image.
EMDatarotavg_i ()
 Create a 2-D or 3-D rotationally averaged image.
EMDatamult_radial (EMData *radial)
 Multiply radially a 2-D or 3-D image by a 1-D image.
vector< float > cog ()
 Calculates the Center of Gravity and the Radius of Gyration of the image.
vector< float > calc_fourier_shell_correlation (EMData *with, float w=1.0f)
 Calculate CCF in Fourier space as a function of spatial frequency between a pair of 2-3D images (corners not included).
EMDataaverage_circ_sub () const
 Subtract average outside of a circle.
void onelinenn (int j, int n, int n2, EMData *wptr, EMData *bi, const Transform &tf)
 Helper function for method nn.
void onelinenn_mult (int j, int n, int n2, EMData *wptr, EMData *bi, const Transform &tf, int mult)
void nn (EMData *wptr, EMData *myfft, const Transform &tf, int mult=1)
 Nearest Neighbor interpolation.
void nn_SSNR (EMData *wptr, EMData *wptr2, EMData *myfft, const Transform &tf, int mult=1)
 Nearest Neighbor interpolation, meanwhile return necessary data such as Kn, sum_k(F_k^n) ans sum_k(|F_k^n|^2) Modifies the current object.
void nn_SSNR_ctf (EMData *wptr, EMData *wptr2, EMData *wptr3, EMData *myfft, const Transform &tf, int mult=1)
 Nearest Neighbor interpolation, meanwhile return necessary data such as Kn, sum_k(F_k^n) ans sum_k(|F_k^n|^2) Modifies the current object.
void symplane0 (EMData *norm)
 Calculate Spectrum signal noise ratio (SSNR) accounting CTF correction a.
void symplane1 (EMData *norm, EMData *norm2)
 Symmetrize plane 0 Modifies the current object.
void symplane2 (EMData *norm, EMData *norm2, EMData *norm3)
 Symmetrize plane 0 Modifies the current object.
void onelinenn_ctf (int j, int n, int n2, EMData *w, EMData *bi, const Transform &tf, int mult)
 Helper function for method nn4_ctf.
void nn_ctf (EMData *w, EMData *myfft, const Transform &tf, int mult)
 Nearest Neighbor interpolation.
void onelinenn_ctf_applied (int j, int n, int n2, EMData *w, EMData *bi, const Transform &tf, int mult)
 Helper function for method nn4_ctf.
void nn_ctf_applied (EMData *w, EMData *myfft, const Transform &tf, int mult)
 Nearest Neighbor interpolation.
void symplane0_ctf (EMData *w)
 Symmetrize plane 0 Modifies the current object.
EMDatasymvol (string symmetry)
 Symmetrize volume in real space.
EMDatarot_scale_trans2D (float ang, float delx=0.0f, float dely=0.0f, float scale=1.0f)
 Rotate-Shift-Scale-Circulantly image.
EMDatarot_scale_trans2D_background (float ang, float delx=0.0f, float dely=0.0f, float scale=1.0f)
 Rotate-Shift-Scale image.
EMDatarot_scale_trans (const Transform &RA)
 Rotate-Shift-Scale-Circulantly image.
EMDatarot_scale_trans_background (const Transform &RA)
 Rotate-Shift-Scale image.
float cm_euc (EMData *sinoj, int n1, int n2)
 euclidean distance between two line
EMDatarot_scale_conv (float ang, float delx, float dely, Util::KaiserBessel &kb, float scale=1.0)
 Rotate-Shift-Scale-Circulantly image using convolution.
EMDatadownsample (Util::sincBlackman &kb, float scale=1.0)
EMDatarot_scale_conv7 (float ang, float delx, float dely, Util::KaiserBessel &kb, float scale_input)
EMDatarot_scale_conv_new (float ang, float delx, float dely, Util::KaiserBessel &kb, float scale=1.0)
EMDatarot_scale_conv_new_background (float ang, float delx, float dely, Util::KaiserBessel &kb, float scale=1.0)
float get_pixel_conv (float delx, float dely, float delz, Util::KaiserBessel &kb)
 Get pixel value image using convolution.
float get_pixel_filtered (float delx, float dely, float delz, Util::sincBlackman &kb)
float get_pixel_conv7 (float delx, float dely, float delz, Util::KaiserBessel &kb)
float getconvpt2d_kbi0 (float x, float y, Util::KaiserBessel::kbi0_win win, int size=7)
 Value of 2-D analytic masking (or 2-D convolution) at off-grid point.
void fft_shuffle ()
 2-D rotation using gridding convolution.
void pad_corner (float *pad_image)
void shuffle_pad_corner (float *pad_image)
std::complex< float > extractpoint (float xin, float yin, Util::KaiserBessel &kb)
 extractpoint -- Gridding convolution
EMDataextract_plane (const Transform &tf, Util::KaiserBessel &kb)
 extractplane -- Gridding convolution in 3D along a plane
EMDatafouriergridrot2d (float ang, float scale, Util::KaiserBessel &kb)
EMDatafouriergridrot_shift2d (float ang, float sx, float sy, Util::KaiserBessel &kb)
void divkbsinh (const Util::KaiserBessel &kb)
 divkbsinh -- Divide image by a Kaiser-Bessel sinh window.
vector< float > max_search ()
 masked_stats -- Compute image statistics under a mask
vector< float > peak_search (int ml, float invert)
vector< float > phase_cog ()
 Calculate the Phase approximation to center of gravity This operations works for 1-2-3-d images.
float find_3d_threshold (float mass, float pixel_size)
vector< float > peak_ccf (float hf_p)
 Peak (with a radius of hf_p) search for particle picking:.
EMDataget_pow (float n_pow)
EMDataconjg ()
EMDataextractline (Util::KaiserBessel &kb, float nuxnew, float nuynew)
EMDatadelete_disconnected_regions (int ix=0, int iy=0, int iz=0)
 Delete disconnected regions in a binary image.
EMDatahelicise (float pixel_size, float dp, float dphi, float section_use=1.0f, float radius=-1.0f)
 Apply helical symmetry.
void depad ()
 De-pad, and and remove Fourier extension convenience function.
void depad_corner ()
 De-pad, and and remove Fourier extension convenience function.
EMDatanorm_pad (bool do_norm, int npad=1, int valtype=0)
 Normalize, pad, and Fourier extend convenience function.
void center_origin ()
void center_origin_yz ()
void center_origin_fft ()
 Multiply a Fourier image by (-1)**(ix+iy+iz) to center it.
EMDataFourInterpol (int nxni, int nyni=0, int nzni=0, bool RetReal=true)
EMDataFourTruncate (int nxni, int nyni=0, int nzni=0, bool RetReal=true)
 Truncate Fourier transform of an image, it will reduce its size.
EMDataFour_ds (int nxni, int nyni=0, int nzni=0, bool RetReal=true)
EMDataFour_shuf_ds_cen_us (int nxni, int nyni=0, int nzni=0, bool RetReal=true)
EMDatafilter_by_image (EMData *image, bool RetReal=true)
EMDatareplace_amplitudes (EMData *image, bool RetReal=true)
 EMData ()
 Construct an empty EMData instance.
 ~EMData ()
 EMData (const string &filename, int image_index=0)
 Construct from an image file.
 EMData (int nx, int ny, int nz=1, bool is_real=true)
 # makes an image of the specified size, either real or complex.
 EMData (float *data, const int nx, const int ny, const int nz, const Dict &attr_dict=Dict())
 Construction from a data pointer, dimensions must be supplied.
 EMData (const EMData &that)
 Construct from an EMData (copy constructor).
EMDataoperator= (const EMData &that)
 EMData assignment operator Performs a deep copy.
EMDataget_clip (const Region &area, const float fill=0) const
 Do the Fourier Harmonic Transform PRB Takes a real image, returns the FH Sets the EMDATA_FH switch to indicate that it is an FH image
Exceptions:
ImageFormatException If the image is not a square real odd image.

void clip_inplace (const Region &area, const float &fill_value=0)
 Clip the image inplace - clipping region must be smaller than the current region internally memory is reallocated
Exceptions:
ImageDimensionException if any of the dimensions of the argument region are negative.

EMDataget_top_half () const
 Get the top half of this 3D image.
EMDataget_rotated_clip (const Transform &xform, const IntSize &size, float scale=1.0)
 Get the normalization and phase residual values Used for normalizaton and error measurement when 2D slices are inserted into a 3D volume of Fourier pixels Originally added for use by the FourierReconstructor object.
EMDatawindow_center (int l)
 Window the center of an image.
float * setup4slice (bool redo=true)
 Set up for fftslice operations.
void scale (float scale_factor)
 scale the image by a factor.
void translate (float dx, float dy, float dz)
 Translate this image.
void translate (const Vec3f &translation)
 Translate this image.
void translate (int dx, int dy, int dz)
 Translate this image.
void translate (const Vec3i &translation)
 Translate this image.
void rotate (const Transform3D &t)
 Rotate this image.
void rotate (float az, float alt, float phi)
 Rotate this image.
void rotate_translate (const Transform3D &t)
 Rotate then translate the image.
void transform (const Transform &t)
 Transform the image.
void rotate_translate (const Transform &t)
 Apply a transformation to the image.
void rotate_translate (float az, float alt, float phi, float dx, float dy, float dz)
 Rotate then translate the image.
void rotate_translate (float az, float alt, float phi, float dx, float dy, float dz, float pdx, float pdy, float pdz)
 Rotate then translate the image.
void rotate_x (int dx)
 This performs a translation of each line along x with wraparound.
void rotate_180 ()
 Fast rotation by 180 degrees.
double dot_rotate_translate (EMData *with, float dx, float dy, float da, const bool mirror=false)
 dot product of 2 images.
EMDatalittle_big_dot (EMData *little_img, bool do_sigma=false)
 This does a normalized dot product of a little image with a big image using real-space methods.
EMDatado_radon ()
 Radon Transform: an algorithm that transforms an original image into a series of equiangular projections.
EMDatacalc_ccf (EMData *with, fp_flag fpflag=CIRCULANT, bool center=false)
 Calculate Cross-Correlation Function (CCF).
void zero_corner_circulant (const int radius=0)
 Zero the pixels in the bottom left corner of the image If radius is greater than 1, than circulant zeroing occurs assuming that the center of operation starts in the bottom left corner and proceed outwards to the NE and backwards in a circulant fashion towards the SW.
EMDatacalc_ccfx (EMData *const with, int y0=0, int y1=-1, bool nosum=false)
 Calculate Cross-Correlation Function (CCF) in the x-direction and adds them up, result in 1D.
EMDatamake_rotational_footprint (bool unwrap=true)
 Makes a 'rotational footprint', which is an 'unwound' autocorrelation function.
EMDatamake_rotational_footprint_e1 (bool unwrap=true)
EMDatamake_rotational_footprint_cmc (bool unwrap=true)
EMDatamake_footprint (int type=0)
 Makes a 'footprint' for the current image.
EMDatacalc_mutual_correlation (EMData *with, bool tocorner=false, EMData *filter=0)
 Calculates mutual correlation function (MCF) between 2 images.
EMDataunwrap (int r1=-1, int r2=-1, int xs=-1, int dx=0, int dy=0, bool do360=false, bool weight_radial=true) const
 Maps to polar coordinates from Cartesian coordinates.
void apply_radial_func (float x0, float dx, vector< float >array, bool interp=true)
 multiplies by a radial function in fourier space.
vector< float > calc_radial_dist (int n, float x0, float dx, bool inten)
 calculates radial distribution.
vector< float > calc_radial_dist (int n, float x0, float dx, int nwedge, bool inten)
 calculates radial distribution subdivided by angle.
void cconj ()
 Replace the image its complex conjugate.
void add_incoherent (EMData *obj)
 Adds 'obj' to 'this' incoherently.
vector< float > calc_hist (int hist_size=128, float hist_min=0, float hist_max=0, const float &brt=0.0f, const float &cont=1.0f)
 Calculates the histogram of 'this' image.
vector< float > calc_az_dist (int n, float a0, float da, float rmin, float rmax)
 Caculates the azimuthal distributions.
float calc_dist (EMData *second_img, int y_index=0) const
 Calculates the distance between 2 vectors.
EMDatacalc_flcf (EMData *with)
 Calculates the cross correlation with local normalization between 2 images.
EMDatacalc_fast_sigma_image (EMData *mask)
 Calculates the local standard deviation (sigma) image using the given mask image.
EMDataconvolute (EMData *with)
 Convolutes 2 data sets.
void common_lines (EMData *image1, EMData *image2, int mode=0, int steps=180, bool horizontal=false)
 Finds common lines between 2 complex images.
void common_lines_real (EMData *image1, EMData *image2, int steps=180, bool horizontal=false)
 Finds common lines between 2 real images.
void cut_slice (const EMData *const map, const Transform &tr, bool interpolate=true)
 cut a 2D slice out of a real 3D map.
void uncut_slice (EMData *const map, const Transform &tr) const
 cut a 2D slice out of a this 3D image and return it An alternative to cut_slice
int getResolution () const
 function for MarchingCubes, for 3D image display
void debug_print_parms ()
 Printing EMData params for debugging purpose.
void set_xyz_origin (float origin_x, float origin_y, float origin_z)
 Set the x,y,z origin of the image.

Static Public Member Functions

static vector< EMData * > read_images (const string &filename, vector< int >img_indices=vector< int >(), bool header_only=false)
 Read a set of images from file specified by 'filename'.
static vector< EMData * > read_images_ext (const string &filename, int img_index_start, int img_index_end, bool header_only=false, const string &ext="")
 Read a set of images from file specified by 'filename'.
static float restrict1 (float x, int nx)
static float restrict2 (float x, int nx)

Static Public Attributes

static int totalalloc = 0

Private Types

enum  EMDataFlags {
  EMDATA_BUSY = 1 << 3, EMDATA_HASCTFF = 1 << 4, EMDATA_NEEDUPD = 1 << 5, EMDATA_FLIP = 1 << 7,
  EMDATA_PAD = 1 << 8, EMDATA_FFTODD = 1 << 9, EMDATA_SHUFFLE = 1 << 10, EMDATA_FH = 1 << 11,
  EMDATA_CPU_NEEDS_UPDATE = 1 << 12, EMDATA_GPU_NEEDS_UPDATE = 1 << 13, EMDATA_GPU_RO_NEEDS_UPDATE = 1 << 14
}
 This EMDataFlags is deprecated. More...

Private Member Functions

void set_attr_dict_explicit (const Dict &new_dict)
 Make the attributes of this EMData exactly equal to the argument dictionary Originally introduced because set_attr_dict does automatic resizing, which is undersirable in some circumstances.
void update_stat () const
void save_byteorder_to_dict (ImageIO *imageio)

Static Private Member Functions

static bool peakcmp (const Pixel &p1, const Pixel &p2)

Private Attributes

Dict attr_dict
 to store all image header info
float * rdata
 image real data
float * supp
 supplementary data array
int flags
 CTF data All CTF data become attribute ctf(vector<float>) in attr_dict --Grant Tang.
int changecount
int nx
 image size
int ny
int nz
int nxy
int xoff
 array index offsets
int yoff
int zoff
Vec3f all_translation
 translation from the original location
string path
int pathnum
EMDatarot_fp
 This is a cached rotational footprint, can save much time.

Friends

class GLUtil

Classes

class  ClipInplaceVariables


Detailed Description

EMData stores an image's data and defines core image processing routines.

The image is 1D, 2D or 3D, in real space or fourier space (complex image).

Data are ordered with x increasing fastest, then y, then z.

Definition at line 88 of file emdata.h.


Member Enumeration Documentation

Enumerator:
FFT_OUT_OF_PLACE 
FFT_IN_PLACE 

Definition at line 2954 of file emdata.h.

Enumerator:
WINDOW_OUT_OF_PLACE 
WINDOW_IN_PLACE 

Definition at line 2955 of file emdata.h.

enum EMAN::EMData::EMDataFlags [private]

This EMDataFlags is deprecated.

For anything which is currently handled by setting a bit in 'flags', instead, set or read an appropriately named attribute in the attributes dictionary. While there is a small overhead in the string lookup, none of these things should be called in the innermost loop anywhere, so it should be fine. --Grant

Enumerator:
EMDATA_BUSY 
EMDATA_HASCTFF 
EMDATA_NEEDUPD 
EMDATA_FLIP 
EMDATA_PAD 
EMDATA_FFTODD 
EMDATA_SHUFFLE 
EMDATA_FH 
EMDATA_CPU_NEEDS_UPDATE 
EMDATA_GPU_NEEDS_UPDATE 
EMDATA_GPU_RO_NEEDS_UPDATE 

Definition at line 3684 of file emdata.h.


Constructor & Destructor Documentation

EMData::EMData (  ) 

Construct an empty EMData instance.

It has no image data.

Definition at line 71 of file emdata.cpp.

References attr_dict, EMAN::EMUtil::EM_FLOAT, ENTERFUNC, and totalalloc.

Referenced by absi(), amplitude(), bispecRotTransInvDirect(), bispecRotTransInvN(), calc_ccfx(), calc_fast_sigma_image(), calc_flcf(), copy(), copy_head(), do_radon(), EMData(), extract_plane(), extractline(), get_circle_mean(), get_clip(), get_col(), get_rotated_clip(), get_row(), get_top_half(), imag(), make_footprint(), make_rotational_footprint(), make_rotational_footprint_cmc(), make_rotational_footprint_e1(), operator=(), phase(), read_images(), read_images_ext(), real(), real2complex(), rotavg(), rotavg_i(), and unwrap().

00071                :
00072 #ifdef EMAN2_USING_CUDA
00073                 cuda_cache_handle(-1),
00074 #endif //EMAN2_USING_CUDA
00075                 attr_dict(), rdata(0), supp(0), flags(0), changecount(0), nx(0), ny(0), nz(0), nxy(0), xoff(0), yoff(0),
00076                 zoff(0), all_translation(),     path(""), pathnum(0), rot_fp(0)
00077 
00078 {
00079         ENTERFUNC;
00080 
00081         attr_dict["apix_x"] = 1.0f;
00082         attr_dict["apix_y"] = 1.0f;
00083         attr_dict["apix_z"] = 1.0f;
00084 
00085         attr_dict["is_complex"] = int(0);
00086         attr_dict["is_complex_x"] = int(0);
00087         attr_dict["is_complex_ri"] = int(1);
00088 
00089         attr_dict["datatype"] = (int)EMUtil::EM_FLOAT;
00090 
00091         EMData::totalalloc++;
00092 #ifdef MEMDEBUG
00093         printf("EMDATA+  %4d    %p\n",EMData::totalalloc,this);
00094 #endif
00095 
00096 }

EMData::~EMData (  ) 

Definition at line 287 of file emdata.cpp.

References ENTERFUNC, EXITFUNC, free_memory(), and totalalloc.

00288 {
00289         ENTERFUNC;
00290         free_memory();
00291 #ifdef EMAN2_USING_CUDA
00292 //      cout << "Death comes to " << cuda_cache_handle << " " << this << endl;
00293         free_cuda_memory();
00294 #endif // EMAN2_USING_CUDA
00295         EMData::totalalloc--;
00296 #ifdef MEMDEBUG
00297         printf("EMDATA-  %4d    %p\n",EMData::totalalloc,this);
00298 #endif
00299         EXITFUNC;
00300 }

EMData::EMData ( const string &  filename,
int  image_index = 0 
) [explicit]

Construct from an image file.

Parameters:
filename the image file name
image_index the image index for stack image file, default 0

Definition at line 98 of file emdata.cpp.

References attr_dict, ENTERFUNC, EXITFUNC, read_image(), totalalloc, and update().

00098                                                       :
00099 #ifdef EMAN2_USING_CUDA
00100                 cuda_cache_handle(-1),
00101 #endif //EMAN2_USING_CUDA
00102                 attr_dict(), rdata(0), supp(0), flags(0), changecount(0), nx(0), ny(0), nz(0), nxy(0), xoff(0), yoff(0), zoff(0),
00103                 all_translation(),      path(filename), pathnum(image_index), rot_fp(0)
00104 {
00105         ENTERFUNC;
00106 
00107         attr_dict["apix_x"] = 1.0f;
00108         attr_dict["apix_y"] = 1.0f;
00109         attr_dict["apix_z"] = 1.0f;
00110 
00111         attr_dict["is_complex"] = int(0);
00112         attr_dict["is_complex_x"] = int(0);
00113         attr_dict["is_complex_ri"] = int(1);
00114 
00115         this->read_image(filename, image_index);
00116 
00117         update();
00118         EMData::totalalloc++;
00119 
00120         EXITFUNC;
00121 }

EMData::EMData ( int  nx,
int  ny,
int  nz = 1,
bool  is_real = true 
)

# makes an image of the specified size, either real or complex.

For complex image, the user would specify the real-space dimensions.

Parameters:
nx size for x dimension
ny size for y dimension
nz size for z dimension, default 1
is_real boolean to specify real(true) or complex(false) image, default real

Definition at line 215 of file emdata.cpp.

References attr_dict, ENTERFUNC, EXITFUNC, set_size(), to_zero(), totalalloc, and update().

00215                                                    :
00216 #ifdef EMAN2_USING_CUDA
00217                 cuda_cache_handle(-1),
00218 #endif //EMAN2_USING_CUDA
00219                 attr_dict(), rdata(0), supp(0), flags(0), changecount(0), nx(0), ny(0), nz(0), nxy(0), xoff(0), yoff(0), zoff(0),
00220                 all_translation(),      path(""), pathnum(0), rot_fp(0)
00221 {
00222         ENTERFUNC;
00223 
00224         // used to replace cube 'pixel'
00225         attr_dict["apix_x"] = 1.0f;
00226         attr_dict["apix_y"] = 1.0f;
00227         attr_dict["apix_z"] = 1.0f;
00228 
00229         if(is_real) {   // create a real image [nx, ny, nz]
00230                 attr_dict["is_complex"] = int(0);
00231                 attr_dict["is_complex_x"] = int(0);
00232                 attr_dict["is_complex_ri"] = int(1);
00233                 set_size(nx, ny, nz);
00234         }
00235         else {  //create a complex image which real dimension is [ny, ny, nz]
00236                 int new_nx = nx + 2 - nx%2;
00237                 set_size(new_nx, ny, nz);
00238 
00239                 attr_dict["is_complex"] = int(1);
00240 
00241                 if(ny==1 && nz ==1)     {
00242                         attr_dict["is_complex_x"] = int(1);
00243                 }
00244                 else {
00245                         attr_dict["is_complex_x"] = int(0);
00246                 }
00247 
00248                 attr_dict["is_complex_ri"] = int(1);
00249                 attr_dict["is_fftpad"] = int(1);
00250 
00251                 if(nx%2 == 1) {
00252                         attr_dict["is_fftodd"] = 1;
00253                 }
00254         }
00255 
00256         this->to_zero();
00257         update();
00258         EMData::totalalloc++;
00259 
00260         EXITFUNC;
00261 }

EMData::EMData ( float *  data,
const int  nx,
const int  ny,
const int  nz,
const Dict attr_dict = Dict() 
)

Construction from a data pointer, dimensions must be supplied.

Takes possession of the pointer. data pointer must be allocated using malloc!

Parameters:
data a pointer to the pixel data which is stored in memory. Takes possession
nx the number of pixels in the x direction
ny the number of pixels in the y direction
nz the number of pixels in the z direction
attr_dict attribute dictionary for this image

Definition at line 264 of file emdata.cpp.

References ENTERFUNC, EXITFUNC, totalalloc, and update().

00264                                                                                         :
00265 #ifdef EMAN2_USING_CUDA
00266                 cuda_cache_handle(-1),
00267 #endif //EMAN2_USING_CUDA
00268                 attr_dict(attr_dict), rdata(data), supp(0), flags(0), changecount(0), nx(x), ny(y), nz(z), nxy(x*y), xoff(0),
00269                 yoff(0), zoff(0), all_translation(), path(""), pathnum(0), rot_fp(0)
00270 {
00271         ENTERFUNC;
00272 
00273         // used to replace cube 'pixel'
00274         attr_dict["apix_x"] = 1.0f;
00275         attr_dict["apix_y"] = 1.0f;
00276         attr_dict["apix_z"] = 1.0f;
00277 
00278         EMData::totalalloc++;
00279 
00280         update();
00281         EXITFUNC;
00282 }


Member Function Documentation

void EMData::read_image ( const string &  filename,
int  img_index = 0,
bool  header_only = false,
const Region region = 0,
bool  is_3d = false 
)

For all image I/O.

$Id$ This file is a part of "emdata.h", to use functions in this file, you should "#include "emdata.h", NEVER directly include this file. read an image file and stores its information to this EMData object.

If a region is given, then only read a region of the image file. The region will be this EMData object. The given region must be inside the given image file. Otherwise, an error will be created.

Parameters:
filename The image file name.
img_index The nth image you want to read.
header_only To read only the header or both header and data.
region To read only a region of the image.
is_3d Whether to treat the image as a single 3D or a set of 2Ds. This is a hint for certain image formats which has no difference between 3D image and set of 2Ds.
Exceptions:
ImageFormatException 
ImageReadException 

Definition at line 48 of file emdata_io.cpp.

References attr_dict, ENTERFUNC, EXITFUNC, get_data(), EMAN::Region::get_depth(), EMAN::Region::get_height(), EMAN::EMUtil::get_imageio(), EMAN::Region::get_width(), EMAN::Dict::has_key(), ImageFormatException, ImageReadException, EMAN::ImageIO::is_complex_mode(), nx, ny, nz, EMAN::ImageIO::read_data(), EMAN::ImageIO::read_header(), EMAN::ImageIO::READ_ONLY, save_byteorder_to_dict(), set_complex(), set_fftodd(), set_fftpad(), set_ri(), set_size(), to_zero(), and update().

Referenced by EMAN::PCA::dopca_ooc(), EMAN::TestUtil::dump_image_from_file(), EMData(), EMAN::Util::eval(), EMAN::PCA::Lanczos_ooc(), main(), ParseAlignOptions(), EMAN::CoordinateMaskFileProcessor::process_inplace(), EMAN::IndexMaskFileProcessor::process_inplace(), read_images(), read_images_ext(), ReadStackandDist(), ReadStackandDist_Cart(), ReadVandBcast(), recons3d_4nn(), and EMAN::TestUtil::verify_image_file_by_mode().

00050 {
00051         ENTERFUNC;
00052 
00053         ImageIO *imageio = EMUtil::get_imageio(filename, ImageIO::READ_ONLY);
00054 
00055         if (!imageio) {
00056                 throw ImageFormatException("cannot create an image io");
00057         }
00058         else {
00059                 int err = imageio->read_header(attr_dict, img_index, region, is_3d);
00060                 if (err) {
00061                         throw ImageReadException(filename, "imageio read header failed");
00062                 }
00063                 else {
00064                         if (imageio->is_complex_mode()) {
00065                                 set_complex(true);
00066                                 set_fftpad(true);
00067                         }
00068                         if (attr_dict.has_key("is_fftodd") && (int)attr_dict["is_fftodd"] == 1) {
00069                                 set_fftodd(true);
00070                         }
00071                         if ((int) attr_dict["is_complex_ri"] == 1) {
00072                                 set_ri(true);
00073                         }
00074                         save_byteorder_to_dict(imageio);
00075 
00076                         nx = attr_dict["nx"];
00077                         ny = attr_dict["ny"];
00078                         nz = attr_dict["nz"];
00079 
00080 //                      if(attr_dict.has_key("ctf")) {
00081 //                              flags |= EMDATA_HASCTFF;
00082 //                      }
00083 //                      else {
00084 //                              flags &= ~EMDATA_HASCTFF;
00085 //                      }
00086 
00087                         if (!nodata) {
00088 
00089                                 if (region) {
00090                                         nx = (int)region->get_width();
00091                                         if (nx <= 0) nx = 1;
00092                                         ny = (int)region->get_height();
00093                                         if (ny <= 0) ny = 1;
00094                                         nz = (int)region->get_depth();
00095                                         if (nz <= 0) nz = 1;
00096                                         set_size(nx,ny,nz);
00097                                         to_zero(); // This could be avoided in favor of setting only the regions that were not read to to zero... but tedious
00098                                 } // else the dimensions of the file being read match those of this
00099                                 else {
00100                                         set_size(nx, ny, nz);
00101                                 }
00102 
00103                                 // If GPU features are enabled there is  danger that rdata will
00104                                 // not be allocated, but set_size takes care of this, so this
00105                                 // should be safe.
00106                                 int err = imageio->read_data(get_data(), img_index, region, is_3d);
00107                                 if (err) {
00108                                         throw ImageReadException(filename, "imageio read data failed");
00109                                 }
00110                                 else {
00111                                         update();
00112                                 }
00113                         }
00114                 }
00115         }
00116 
00117 #ifndef IMAGEIO_CACHE
00118         if( imageio )
00119         {
00120                 delete imageio;
00121                 imageio = 0;
00122         }
00123 #endif
00124         EXITFUNC;
00125 }

void EMData::write_image ( const string &  filename,
int  img_index = 0,
EMUtil::ImageType  imgtype = EMUtil::IMAGE_UNKNOWN,
bool  header_only = false,
const Region region = 0,
EMUtil::EMDataType  filestoragetype = EMUtil::EM_FLOAT,
bool  use_host_endian = true 
)

write the header and data out to an image.

If the img_index = -1, append the image to the given image file.

If the given image file already exists, this image format only stores 1 image, and no region is given, then truncate the image file to zero length before writing data out. For header writing only, no truncation happens.

If a region is given, then write a region only.

Parameters:
filename The image file name.
img_index The nth image to write as.
imgtype Write to the given image format type. if not specified, use the 'filename' extension to decide.
header_only To write only the header or both header and data.
region Define the region to write to.
filestoragetype The image data type used in the output file.
use_host_endian To write in the host computer byte order.
Exceptions:
ImageFormatException 
ImageWriteException 

Definition at line 129 of file emdata_io.cpp.

References attr_dict, changecount, ENTERFUNC, EXITFUNC, fft_shuffle(), EMAN::ImageIO::flush(), get_data(), EMAN::EMUtil::get_image_ext_type(), EMAN::EMUtil::get_imageio(), EMAN::ImageIO::get_nimg(), EMAN::EMUtil::IMAGE_LST, EMAN::EMUtil::IMAGE_LSTFAST, EMAN::EMUtil::IMAGE_PNG, EMAN::EMUtil::IMAGE_UNKNOWN, ImageFormatException, ImageWriteException, is_complex(), EMAN::Util::is_file_exist(), is_shuffled(), EMAN::ImageIO::is_single_image_format(), LOGVAR, nx, ny, nz, path, pathnum, EMAN::ImageIO::READ_ONLY, EMAN::ImageIO::READ_WRITE, UnexpectedBehaviorException, update_stat(), EMAN::ImageIO::write_data(), EMAN::ImageIO::write_header(), and EMAN::ImageIO::WRITE_ONLY.

Referenced by ali3d_d(), append_image(), bispecRotTransInvDirect(), bispecRotTransInvN(), EMAN::OptVarianceCmp::cmp(), EMAN::PCA::dopca_ooc(), EMAN::BaldwinWoolfordReconstructor::finish(), EMAN::FourierReconstructor::finish(), main(), EMAN::TestUtil::make_image_file_by_mode(), EMAN::AutoMask3DProcessor::process_inplace(), EMAN::LocalNormProcessor::process_inplace(), EMAN::WatershedProcessor::process_inplace(), unified(), and write_lst().

00134 {
00135         ENTERFUNC;
00136 
00137         struct stat fileinfo;
00138         if ( region && stat(filename.c_str(),&fileinfo) != 0 ) throw UnexpectedBehaviorException("To write an image using a region the file must already exist and be the correct dimensions");
00139 
00140         if (is_complex() && is_shuffled())
00141                 fft_shuffle();
00142 
00143         if (imgtype == EMUtil::IMAGE_UNKNOWN) {
00144                 const char *ext = strrchr(filename.c_str(), '.');
00145                 if (ext) {
00146                         ext++;
00147                         imgtype = EMUtil::get_image_ext_type(ext);
00148                 }
00149         }
00150         ImageIO::IOMode rwmode = ImageIO::READ_WRITE;
00151 
00152         //set "nx", "ny", "nz" and "changecount" in attr_dict, since they are taken out of attribute dictionary
00153         attr_dict["nx"] = nx;
00154         attr_dict["ny"] = ny;
00155         attr_dict["nz"] = nz;
00156         attr_dict["changecount"] = changecount;
00157 
00158         if (Util::is_file_exist(filename)) {
00159                 LOGVAR("file exists");
00160                 if (!header_only && region == 0) {
00161                         ImageIO * tmp_imageio = EMUtil::get_imageio(filename, ImageIO::READ_ONLY,
00162                                                                                                                 imgtype);
00163                         if (tmp_imageio->is_single_image_format()) {
00164                                 rwmode = ImageIO::WRITE_ONLY;
00165                         }
00166 #ifndef IMAGEIO_CACHE
00167                         if( tmp_imageio )
00168                         {
00169                                 delete tmp_imageio;
00170                                 tmp_imageio = 0;
00171                         }
00172 #endif
00173                 }
00174         }
00175         LOGVAR("getimageio %d",rwmode);
00176         ImageIO *imageio = EMUtil::get_imageio(filename, rwmode, imgtype);
00177         if (!imageio) {
00178                 throw ImageFormatException("cannot create an image io");
00179         }
00180         else {
00181                 update_stat();
00182                 if (img_index < 0) {
00183                         img_index = imageio->get_nimg();
00184                 }
00185                 LOGVAR("header write %d",img_index);
00186                 int err = imageio->write_header(attr_dict, img_index, region, filestoragetype,
00187                                                                                 use_host_endian);
00188                 if (err) {
00189                         throw ImageWriteException(filename, "imageio write header failed");
00190                 }
00191                 else {
00192                         if (!header_only) {
00193                                 if (imgtype == EMUtil::IMAGE_LST) {
00194                                         const char *reffile = attr_dict["LST.reffile"];
00195                                         if (strcmp(reffile, "") == 0) {
00196                                                 reffile = path.c_str();
00197                                         }
00198                                         int refn = attr_dict["LST.refn"];
00199                                         if (refn < 0) {
00200                                                 refn = pathnum;
00201                                         }
00202 
00203                                         const char *comment = attr_dict["LST.comment"];
00204                                         char *lstdata = new char[1024];
00205                                         sprintf(lstdata, "%d\t%s", refn, reffile);
00206                                         if(strcmp(comment, "") != 0) {
00207                                                 sprintf(lstdata+strlen(lstdata), "\t%s\n", comment);
00208                                         }
00209                                         else {
00210                                                 strcat(lstdata, "\n");
00211                                         }
00212                                         err = imageio->write_data((float*)lstdata, img_index,
00213                                                                                           region, filestoragetype, use_host_endian);
00214                                         if( lstdata )
00215                                         {
00216                                                 delete [] lstdata;
00217                                                 lstdata = 0;
00218                                         }
00219                                 }
00220                                 if (imgtype == EMUtil::IMAGE_LSTFAST) {
00221                                         const char *reffile = attr_dict["LST.reffile"];
00222                                         if (strcmp(reffile, "") == 0) {
00223                                                 reffile = path.c_str();
00224                                         }
00225                                         int refn = attr_dict["LST.refn"];
00226                                         if (refn < 0) {
00227                                                 refn = pathnum;
00228                                         }
00229 
00230                                         const char *comment = attr_dict["LST.comment"];
00231                                         char *lstdata = new char[1024];
00232                                         sprintf(lstdata, "%d\t%s", refn, reffile);
00233                                         if(strcmp(comment, "") != 0) {
00234                                                 sprintf(lstdata+strlen(lstdata), "\t%s\n", comment);
00235                                         }
00236                                         else {
00237                                                 strcat(lstdata, "\n");
00238                                         }
00239                                         err = imageio->write_data((float*)lstdata, img_index,
00240                                                                                           region, filestoragetype, use_host_endian);
00241                                         if( lstdata )
00242                                         {
00243                                                 delete [] lstdata;
00244                                                 lstdata = 0;
00245                                         }
00246                                 }
00247                                 else {
00248                                         err = imageio->write_data(get_data(), img_index, region, filestoragetype,
00249                                                                                           use_host_endian);
00250                                 }
00251                                 if (err) {
00252                                         imageio->flush();
00253                                         throw ImageWriteException(filename, "imageio write data failed");
00254                                 }
00255                         }
00256                 }
00257         }
00258         //PNG image already do cleaning in write_data function.
00259         if (!(imgtype == EMUtil::IMAGE_PNG)) {
00260                 imageio->flush();
00261         }
00262 
00263 #ifndef IMAGEIO_CACHE
00264         if( imageio )
00265         {
00266                 delete imageio;
00267                 imageio = 0;
00268         }
00269 #endif
00270 
00271 
00272 
00273         EXITFUNC;
00274 }

void EMData::append_image ( const string &  filename,
EMUtil::ImageType  imgtype = EMUtil::IMAGE_UNKNOWN,
bool  header_only = false 
)

append to an image file; If the file doesn't exist, create one.

Parameters:
filename The image file name.
imgtype Write to the given image format type. if not specified, use the 'filename' extension to decide.
header_only To write only the header or both header and data.

Definition at line 277 of file emdata_io.cpp.

References ENTERFUNC, EXITFUNC, and write_image().

Referenced by EMAN::IterationAverager::finish(), and main().

00279 {
00280         ENTERFUNC;
00281         write_image(filename, -1, imgtype, header_only, 0);
00282         EXITFUNC;
00283 }

void EMData::write_lst ( const string &  filename,
const string &  reffile = "",
int  refn = -1,
const string &  comment = "" 
)

Append data to a LST image file.

Parameters:
filename The LST image file name.
reffile Reference file name.
refn The reference file number.
comment The comment to the added reference file.
See also:
lstio.h

Definition at line 286 of file emdata_io.cpp.

References attr_dict, ENTERFUNC, EXITFUNC, EMAN::EMUtil::IMAGE_LST, and write_image().

00288 {
00289         ENTERFUNC;
00290         attr_dict["LST.reffile"] = reffile;
00291         attr_dict["LST.refn"] = refn;
00292         attr_dict["LST.comment"] = comment;
00293         write_image(filename, -1, EMUtil::IMAGE_LST, false);
00294         EXITFUNC;
00295 }

void EMData::print_image ( const string  str = string(""),
ostream &  out = std::cout 
)

Print the image data to a file stream (standard out by default).

Parameters:
out Output stream; cout by default.
str Message string to be printed.

Definition at line 298 of file emdata_io.cpp.

References get_xsize(), get_ysize(), get_zsize(), nx, ny, and nz.

00298                                                        {
00299         out << "Printing EMData object: " << str << std::endl;
00300         int nx = get_xsize();
00301         int ny = get_ysize();
00302         int nz = get_zsize();
00303         for (int iz = 0; iz < nz; iz++) {
00304                 out << "(z = " << iz << " slice)" << std::endl;
00305                 for (int ix = 0; ix < nx; ix++) {
00306                         for (int iy = 0; iy < ny; iy++) {
00307                                 out << setiosflags(std::ios::fixed)
00308                                         << setiosflags(std::ios_base::scientific)
00309                                         << std::setw(12)
00310                                          << std::setprecision(5) << (*this)(ix,iy,iz) << "  ";
00311                                 if (((iy+1) % 6) == 0) {
00312                                         out << std::endl << "   ";
00313                                 }
00314                         }
00315                         out << std::endl;
00316                 }
00317         }
00318 }

vector< EMData * > EMData::read_images ( const string &  filename,
vector< int >  img_indices = vector < int >(),
bool  header_only = false 
) [static]

Read a set of images from file specified by 'filename'.

Which images are read is set by 'img_indices'.

Parameters:
filename The image file name.
img_indices Which images are read. If it is empty, all images are read. If it is not empty, only those in this array are read.
header_only If true, only read image header. If false, read both data and header.
Returns:
The set of images read from filename.

Definition at line 320 of file emdata_io.cpp.

References EMData(), ENTERFUNC, EXITFUNC, EMAN::EMUtil::get_image_count(), ImageReadException, OutofRangeException, read_image(), and v.

00322 {
00323         ENTERFUNC;
00324 
00325         int total_img = EMUtil::get_image_count(filename);
00326         size_t num_img = img_indices.size();
00327 
00328         for (size_t i = 0; i < num_img; i++) {
00329                 if (img_indices[i] < 0 && img_indices[i] >= total_img) {
00330                         throw OutofRangeException(0, total_img, img_indices[i], "image index");
00331                 }
00332         }
00333 
00334         size_t n = (num_img == 0 ? total_img : num_img);
00335 
00336         vector<EMData* > v;
00337         for (size_t j = 0; j < n; j++) {
00338                 EMData *d = new EMData();
00339                 size_t k = (num_img == 0 ? j : img_indices[j]);
00340                 try {
00341                         d->read_image(filename, (int)k, header_only);
00342                 }
00343                 catch(E2Exception &e) {
00344                         if( d )
00345                         {
00346                                 delete d;
00347                                 d = 0;
00348                         }
00349                         throw(e);
00350                 }
00351                 if ( d != 0 )
00352                 {
00353                         v.push_back(d);
00354                 }
00355                 else
00356                         throw ImageReadException(filename, "imageio read data failed");
00357         }
00358 
00359         EXITFUNC;
00360         return v;
00361 }

vector< EMData * > EMData::read_images_ext ( const string &  filename,
int  img_index_start,
int  img_index_end,
bool  header_only = false,
const string &  ext = "" 
) [static]

Read a set of images from file specified by 'filename'.

If the given 'ext' is not empty, replace 'filename's extension it. Images with index from img_index_start to img_index_end are read.

Parameters:
filename The image file name.
img_index_start Starting image index.
img_index_end Ending image index.
header_only If true, only read image header. If false, read both data and header.
ext The new image filename extension.
Returns:
The set of images read from filename.

Definition at line 364 of file emdata_io.cpp.

References EMData(), ENTERFUNC, EXITFUNC, EMAN::EMUtil::get_image_count(), InvalidValueException, OutofRangeException, read_image(), and v.

00367 {
00368         ENTERFUNC;
00369 
00370         if (img_index_end < img_index_start) {
00371                 throw InvalidValueException(img_index_end, "image index end < image index start");
00372         }
00373         string new_filename = filename;
00374         new_filename = new_filename.insert(new_filename.rfind("."), ext);
00375         int num_img = EMUtil::get_image_count(new_filename);
00376 
00377         if (img_index_start < 0 || img_index_start >= num_img) {
00378                 throw OutofRangeException(0, num_img-1, img_index_start, "image index start");
00379         }
00380 
00381         if (img_index_end >= num_img) {
00382                 img_index_end = num_img - 1;
00383         }
00384 
00385         vector < EMData * >v;
00386 
00387         for (int i = img_index_start; i < img_index_end; i++) {
00388                 EMData *d = new EMData();
00389                 try {
00390                         d->read_image(new_filename, i, header_only);
00391                 }
00392                 catch(E2Exception &e) {
00393                         if( d )
00394                         {
00395                                 delete d;
00396                                 d = 0;
00397                         }
00398                         throw(e);
00399                 }
00400                 v.push_back(d);
00401         }
00402         EXITFUNC;
00403         return v;
00404 }

EMData * EMData::get_fft_amplitude (  ) 

For anything read/set image's information.

$Id$ This file is a part of "emdata.h", to use functions in this file, you should "#include "emdata.h", NEVER directly include this file. return the amplitudes of the FFT including the left half

Exceptions:
ImageFormatException If the image is not a complex image.
Returns:
The current FFT image's amplitude image.

Definition at line 92 of file emdata_metadata.cpp.

References copy_head(), data, ENTERFUNC, EXITFUNC, get_data(), get_ndim(), get_ysize(), get_zsize(), ImageFormatException, is_complex(), LOGERR, nx, ny, nz, ri2ap(), set_complex(), set_complex_x(), set_ri(), set_size(), to_zero(), and update().

Referenced by EMAN::FourierReconstructor::finish().

00093 {
00094         ENTERFUNC;
00095 
00096         if (!is_complex()) {
00097                 LOGERR("complex image expected. Input image is real image.");
00098                 throw ImageFormatException("complex image expected. Input image is a real image.");
00099         }
00100 
00101         ri2ap();
00102 
00103         int nx2 = nx - 2;
00104         EMData *dat = copy_head();
00105         dat->set_size(nx2, ny, nz);
00106         dat->to_zero();
00107 
00108         float *d = dat->get_data();
00109         float *data = get_data();
00110         int ndim = get_ndim();
00111 
00112         size_t idx1, idx2, idx3;
00113         if (ndim == 3) {
00114                 for (int k = 1; k < nz; ++k) {
00115                         for (int j = 1; j < ny; ++j) {
00116                                 for (int i = 0; i < nx2/2; ++i) {
00117                                         idx1 = k*nx2*ny+j*nx2+nx2/2+i;
00118                                         idx2 = k*nx*ny+j*nx+2*i;
00119                                         idx3 = (nz-k)*nx2*ny+(ny-j)*nx2+nx2/2-i;
00120                                         d[idx1] = data[idx2];
00121                                         d[idx3] = data[idx2];
00122                                 }
00123                         }
00124                 }
00125         }
00126         else if (ndim == 2) {
00127                 for (int j = 1; j < ny; ++j) {
00128                         for (int i = 0; i < nx2/2; ++i) {
00129                                 d[j*nx2+nx2/2+i] = data[j*nx+2*i];
00130                                 d[(ny-j)*nx2+nx2/2-i] = data[j*nx+2*i];
00131                         }
00132                 }
00133         }
00134 
00135         dat->update();
00136         dat->set_complex(false);
00137         if(dat->get_ysize()==1 && dat->get_zsize()==1) {
00138                 dat->set_complex_x(false);
00139         }
00140         dat->set_ri(false);
00141 
00142         EXITFUNC;
00143         return dat;
00144 }

EMData * EMData::get_fft_amplitude2D (  ) 

return the amplitudes of the 2D FFT including the left half PRB

Exceptions:
ImageFormatException If the image is not a complex image.

Returns:
The current FFT image's amplitude image.

Definition at line 51 of file emdata_metadata.cpp.

References copy_head(), ENTERFUNC, EXITFUNC, ImageFormatException, is_complex(), LOGERR, nx, ny, nz, set_complex(), set_ri(), set_size(), sqrt(), to_zero(), and update().

00052 {
00053         ENTERFUNC;
00054 
00055 //      int ndim = get_ndim();
00056         if (!is_complex()) {
00057                 LOGERR("complex image expected. Input image is real image.");
00058                 throw ImageFormatException("complex image expected. Input image is a real image.");
00059         }
00060         if (nz>1) {
00061                 LOGERR("2D image expected. Input image is 3D");
00062                 throw ImageFormatException("2D odd square complex image"
00063                         " expected Input image is 3D.");
00064         }
00065 
00066         int nx2 = nx/2;
00067 
00068         EMData *dat = copy_head();
00069 
00070         dat->set_size(nx2, ny, nz);
00071         dat->to_zero();
00072 
00073         float temp=0;
00074 
00075         for (int j = 0; j < ny; j++) {
00076                 for (int i = 0; i < nx2; i++) {
00077                         temp = (*this)(2*i,j)*(*this)(2*i,j);
00078                         temp += (*this)(2*i+1,j)*(*this)(2*i+1,j);
00079                         (*dat)(i,j) = std::sqrt(temp);
00080                 }
00081         }
00082 
00083         dat->update();
00084         dat->set_complex(false);
00085         dat->set_ri(false);
00086 
00087         EXITFUNC;
00088         return dat;
00089 }

EMData * EMData::get_fft_phase (  ) 

return the phases of the FFT including the left half

Exceptions:
ImageFormatException If the image is not a complex image.
Returns:
The current FFT image's phase image.

Definition at line 147 of file emdata_metadata.cpp.

References copy_head(), data, ENTERFUNC, EXITFUNC, get_data(), get_ndim(), get_ysize(), get_zsize(), ImageFormatException, is_complex(), LOGERR, nx, ny, nz, ri2ap(), set_complex(), set_complex_x(), set_ri(), set_size(), to_zero(), and update().

00148 {
00149         ENTERFUNC;
00150 
00151         if (!is_complex()) {
00152                 LOGERR("complex image expected. Input image is real image.");
00153                 throw ImageFormatException("complex image expected. Input image is a real image.");
00154         }
00155 
00156         ri2ap();
00157 
00158         int nx2 = nx - 2;
00159         EMData *dat = copy_head();
00160         dat->set_size(nx2, ny, nz);
00161         dat->to_zero();
00162 
00163         float *d = dat->get_data();
00164         float * data = get_data();
00165 
00166         int ndim = get_ndim();
00167         size_t idx1, idx2, idx3;
00168         if (ndim == 3) {
00169                 for (int k = 1; k < nz; ++k) {
00170                         for (int j = 1; j < ny; ++j) {
00171                                 for (int i = 0; i < nx2/2; ++i) {
00172                                         idx1 = k*nx2*ny+j*nx2+nx2/2+i;
00173                                         idx2 = k*nx*ny+j*nx+2*i+1;
00174                                         idx3 = (nz-k)*nx2*ny+(ny-j)*nx2+nx2/2-i;
00175                                         d[idx1] = data[idx2];
00176                                         d[idx3] = -data[idx2];
00177                                 }
00178                         }
00179                 }
00180         }
00181         else if (ndim == 2) {
00182                 for (int j = 1; j < ny; ++j) {
00183                         for (int i = 0; i < nx2/2; ++i) {
00184                                 d[j*nx2+nx2/2+i] = data[j*nx+2*i+1];
00185                                 d[(ny-j)*nx2+nx2/2-i] = -data[j*nx+2*i+1];
00186                         }
00187                 }
00188         }
00189 
00190         dat->update();
00191         dat->set_complex(false);
00192         if(dat->get_ysize()==1 && dat->get_zsize()==1) {
00193                 dat->set_complex_x(false);
00194         }
00195         dat->set_ri(false);
00196 
00197         EXITFUNC;
00198         return dat;
00199 }

float * EMData::get_data (  )  const

Get the image pixel density data in a 1D float array.

Returns:
The image pixel density data.

Definition at line 203 of file emdata_metadata.cpp.

References BadAllocException, EMAN::EMUtil::em_malloc(), EMDATA_CPU_NEEDS_UPDATE, flags, nx, ny, nz, rdata, and UnexpectedBehaviorException.

Referenced by absi(), EMAN::MeanShrinkProcessor::accrue_mean(), EMAN::MeanShrinkProcessor::accrue_mean_one_p_five(), EMAN::MedianShrinkProcessor::accrue_median(), add(), EMAN::file_store::add_image(), EMAN::CtfAverager::add_image(), EMAN::CtfCWautoAverager::add_image(), EMAN::IterationAverager::add_image(), EMAN::ImageAverager::add_image(), EMAN::Util::add_img(), EMAN::Util::add_img2(), add_incoherent(), EMAN::newfile_store::add_tovol(), EMAN::Util::addn_img(), addsquare(), ali3d_d(), EMAN::RotatePrecenterAligner::align(), EMAN::TranslationalAligner::align(), EMAN::RotationalAligner::align_180_ambiguous(), amplitude(), EMAN::SVDAnalyzer::analyze(), EMAN::varimax::analyze(), EMAN::PCAlarge::analyze(), EMAN::PCAsmall::analyze(), ap2ri(), apmd(), apmq(), apply_radial_func(), average_circ_sub(), EMAN::PawelProjector::backproject3d(), EMAN::ChaoProjector::backproject3d(), EMAN::Util::BPCQ(), calc_az_dist(), calc_ccfx(), calc_center_density(), calc_center_of_mass(), calc_dist(), calc_fourier_shell_correlation(), calc_highest_locations(), calc_hist(), EMAN::MaskEdgeMeanProcessor::calc_locals(), calc_max_location(), EMAN::NormalizeLREdgeMeanProcessor::calc_mean(), EMAN::NormalizeMaskProcessor::calc_mean(), calc_min_location(), calc_mutual_correlation(), calc_radial_dist(), EMAN::NormalizeMaskProcessor::calc_sigma(), calc_sigma_diff(), circumference(), CleanStack(), CleanStack_Cart(), clip_inplace(), cm_euc(), EMAN::Util::cml_prepare_line(), EMAN::FRCCmp::cmp(), EMAN::OptVarianceCmp::cmp(), common_lines(), common_lines_real(), EMAN::Util::compress_image_mask(), EMAN::EMAN2Ctf::compute_2d_complex(), EMAN::EMAN1Ctf::compute_2d_complex(), conjg(), convolute(), EMAN::Util::Crosrng_e(), EMAN::Util::Crosrng_ew(), EMAN::Util::Crosrng_ms(), EMAN::Util::Crosrng_msg(), EMAN::Util::Crosrng_msg_m(), EMAN::Util::Crosrng_msg_s(), EMAN::Util::Crosrng_msg_vec(), EMAN::Util::Crosrng_ns(), EMAN::Util::Crosrng_sm_psi(), cut_slice(), EMAN::Util::cyclicshift(), EMAN::Util::decimate(), depad(), depad_corner(), EMAN::FourierReconstructor::determine_slice_agreement(), EMAN::PointArray::distmx(), div(), EMAN::Util::div_filter(), EMAN::Util::div_img(), EMAN::Util::divn_filter(), EMAN::Util::divn_img(), do_fft(), do_fft_inplace(), do_ift(), do_ift_inplace(), EMAN::FourierReconstructor::do_insert_slice_work(), do_radon(), EMAN::PCA::dopca_lan(), EMAN::PCA::dopca_ooc(), dot_rotate_translate(), EMAN::TestUtil::dump_emdata(), EMAN::Processor::EMFourierFilterFunc(), EMAN::Util::ener(), EMAN::Util::eval(), filter_by_image(), EMAN::WienerFourierReconstructor::finish(), EMAN::BaldwinWoolfordReconstructor::finish(), EMAN::FourierReconstructor::finish(), EMAN::CtfAverager::finish(), EMAN::CtfCWautoAverager::finish(), EMAN::IterationAverager::finish(), EMAN::ImageAverager::finish(), Four_ds(), Four_shuf_ds_cen_us(), EMAN::Phase180Processor::fourier_phaseshift180(), FourInterpol(), FourTruncate(), EMAN::Util::Frngs(), EMAN::Util::Frngs_inv(), get_2dcview(), get_2dview(), get_3dcview(), get_3dcviewptr(), get_3dview(), get_attr(), get_circle_mean(), get_col(), get_data_pickle(), get_edge_mean(), get_fft_amplitude(), get_fft_phase(), EMAN::file_store::get_image(), EMAN::newfile_store::get_image(), get_pixel_conv7(), get_pow(), get_row(), EMAN::Util::get_slice(), get_top_half(), get_value_at_wrap(), EMAN::Util::hist_comp_freq(), EMAN::Util::histc(), EMAN::Util::histogram(), EMAN::Util::im_diff(), imag(), EMAN::Util::image_mutation(), EMAN::Util::infomask(), EMAN::nn4_ctfReconstructor::insert_buffed_slice(), insert_clip(), EMAN::BaldwinWoolfordReconstructor::insert_density_at(), EMAN::SVDAnalyzer::insert_image(), EMAN::varimax::insert_image(), EMAN::PCAlarge::insert_image(), EMAN::PCAsmall::insert_image(), EMAN::BaldwinWoolfordReconstructor::insert_pixel(), insert_scaled_sum(), EMAN::BackProjectionReconstructor::insert_slice(), EMAN::WienerFourierReconstructor::insert_slice(), EMAN::BaldwinWoolfordReconstructor::insert_slice(), EMAN::FourierReconstructorSimple2D::insert_slice(), EMAN::GaussFFTProjector::interp_ft_3d(), EMAN::PCA::Lanczos_ooc(), little_big_dot(), EMAN::FourierReconstructor::load_inserter(), EMAN::FourierReconstructor::load_interp_FRC_calculator(), log(), log10(), EMAN::Util::mad_scalar(), EMAN::Util::madn_scalar(), main(), EMAN::TestUtil::make_image_file_by_mode(), EMAN::EMUtil::make_image_median(), EMAN::Util::min_dist_four(), EMAN::Util::min_dist_real(), EMAN::Util::move_points(), EMAN::Util::mul_img(), EMAN::Util::mul_scalar(), EMAN::Util::muln_img(), mult(), mult_complex_efficient(), EMAN::Util::mult_scalar(), EMAN::Util::multiref_peaks_ali2d(), EMAN::Util::multiref_peaks_compress_ali2d(), EMAN::Util::Normalize_ring(), EMAN::ReconstructorVolumeData::normalize_threed(), operator==(), EMAN::Util::pack_complex_to_real(), EMAN::Util::pad(), ParseAlignOptions(), EMAN::PointArray::pdb2mrc_by_nfft(), EMAN::PointArray::pdb2mrc_by_summation(), phase(), EMAN::Util::Polar2D(), EMAN::Util::Polar2Dm(), EMAN::Util::Polar2Dmi(), EMAN::DirectionalSumProcessor::process(), EMAN::Wiener2DAutoAreaProcessor::process(), EMAN::XYZProcessor::process_inplace(), EMAN::BinaryOperateProcessor< Type >::process_inplace(), EMAN::ApplyPolynomialProfileToHelix::process_inplace(), EMAN::ModelEMCylinderProcessor::process_inplace(), EMAN::ConvolutionProcessor::process_inplace(), EMAN::HistogramBin::process_inplace(), EMAN::ClampingProcessor::process_inplace(), EMAN::Rotate180Processor::process_inplace(), EMAN::CCDNormProcessor::process_inplace(), EMAN::RampProcessor::process_inplace(), EMAN::TestImageCylinder::process_inplace(), EMAN::TestImageNoiseGauss::process_inplace(), EMAN::TestImageNoiseUniformRand::process_inplace(), EMAN::TestImageCirclesphere::process_inplace(), EMAN::TestImageSquarecube::process_inplace(), EMAN::TestImageSinewaveCircular::process_inplace(), EMAN::TestImageSinewave::process_inplace(), EMAN::TestImageGaussian::process_inplace(), EMAN::TestImageFourierNoiseProfile::process_inplace(), EMAN::CTFSNRWeightProcessor::process_inplace(), EMAN::TestImageFourierNoiseGaussian::process_inplace(), EMAN::IterBinMaskProcessor::process_inplace(), EMAN::AutoMask3D2Processor::process_inplace(), EMAN::AutoMask3DProcessor::process_inplace(), EMAN::SmartMaskProcessor::process_inplace(), EMAN::CoordinateMaskFileProcessor::process_inplace(), EMAN::SymSearchProcessor::process_inplace(), EMAN::AddMaskShellProcessor::process_inplace(), EMAN::AddRandomNoiseProcessor::process_inplace(), EMAN::AutoMask2DProcessor::process_inplace(), EMAN::AutoMaskAsymUnit::process_inplace(), EMAN::PhaseToCenterProcessor::process_inplace(), EMAN::PhaseToCornerProcessor::process_inplace(), EMAN::FourierToCenterProcessor::process_inplace(), EMAN::FourierToCornerProcessor::process_inplace(), EMAN::AddNoiseProcessor::process_inplace(), EMAN::FlipProcessor::process_inplace(), EMAN::RotationalSubstractProcessor::process_inplace(), EMAN::RotationalAverageProcessor::process_inplace(), EMAN::BilateralProcessor::process_inplace(), EMAN::BinarizeFourierProcessor::process_inplace(), EMAN::NormalizeToLeastSquareProcessor::process_inplace(), EMAN::NormalizeRowProcessor::process_inplace(), EMAN::NormalizeByMassProcessor::process_inplace(), EMAN::NormalizeProcessor::process_inplace(), EMAN::ZeroEdgePlaneProcessor::process_inplace(), EMAN::ZeroEdgeRowProcessor::process_inplace(), EMAN::DecayEdgeProcessor::process_inplace(), EMAN::AverageXProcessor::process_inplace(), EMAN::MeanZeroEdgeProcessor::process_inplace(), EMAN::BeamstopProcessor::process_inplace(), EMAN::SigmaZeroEdgeProcessor::process_inplace(), EMAN::VerticalStripeProcessor::process_inplace(), EMAN::GradientPlaneRemoverProcessor::process_inplace(), EMAN::GradientRemoverProcessor::process_inplace(), EMAN::CutoffBlockProcessor::process_inplace(), EMAN::DiffBlockProcessor::process_inplace(), EMAN::BoxStatProcessor::process_inplace(), EMAN::AreaProcessor::process_inplace(), EMAN::ComplexPixelProcessor::process_inplace(), EMAN::WatershedProcessor::process_inplace(), EMAN::CoordinateProcessor::process_inplace(), EMAN::RealPixelProcessor::process_inplace(), EMAN::Wiener2DFourierProcessor::process_inplace(), EMAN::Wiener2DAutoAreaProcessor::process_inplace(), EMAN::LinearPyramidProcessor::process_inplace(), EMAN::AmpweightFourierProcessor::process_inplace(), EMAN::FourierAnlProcessor::process_inplace(), EMAN::FourierProcessor::process_inplace(), EMAN::ImageProcessor::process_inplace(), EMAN::ChaoProjector::project3d(), EMAN::StandardProjector::project3d(), EMAN::GaussFFTProjector::project3d(), EMAN::PointArray::projection_by_nfft(), EMAN::PointArray::projection_by_summation(), read_data(), read_image(), ReadStackandDist(), ReadStackandDist_Cart(), ReadVandBcast(), real(), recons3d_CGLS_mpi_Cart(), recons3d_HyBR_mpi_Cart(), recons3d_sirt_mpi(), recons3d_sirt_mpi_Cart(), EMAN::Util::reconstitute_image_mask(), render_amp24(), render_ap24(), replace_amplitudes(), EMAN::PointArray::replace_by_summation(), ri2ap(), ri2inten(), rot_scale_conv_new(), rot_scale_conv_new_background(), rot_scale_trans(), rot_scale_trans2D(), rot_scale_trans2D_background(), rot_scale_trans_background(), rotate_translate(), rotate_x(), set_col(), set_data_pickle(), EMAN::PointArray::set_from_density_map(), EMAN::Util::set_line(), EMAN::SVDAnalyzer::set_params(), set_row(), set_size(), wustl_mm::SkeletonMaker::VolumeData::SetDataAt(), EMAN::WienerFourierReconstructor::setup(), setup4slice(), sget_value_at(), sqrt(), sub(), EMAN::Util::sub_fav(), EMAN::Util::sub_img(), EMAN::Util::subn_img(), subsquare(), EMAN::Phase180Processor::swap_central_slices_180(), EMAN::Phase180Processor::swap_corners_180(), to_value(), uncut_slice(), unified(), unwrap(), EMAN::Util::update_fav(), update_stat(), EMAN::Cmp::validate_input_args(), EMAN::TestUtil::verify_image_file_by_mode(), EMAN::EMUtil::vertical_acf(), EMAN::Util::window(), write_data(), write_image(), EMAN::Util::WTF(), EMAN::Util::WTM(), and EMAN::FourierReconstructor::zero_memory().

00204 {
00205         size_t num_bytes = nx*ny*nz*sizeof(float);
00206         if (num_bytes > 0 && rdata == 0) {
00207                 rdata = (float*)EMUtil::em_malloc(num_bytes);
00208                 if ( rdata == 0 )
00209                 {
00210                         stringstream ss;
00211                         string gigs;
00212                         ss << num_bytes/1000000000.0;
00213                         ss >> gigs;
00214                         string message = "Cannot allocate " + gigs + " GB - not enough memory.";
00215                         throw BadAllocException(message);
00216                 }
00217                 if (rdata == 0) throw BadAllocException("The allocation of the raw data failed");
00218         }
00219 #ifdef EMAN2_USING_CUDA
00220         if ( num_bytes > 0 && gpu_rw_is_current()  && (EMDATA_CPU_NEEDS_UPDATE & flags)) {
00221                 cudaError_t error = cudaMemcpy(rdata,get_cuda_data(),num_bytes,cudaMemcpyDeviceToHost);
00222                 if (error != cudaSuccess ) throw UnexpectedBehaviorException("The device to host cudaMemcpy failed : " + string(cudaGetErrorString(error)));
00223         } else if ( gpu_ro_is_current()  && (EMDATA_CPU_NEEDS_UPDATE & flags)) {
00224                 cout << "Copy ro to cpu" << endl;
00225                 copy_gpu_ro_to_cpu();
00226         }
00227         flags &= ~EMDATA_CPU_NEEDS_UPDATE;
00228 #endif
00229         return rdata;
00230 
00231 }

const float* const EMAN::EMData::get_const_data (  )  const [inline]

void EMAN::EMData::set_data ( float *  data,
const int  x,
const int  y,
const int  z 
) [inline]

Set the data explicitly data pointer must be allocated using malloc!

Parameters:
data a pointer to the pixel data which is stored in memory. Takes possession
x the number of pixels in the x direction
y the number of pixels in the y direction
z the number of pixels in the z direction

Definition at line 342 of file emdata.h.

Referenced by wustl_mm::SkeletonMaker::VolumeData::Pad(), EMAN::TransformProcessor::process_inplace(), and EMAN::TransposeProcessor::process_inplace().

00345                                                           {
00346                         ENTERFUNC;
00347                         process_inplace("math.transform",Dict("transform",(Transform*)(&t)));
00348                         //update(); no need, process_inplace did it
00349                         EXITFUNC;
00350                 }
00351 

void EMData::write_data ( string  fsp,
size_t  loc,
const Region *const  area = 0,
const int  file_nx = 0,
const int  file_ny = 0,
const int  file_nz = 0 
)

Dump the image pixel data in native byte order to a disk file.

Parameters:
fsp The filename to write the image data to
loc Location to seek to in the file before writing (size_t)
area The image region you want to read, default 0 means read the whole image
file_nx Image x size.
file_ny Image y size.
file_nz Image z size.
Author:
Steve Ludtke
Date:
Mon Jun 23, 2008

Definition at line 235 of file emdata_metadata.cpp.

References FileAccessException, get_data(), nx, ny, nz, portable_fseek(), EMAN::EMUtil::process_region_io(), EMAN::ImageIO::READ_WRITE, and UnexpectedBehaviorException.

00235                                                                                                                         {
00236 
00237         if (area) {
00238                 struct stat fileinfo;
00239                 if ( stat(fsp.c_str(),&fileinfo) != 0 ) throw UnexpectedBehaviorException("To write an image using a region the file must already exist and be the correct dimensions");
00240         }
00241 
00242 
00243         FILE *f = 0;
00244         f=fopen(fsp.c_str(), "rb+");
00245         if (!f) f=fopen(fsp.c_str(), "wb");
00246         if (!f) throw FileAccessException(fsp);
00247         portable_fseek(f,loc,SEEK_SET);
00248         if (!area) {
00249                 if (fwrite(get_data(),nx*ny,nz*4,f)!=(size_t)(nz*4)) throw FileAccessException(fsp);
00250         } else {
00251                 int fnx = nx;
00252                 if (file_nx != 0) fnx = file_nx;
00253                 int fny = ny;
00254                 if (file_ny != 0) fny = file_ny;
00255                 int fnz = nz;
00256                 if (file_nz != 0) fnz = file_nz;
00257 
00258                 EMUtil::process_region_io(get_data(), f, ImageIO::READ_WRITE,
00259                                                                   0, 4,fnx,fny,fnz,area);
00260         }
00261         fclose(f);
00262 }

void EMData::read_data ( string  fsp,
size_t  loc,
const Region area = 0,
const int  file_nx = 0,
const int  file_ny = 0,
const int  file_nz = 0 
)

Read the image pixel data in native byte order from a disk file.

The image should already have the correct dimensions.

Parameters:
fsp The filename to read the image data from
loc Location to seek to in the file before writing (size_t)
area The image region you want to read, default 0 means read the whole image
file_nx Image x size.
file_ny Image y size.
file_nz Image z size.
Author:
Steve Ludtke
Date:
Mon Jun 23, 2008

Definition at line 264 of file emdata_metadata.cpp.

References FileAccessException, get_data(), nx, ny, nz, portable_fseek(), EMAN::EMUtil::process_region_io(), and EMAN::ImageIO::READ_ONLY.

00264                                                                                                                         {
00265         FILE *f = 0;
00266         f=fopen(fsp.c_str(), "rb");
00267         if (!f) throw FileAccessException(fsp);
00268         int fnx = nx;
00269         if (file_nx != 0) fnx = file_nx;
00270         int fny = ny;
00271         if (file_ny != 0) fny = file_ny;
00272         int fnz = nz;
00273         if (file_nz != 0) fnz = file_nz;
00274 
00275         portable_fseek(f,loc,SEEK_SET);
00276         EMUtil::process_region_io(get_data(), f, ImageIO::READ_ONLY,
00277                                                           0, 4,fnx,fny,fnz,area);
00278 //      portable_fseek(f,loc,SEEK_SET);
00279 //      if (fread(get_data(),nx*ny,nz*4,f)!=(size_t)(nz*4)) throw FileAccessException(fsp);
00280         fclose(f);
00281 }

void EMAN::EMData::update (  )  [inline]

Mark EMData as changed, statistics, etc will be updated at need.

Definition at line 382 of file emdata.h.

Referenced by absi(), EMAN::MeanShrinkProcessor::accrue_mean_one_p_five(), add(), EMAN::CtfAverager::add_image(), EMAN::Util::add_img(), EMAN::Util::add_img2(), add_incoherent(), EMAN::Util::addn_img(), addsquare(), EMAN::TranslationalAligner::align(), amplitude(), ap2ri(), apply_radial_func(), average_circ_sub(), EMAN::PawelProjector::backproject3d(), EMAN::ChaoProjector::backproject3d(), calc_ccfx(), calc_mutual_correlation(), center_origin(), center_origin_fft(), center_origin_yz(), clip_inplace(), EMAN::Util::cml_prepare_line(), EMAN::FRCCmp::cmp(), EMAN::OptVarianceCmp::cmp(), common_lines(), common_lines_real(), EMAN::EMAN2Ctf::compute_2d_complex(), EMAN::EMAN1Ctf::compute_2d_complex(), convolute(), copy_head(), EMAN::Util::ctf_img(), cut_slice(), EMAN::Util::cyclicshift(), EMAN::Util::decimate(), delete_disconnected_regions(), depad(), depad_corner(), EMAN::PointArray::distmx(), div(), EMAN::Util::div_filter(), EMAN::Util::div_img(), EMAN::Util::divn_filter(), EMAN::Util::divn_img(), do_fft(), do_fft_inplace(), do_ift(), do_ift_inplace(), do_radon(), EMData(), EMAN::Processor::EMFourierFilterFunc(), fft_shuffle(), FH2F(), filter_by_image(), EMAN::nnSSNR_ctfReconstructor::finish(), EMAN::nnSSNR_Reconstructor::finish(), EMAN::WienerFourierReconstructor::finish(), EMAN::BaldwinWoolfordReconstructor::finish(), EMAN::FourierReconstructor::finish(), EMAN::CtfAverager::finish(), EMAN::CtfCWautoAverager::finish(), EMAN::IterationAverager::finish(), EMAN::MinMaxAverager::finish(), EMAN::ImageAverager::finish(), Four_ds(), Four_shuf_ds_cen_us(), fouriergridrot2d(), fouriergridrot_shift2d(), EMAN::fourierproduct(), FourInterpol(), FourTruncate(), get_clip(), get_col(), get_fft_amplitude(), get_fft_amplitude2D(), get_fft_phase(), EMAN::file_store::get_image(), EMAN::newfile_store::get_image(), get_rotated_clip(), get_row(), get_top_half(), helicise(), EMAN::Util::im_diff(), imag(), insert_clip(), insert_scaled_sum(), EMAN::WienerFourierReconstructor::insert_slice(), little_big_dot(), log(), log10(), EMAN::Util::mad_scalar(), EMAN::Util::madn_scalar(), main(), EMAN::TestUtil::make_image_file_by_mode(), EMAN::EMUtil::make_image_median(), EMAN::Util::move_points(), EMAN::Util::mul_img(), EMAN::Util::mul_scalar(), EMAN::Util::muln_img(), mult(), mult_complex_efficient(), mult_radial(), EMAN::Util::mult_scalar(), EMAN::Util::Normalize_ring(), operator*=(), operator+=(), operator-=(), operator/=(), EMAN::Util::pack_complex_to_real(), EMAN::Util::pad(), EMAN::PointArray::pdb2mrc_by_nfft(), EMAN::PointArray::pdb2mrc_by_summation(), EMAN::periodogram(), phase(), power(), EMAN::DirectionalSumProcessor::process(), EMAN::BooleanShrinkProcessor::process(), EMAN::MeanShrinkProcessor::process(), EMAN::FFTResampleProcessor::process(), EMAN::MedianShrinkProcessor::process(), EMAN::BinaryOperateProcessor< Type >::process_inplace(), EMAN::TomoTiltEdgeMaskProcessor::process_inplace(), EMAN::ConvolutionProcessor::process_inplace(), EMAN::ClampingProcessor::process_inplace(), EMAN::Rotate180Processor::process_inplace(), EMAN::TransformProcessor::process_inplace(), EMAN::MirrorProcessor::process_inplace(), EMAN::RadialProcessor::process_inplace(), EMAN::RampProcessor::process_inplace(), EMAN::TestImageCylinder::process_inplace(), EMAN::TestImageNoiseGauss::process_inplace(), EMAN::TestImageNoiseUniformRand::process_inplace(), EMAN::TestImageEllipse::process_inplace(), EMAN::TestImageHollowEllipse::process_inplace(), EMAN::TestImageCirclesphere::process_inplace(), EMAN::TestImageSquarecube::process_inplace(), EMAN::TestImageSinewaveCircular::process_inplace(), EMAN::TestImageSinewave::process_inplace(), EMAN::TestImageSphericalWave::process_inplace(), EMAN::TestImagePureGaussian::process_inplace(), EMAN::TestImageScurve::process_inplace(), EMAN::TestImageAxes::process_inplace(), EMAN::TestImageGradient::process_inplace(), EMAN::TestImageGaussian::process_inplace(), EMAN::IterBinMaskProcessor::process_inplace(), EMAN::AutoMask3D2Processor::process_inplace(), EMAN::AutoMask3DProcessor::process_inplace(), EMAN::SmartMaskProcessor::process_inplace(), EMAN::CoordinateMaskFileProcessor::process_inplace(), EMAN::AddMaskShellProcessor::process_inplace(), EMAN::AddRandomNoiseProcessor::process_inplace(), EMAN::AutoMask2DProcessor::process_inplace(), EMAN::AddNoiseProcessor::process_inplace(), EMAN::FlipProcessor::process_inplace(), EMAN::RotationalSubstractProcessor::process_inplace(), EMAN::RotationalAverageProcessor::process_inplace(), EMAN::BilateralProcessor::process_inplace(), EMAN::BinarizeFourierProcessor::process_inplace(), EMAN::NormalizeToLeastSquareProcessor::process_inplace(), EMAN::NormalizeRowProcessor::process_inplace(), EMAN::NormalizeByMassProcessor::process_inplace(), EMAN::NormalizeRampNormVar::process_inplace(), EMAN::NormalizeProcessor::process_inplace(), EMAN::ZeroEdgePlaneProcessor::process_inplace(), EMAN::ZeroEdgeRowProcessor::process_inplace(), EMAN::DecayEdgeProcessor::process_inplace(), EMAN::AverageXProcessor::process_inplace(), EMAN::MeanZeroEdgeProcessor::process_inplace(), EMAN::BeamstopProcessor::process_inplace(), EMAN::SigmaZeroEdgeProcessor::process_inplace(), EMAN::RealToFFTProcessor::process_inplace(), EMAN::VerticalStripeProcessor::process_inplace(), EMAN::GradientPlaneRemoverProcessor::process_inplace(), EMAN::GradientRemoverProcessor::process_inplace(), EMAN::BooleanShrinkProcessor::process_inplace(), EMAN::MeanShrinkProcessor::process_inplace(), EMAN::FFTResampleProcessor::process_inplace(), EMAN::MedianShrinkProcessor::process_inplace(), EMAN::CutoffBlockProcessor::process_inplace(), EMAN::DiffBlockProcessor::process_inplace(), EMAN::BoxStatProcessor::process_inplace(), EMAN::AreaProcessor::process_inplace(), EMAN::ComplexPixelProcessor::process_inplace(), EMAN::WatershedProcessor::process_inplace(), EMAN::PaintProcessor::process_inplace(), EMAN::CoordinateProcessor::process_inplace(), EMAN::RealPixelProcessor::process_inplace(), EMAN::Wiener2DFourierProcessor::process_inplace(), EMAN::Wiener2DAutoAreaProcessor::process_inplace(), EMAN::LinearPyramidProcessor::process_inplace(), EMAN::AmpweightFourierProcessor::process_inplace(), EMAN::FourierAnlProcessor::process_inplace(), EMAN::FourierProcessor::process_inplace(), EMAN::ImageProcessor::process_inplace(), EMAN::ChaoProjector::project3d(), EMAN::FourierGriddingProjector::project3d(), EMAN::StandardProjector::project3d(), EMAN::PawelProjector::project3d(), EMAN::GaussFFTProjector::project3d(), EMAN::PointArray::projection_by_nfft(), EMAN::PointArray::projection_by_summation(), read_image(), real(), real2complex(), real2FH(), EMAN::Util::reconstitute_image_mask(), replace_amplitudes(), EMAN::PointArray::replace_by_summation(), ri2ap(), ri2inten(), rotate_translate(), rotate_x(), rotavg(), rotavg_i(), EMAN::rsconvolution(), set_col(), EMAN::PointArray::set_from_density_map(), EMAN::Util::set_line(), set_row(), set_size(), EMAN::WienerFourierReconstructor::setup(), EMAN::FourierReconstructor::setup(), sqrt(), sub(), EMAN::Util::sub_fav(), EMAN::Util::sub_img(), EMAN::Util::subn_img(), subsquare(), symvol(), to_one(), to_value(), to_zero(), EMAN::Util::TwoDTestFunc(), uncut_slice(), unwrap(), EMAN::Util::update_fav(), EMAN::EMUtil::vertical_acf(), EMAN::Util::window(), EMAN::Util::WTF(), and EMAN::Util::WTM().

00400                                          {

bool EMAN::EMData::has_ctff (  )  const [inline]

check whether the image physical file has the CTF info or not.

Returns:
True if it has the CTF information. Otherwise, false.

Definition at line 392 of file emdata.h.

Referenced by EMAN::CtfAverager::add_image(), and EMAN::EMUtil::is_same_ctf().

00400                                          {

float EMData::calc_center_density (  ) 

Calculates the density value at the peak of the image histogram, sort of like the mode of the density.

Returns:
The density value at the peak of the image histogram.

Definition at line 283 of file emdata_metadata.cpp.

References ENTERFUNC, EXITFUNC, get_attr(), get_data(), norm(), nx, ny, and nz.

00284 {
00285         ENTERFUNC;
00286 
00287         float center = get_attr("mean");
00288         float sigma = get_attr("sigma");
00289         float ds = sigma / 2;
00290         size_t size = nx * ny * nz;
00291         float *d = get_data();
00292         float sigma1 = sigma / 20;
00293         float sigma2 = sigma / 1000;
00294 
00295         while (ds > sigma1) {
00296                 double sum = 0;
00297                 int norm = 0;
00298 
00299                 for (size_t i = 0; i < size; i++) {
00300                         if (fabs(d[i] - center) < ds) {
00301                                 sum += d[i];
00302                                 norm++;
00303                         }
00304                 }
00305                 if (!norm) {
00306                         break;
00307                 }
00308                 float mean = (float)(sum / norm);
00309                 if (fabs(mean - center) < sigma2) {
00310                         ds *= 0.5f;
00311                 }
00312                 center = mean;
00313         }
00314         EXITFUNC;
00315 
00316         return center;
00317 }

float EMData::calc_sigma_diff (  ) 

Calculates sigma above and below the mean and returns the difference between them.

Returns:
The difference between sigma above and below the mean.

Definition at line 320 of file emdata_metadata.cpp.

References ENTERFUNC, EXITFUNC, get_attr(), get_data(), nx, ny, nz, sqrt(), and square.

00321 {
00322         ENTERFUNC;
00323 
00324         float *d = get_data();
00325         float mean = get_attr("mean");
00326         float sigma = get_attr("sigma");
00327 
00328         double sum_up = 0;
00329         double sum_down = 0;
00330         int nup = 0;
00331         int ndown = 0;
00332 
00333         size_t size = nx * ny * nz;
00334 
00335         for (size_t i = 0; i < size; i++) {
00336                 if (d[i] > mean) {
00337                         sum_up += Util::square(d[i] - mean);
00338                         nup++;
00339                 }
00340                 else {
00341                         sum_down += Util::square(mean - d[i]);
00342                         ndown++;
00343                 }
00344         }
00345 
00346         float sigup = std::sqrt((float)sum_up / nup);
00347         float sigdown = std::sqrt((float)sum_down / ndown);
00348         float sig_diff = fabs(sigup - sigdown) / sigma;
00349 
00350 
00351         EXITFUNC;
00352         return sig_diff;
00353 
00354 }

IntPoint EMData::calc_min_location (  )  const

Calculates the coordinates of the minimum-value pixel.

Returns:
The coordinates of the minimum-value pixel.

Definition at line 357 of file emdata_metadata.cpp.

References data, ENTERFUNC, get_data(), is_complex(), is_ri(), min, nx, nxy, ny, nz, and t.

Referenced by calc_min_index().

00358 {
00359         ENTERFUNC;
00360 
00361         int di = 1;
00362         if (is_complex() && !is_ri()) {
00363                 di = 2;
00364         }
00365 
00366         float min = FLT_MAX;
00367         int min_x = 0;
00368         int min_y = 0;
00369         int min_z = 0;
00370         int nxy = nx * ny;
00371         float * data = get_data();
00372 
00373         for (int j = 0; j < nz; ++j) {
00374                 size_t cur_z = j * nxy;
00375 
00376                 for (int k = 0; k < ny; ++k) {
00377                         size_t cur_y = k * nx + cur_z;
00378 
00379                         for (int l = 0; l < nx; l += di) {
00380                                 float t = data[l + cur_y];
00381                                 if (t < min) {
00382                                         min_x = l;
00383                                         min_y = k;
00384                                         min_z = j;
00385                                         min = t;
00386                                 }
00387                         }
00388                 }
00389         }
00390 
00391         return IntPoint(min_x, min_y, min_z);
00392 }

IntPoint EMData::calc_max_location (  )  const

Calculates the coordinates of the maximum-value pixel.

Returns:
The coordinates of the maximum-value pixel.

Definition at line 395 of file emdata_metadata.cpp.

References data, ENTERFUNC, EXITFUNC, get_data(), is_complex(), is_ri(), max, nx, nxy, ny, nz, and t.

Referenced by calc_max_index().

00396 {
00397         ENTERFUNC;
00398 
00399         int di = 1;
00400         if (is_complex() && !is_ri()) {
00401                 di = 2;
00402         }
00403 
00404         float max = -FLT_MAX;
00405         int max_x = 0;
00406         int max_y = 0;
00407         int max_z = 0;
00408         int nxy = nx * ny;
00409         float * data = get_data();
00410 
00411         for (int j = 0; j < nz; ++j) {
00412                 size_t cur_z = j * nxy;
00413 
00414                 for (int k = 0; k < ny; ++k) {
00415                         size_t cur_y = k * nx + cur_z;
00416 
00417                         for (int l = 0; l < nx; l += di) {
00418                                 float t = data[l + cur_y];
00419                                 if (t > max) {
00420                                         max_x = l;
00421                                         max_y = k;
00422                                         max_z = j;
00423                                         max = t;
00424                                 }
00425                         }
00426                 }
00427         }
00428 
00429         EXITFUNC;
00430         return IntPoint(max_x, max_y, max_z);
00431 }

IntPoint EMData::calc_max_location_wrap ( const int  maxshiftx = -1,
const int  maxshifty = -1,
const int  maxshiftz = -1 
)

Calculates the wrapped coordinates of the maximum value This function is useful in the context of Fourier correlation you can call this function to find the correct translational shift when using calc_ccf etc.

Returns:
the wrapped coordinates of the maximum
Author:
David Woolford
Date:
Fri Jun 6th 2008

Definition at line 434 of file emdata_metadata.cpp.

References get_value_at_wrap(), get_xsize(), get_ysize(), and get_zsize().

Referenced by EMAN::TranslationalAligner::align(), EMAN::RT3DSphereAligner::xform_align_nbest(), and EMAN::RT3DGridAligner::xform_align_nbest().

00435 {
00436         int maxshiftx = maxdx, maxshifty = maxdy, maxshiftz = maxdz;
00437         if (maxdx == -1) maxshiftx = get_xsize()/4;
00438         if (maxdy == -1) maxshifty = get_ysize()/4;
00439         if (maxdz == -1) maxshiftz = get_zsize()/4;
00440 
00441         float max_value = -FLT_MAX;
00442 
00443         IntPoint peak(0,0,0);
00444         for (int k = -maxshiftz; k <= maxshiftz; k++) {
00445                 for (int j = -maxshifty; j <= maxshifty; j++) {
00446                         for (int i = -maxshiftx; i <= maxshiftx; i++) {
00447 
00448                                 float value = get_value_at_wrap(i,j,k);
00449 
00450                                 if (value > max_value) {
00451                                         max_value = value;
00452                                         peak[0] = i;
00453                                         peak[1] = j;
00454                                         peak[2] = k;
00455                                 }
00456                         }
00457                 }
00458         }
00459 
00460         return peak;
00461 }

FloatPoint EMData::calc_center_of_mass (  ) 

Calculate the center of mass using an algorithm written by S Ludtke.

Author:
David Woolford
Date:
Fri Jun 6th 2008

Definition at line 463 of file emdata_metadata.cpp.

References data, get_attr(), get_data(), nx, nxy, ny, and nz.

Referenced by EMAN::ToMassCenterProcessor::process_inplace().

00464 {
00465         float *data = get_data();
00466 
00467         float sigma = get_attr("sigma");
00468         float mean = get_attr("mean");
00469         float m = 0;
00470 
00471         FloatPoint com(0,0,0);
00472         for (int i = 0; i < nx; ++i) {
00473                 for (int j = 0; j < ny; ++j) {
00474                         int j2 = nx * j;
00475                         for (int k = 0; k < nz; ++k) {
00476                                 size_t l = i + j2 + k * nxy;
00477                                 if (data[l] >= sigma * .75 + mean) {
00478                                         com[0] += i * data[l];
00479                                         com[1] += j * data[l];
00480                                         com[2] += k * data[l];
00481                                         m += data[l];
00482                                 }
00483                         }
00484                 }
00485         }
00486 
00487         com[0] /= m;
00488         com[1] /= m;
00489         com[2] /= m;
00490 
00491         return com;
00492 }

int EMData::calc_min_index (  )  const

Calculates the index of minimum-value pixel when assuming all pixels are in a 1D array.

Returns:
Index of the minimum-value pixel.

Definition at line 495 of file emdata_metadata.cpp.

References calc_min_location(), nx, and ny.

00496 {
00497         IntPoint min_location = calc_min_location();
00498         int i = min_location[0] + min_location[1] * nx + min_location[2] * nx * ny;
00499         return i;
00500 }

int EMData::calc_max_index (  )  const

Calculates the index of maximum-value pixel when assuming all pixels are in a 1D array.

Returns:
Index of the maximum-value pixel.

Definition at line 503 of file emdata_metadata.cpp.

References calc_max_location(), nx, and ny.

Referenced by EMAN::RTFExhaustiveAligner::align().

00504 {
00505         IntPoint max_location = calc_max_location();
00506         int i = max_location[0] + max_location[1] * nx + max_location[2] * nx * ny;
00507         return i;
00508 }

vector< Pixel > EMData::calc_highest_locations ( float  threshold  ) 

Calculate and return a sorted list of pixels whose values are above a specified threshold.

The pixels are sorted from high to low.

Parameters:
threshold The specified pixel value. Returned pixels should have higher values than it.
Returns:
A sorted list of pixels with their values, and locations. Their values are higher than threshold.

Definition at line 511 of file emdata_metadata.cpp.

References data, ENTERFUNC, EXITFUNC, get_data(), is_complex(), is_ri(), nx, nxy, ny, nz, and v.

00512 {
00513         ENTERFUNC;
00514 
00515         vector<Pixel> result;
00516 
00517         int di = 1;
00518         if (is_complex() && !is_ri()) {
00519                 di = 2;
00520         }
00521 
00522         int nxy = nx * ny;
00523         float * data = get_data();
00524 
00525         for (int j = 0; j < nz; ++j) {
00526                 size_t cur_z = j * nxy;
00527 
00528                 for (int k = 0; k < ny; ++k) {
00529                         size_t cur_y = k * nx + cur_z;
00530 
00531                         for (int l = 0; l < nx; l += di) {
00532                                 float v =data[l + cur_y];
00533                                 if (v > threshold) {
00534                                         result.push_back(Pixel(l, k, j, v));
00535                                 }
00536                         }
00537                 }
00538         }
00539 
00540         std::sort(result.begin(), result.end());
00541 
00542         EXITFUNC;
00543         return result;
00544 }

float EMData::get_edge_mean (  )  const

Calculates the mean pixel values around the (1 pixel) edge of the image.

Returns:
The mean pixel values around the (1 pixel) edge.

Definition at line 547 of file emdata_metadata.cpp.

References data, ENTERFUNC, EXITFUNC, get_data(), nx, nxy, ny, and nz.

Referenced by calc_fast_sigma_image(), EMAN::NormalizeEdgeMeanProcessor::calc_mean(), EMAN::NormalizeMaskProcessor::calc_mean(), little_big_dot(), make_rotational_footprint(), make_rotational_footprint_cmc(), make_rotational_footprint_e1(), and EMAN::FlattenBackgroundProcessor::process_inplace().

00548 {
00549         ENTERFUNC;
00550 
00551         int di = 0;
00552         double edge_sum = 0;
00553         float edge_mean = 0;
00554         size_t nxy = nx * ny;
00555         float * data = get_data();
00556         if (nz == 1) {
00557                 for (int i = 0, j = (ny - 1) * nx; i < nx; ++i, ++j) {
00558                         edge_sum += data[i] + data[j];
00559                 }
00560                 for (size_t i = 0, j = nx - 1; i < nxy; i += nx, j += nx) {
00561                         edge_sum += data[i] + data[j];
00562                 }
00563                 edge_mean = (float)edge_sum / (nx * 2 + ny * 2);
00564         }
00565         else {
00566                 if (nx == ny && nx == nz * 2 - 1) {
00567                         for (size_t j = (nxy * (nz - 1)); j < nxy * nz; ++j, ++di) {
00568                                 edge_sum += data[j];
00569                         }
00570                 }
00571                 else {
00572                         for (size_t i = 0, j = (nxy * (nz - 1)); i < nxy; ++i, ++j, ++di) {
00573                                 edge_sum += data[i] + data[j];
00574                         }
00575                 }
00576 
00577                 int nxy2 = nx * (ny - 1);
00578                 for (int k = 1; k < nz - 1; ++k) {
00579                         size_t k2 = k * nxy;
00580                         size_t k3 = k2 + nxy2;
00581                         for (int i = 0; i < nx; ++i, ++di) {
00582                                 edge_sum += data[i + k2] + data[i + k3];
00583                         }
00584                 }
00585                 for (int k = 1; k < nz - 1; ++k) {
00586                         size_t k2 = k * nxy;
00587                         size_t k3 = nx - 1 + k2;
00588                         for (int i = 1; i < ny - 1; ++i, ++di) {
00589                                 edge_sum += data[i * nx + k2] + data[i * nx + k3];
00590                         }
00591                 }
00592 
00593                 edge_mean = (float)edge_sum / (di * 2);
00594         }
00595         EXITFUNC;
00596 
00597         return edge_mean;
00598 }

float EMData::get_circle_mean (  ) 

Calculates the circular edge mean by applying a circular mask on 'this' image.

Returns:
The circular edge mean.

Definition at line 601 of file emdata_metadata.cpp.

References data, EMData(), ENTERFUNC, EXITFUNC, get_data(), EMAN::EMUtil::is_same_size(), nx, ny, nz, process_inplace(), set_size(), and to_one().

Referenced by EMAN::NormalizeCircleMeanProcessor::calc_mean().

00602 {
00603         ENTERFUNC;
00604 
00605         static bool busy = false;
00606         static EMData *mask = 0;
00607 
00608         while (busy);
00609         busy = true;
00610 
00611         if (!mask || !EMUtil::is_same_size(this, mask)) {
00612                 if (!mask) {
00613                         mask = new EMData();
00614                 }
00615                 mask->set_size(nx, ny, nz);
00616                 mask->to_one();
00617 
00618                 float radius = (float)(ny / 2 - 2);
00619                 mask->process_inplace("mask.sharp", Dict("inner_radius", radius - 1,
00620                                                                            "outer_radius", radius + 1));
00621 
00622         }
00623         double n = 0,s=0;
00624         float *d = mask->get_data();
00625         float * data = get_data();
00626         size_t size = nx*ny*nz;
00627         for (size_t i = 0; i < size; i++) {
00628                 if (d[i]) { n+=1.0; s+=data[i]; }
00629         }
00630 
00631 
00632         float result = (float)(s/n);
00633         busy = false;
00634 
00635         EXITFUNC;
00636         return result;
00637 }

Ctf * EMData::get_ctf (  )  const

Get ctf parameter of this image.

Returns:
The ctf parameter.

Definition at line 650 of file emdata_metadata.cpp.

References attr_dict, EMAN::EMAN1Ctf::from_vector(), and EMAN::Dict::has_key().

Referenced by EMAN::CtfAverager::add_image(), EMAN::EMUtil::is_same_ctf(), main(), and EMAN::SNRProcessor::process_inplace().

00651 {
00652         if(attr_dict.has_key("ctf")) {
00653                 EMAN1Ctf * ctf = new EMAN1Ctf();
00654                 ctf->from_vector(attr_dict["ctf"]);
00655 
00656                 return dynamic_cast<Ctf *>(ctf);
00657         }
00658         else {
00659                 return 0;
00660         }
00661 }

void EMData::set_ctf ( Ctf ctf  ) 

Set the CTF parameter of this image.

Parameters:
ctf The CTF parameter object.

Definition at line 640 of file emdata_metadata.cpp.

References attr_dict, ENTERFUNC, EXITFUNC, and EMAN::Ctf::to_vector().

00641 {
00642         ENTERFUNC;
00643 
00644         vector<float> vctf = new_ctf->to_vector();
00645         attr_dict["ctf"] = vctf;
00646 
00647         EXITFUNC;
00648 }

Vec3f EMAN::EMData::get_translation (  )  const [inline]

Get 'this' image's translation vector from the original location.

Returns:
'this' image's translation vector from the original location.

Definition at line 501 of file emdata.h.

00810                                           {

void EMAN::EMData::set_translation ( const Vec3f t  )  [inline]

Set 'this' images' translation vector from the original location.

Parameters:
t The new translation vector.

Definition at line 511 of file emdata.h.

00810                                           {

void EMAN::EMData::set_translation ( float  dx,
float  dy,
float  dz 
) [inline]

Set 'this' images' translation vector from the original location.

Parameters:
dx The translation distance in x direction.
dy The translation distance in y direction.
dz The translation distance in z direction.

Definition at line 523 of file emdata.h.

00810                                           {

Transform3D EMAN::EMData::get_transform (  )  const [inline]

Get the 3D orientation of 'this' image.

Returns:
The 3D orientation of 'this' image.

Definition at line 532 of file emdata.h.

Referenced by main().

00810                                           {

void EMAN::EMData::set_rotation ( float  az,
float  alt,
float  phi 
) [inline]

Define the 3D orientation of this particle, also used to indicate relative rotations for reconstructions.

Parameters:
az 'az' Euler angle in EMAN convention.
alt 'alt' Euler angle in EMAN convention.
phi 'phi' Euler angle in EMAN convention.

Definition at line 547 of file emdata.h.

Referenced by main().

00810                                           {

void EMAN::EMData::set_rotation ( const Transform3D t3d  )  [inline]

Define the 3D orientation of this particle Orientation information is extracted from a Transform3D object and stored internally in EMAN (az,alt,phi) format.

Parameters:
t3d a Transform3D object containing the particle orientation

Definition at line 561 of file emdata.h.

00810                                           {

void EMData::set_size ( int  nx,
int  ny = 1,
int  nz = 1 
)

Resize this EMData's main board memory pointer.

Parameters:
nx x size of this image.
ny y size of this image.
nz z size of this image. $
Exceptions:
BadAllocException if memory allocation returns a null pointer

Definition at line 667 of file emdata_metadata.cpp.

References BadAllocException, EMAN::EMUtil::em_free(), EMAN::EMUtil::em_malloc(), EMAN::EMUtil::em_memset(), EMAN::EMUtil::em_realloc(), ENTERFUNC, EXITFUNC, get_data(), InvalidValueException, nx, nxy, ny, nz, rdata, supp, and update().

Referenced by absi(), EMAN::CtfAverager::add_image(), EMAN::IterationAverager::add_image(), EMAN::ImageAverager::add_image(), ali3d_d(), amplitude(), EMAN::SVDAnalyzer::analyze(), EMAN::varimax::analyze(), EMAN::PCAlarge::analyze(), EMAN::PCAsmall::analyze(), EMAN::PawelProjector::backproject3d(), EMAN::ChaoProjector::backproject3d(), bispecRotTransInvN(), EMAN::nnSSNR_ctfReconstructor::buildFFTVolume(), EMAN::nn4_ctfReconstructor::buildFFTVolume(), EMAN::nnSSNR_Reconstructor::buildFFTVolume(), EMAN::nn4Reconstructor::buildFFTVolume(), EMAN::nnSSNR_ctfReconstructor::buildNorm2Volume(), EMAN::nnSSNR_Reconstructor::buildNorm2Volume(), EMAN::nnSSNR_ctfReconstructor::buildNorm3Volume(), EMAN::nnSSNR_ctfReconstructor::buildNormVolume(), EMAN::nn4_ctfReconstructor::buildNormVolume(), EMAN::nnSSNR_Reconstructor::buildNormVolume(), EMAN::nn4Reconstructor::buildNormVolume(), calc_ccfx(), clip_inplace(), common_lines(), common_lines_real(), EMAN::Util::compress_image_mask(), copy_head(), EMAN::Util::Crosrng_msg(), EMAN::Util::Crosrng_msg_m(), EMAN::Util::Crosrng_msg_s(), EMAN::Util::ctf_img(), EMAN::Util::decimate(), depad(), depad_corner(), do_fft(), do_fft_inplace(), do_ift(), do_ift_inplace(), do_radon(), EMAN::PCA::dopca_lan(), EMAN::PCA::dopca_ooc(), downsample(), EMData(), extract_plane(), extractline(), FH2F(), EMAN::filt_dilation_(), EMAN::filt_erosion_(), EMAN::filt_median_(), EMAN::nnSSNR_ctfReconstructor::finish(), EMAN::nnSSNR_Reconstructor::finish(), Four_ds(), Four_shuf_ds_cen_us(), FourInterpol(), FourTruncate(), EMAN::Util::get_biggest_cluster(), get_circle_mean(), get_clip(), get_col(), get_fft_amplitude(), get_fft_amplitude2D(), get_fft_phase(), EMAN::file_store::get_image(), EMAN::newfile_store::get_image(), get_rotated_clip(), get_row(), EMAN::Util::get_slice(), get_top_half(), EMAN::Util::im_diff(), imag(), EMAN::BackProjectionReconstructor::insert_slice(), little_big_dot(), main(), EMAN::TestUtil::make_image_file_by_mode(), EMAN::EMUtil::make_image_median(), make_rotational_footprint_cmc(), make_rotational_footprint_e1(), EMAN::Util::move_points(), EMAN::Util::multiref_peaks_ali2d(), EMAN::Util::multiref_peaks_compress_ali2d(), operator=(), EMAN::Util::pack_complex_to_real(), EMAN::Util::pad(), EMAN::PointArray::pdb2mrc_by_nfft(), EMAN::PointArray::pdb2mrc_by_summation(), EMAN::periodogram(), phase(), EMAN::Util::Polar2D(), EMAN::Util::Polar2Dm(), EMAN::Util::Polar2Dmi(), EMAN::DirectionalSumProcessor::process(), EMAN::BooleanShrinkProcessor::process(), EMAN::MeanShrinkProcessor::process(), EMAN::MedianShrinkProcessor::process(), EMAN::ZGradientProcessor::process_inplace(), EMAN::YGradientProcessor::process_inplace(), EMAN::XGradientProcessor::process_inplace(), EMAN::TestImageFourierNoiseProfile::process_inplace(), EMAN::TestImageFourierNoiseGaussian::process_inplace(), EMAN::AutoMask3D2Processor::process_inplace(), EMAN::AutoMask3DProcessor::process_inplace(), EMAN::FlattenBackgroundProcessor::process_inplace(), EMAN::BooleanShrinkProcessor::process_inplace(), EMAN::MeanShrinkProcessor::process_inplace(), EMAN::MedianShrinkProcessor::process_inplace(), EMAN::ChaoProjector::project3d(), EMAN::FourierGriddingProjector::project3d(), EMAN::StandardProjector::project3d(), EMAN::PawelProjector::project3d(), EMAN::GaussFFTProjector::project3d(), EMAN::PointArray::projection_by_nfft(), EMAN::PointArray::projection_by_summation(), read_image(), ReadVandBcast(), real(), real2complex(), real2FH(), recons3d_CGLS_mpi_Cart(), recons3d_HyBR_mpi_Cart(), recons3d_sirt_mpi(), recons3d_sirt_mpi_Cart(), EMAN::Util::reconstitute_image_mask(), rot_scale_conv(), rot_scale_conv7(), rot_scale_conv_new(), rot_scale_conv_new_background(), rotavg(), rotavg_i(), EMAN::rsconvolution(), set_attr(), set_attr_dict(), set_attr_python(), EMAN::varimax::set_params(), EMAN::PCAlarge::set_params(), EMAN::PCAsmall::set_params(), wustl_mm::SkeletonMaker::VolumeData::SetSize(), EMAN::BackProjectionReconstructor::setup(), EMAN::WienerFourierReconstructor::setup(), EMAN::FourierReconstructor::setup(), EMAN::FourierReconstructorSimple2D::setup(), symvol(), EMAN::Util::TwoDTestFunc(), unwrap(), EMAN::EMUtil::vertical_acf(), EMAN::Util::window(), and EMAN::Util::WTM().

00668 {
00669         ENTERFUNC;
00670 
00671         if (x <= 0) {
00672                 throw InvalidValueException(x, "x size <= 0");
00673         }
00674         else if (y <= 0) {
00675                 throw InvalidValueException(y, "y size <= 0");
00676         }
00677         else if (z <= 0) {
00678                 throw InvalidValueException(z, "z size <= 0");
00679         }
00680 
00681         int old_nx = nx;
00682 
00683         size_t size = (size_t)(x) * (size_t)y * (size_t)z * sizeof(float);
00684 
00685         if (rdata != 0) {
00686                 rdata = (float*)EMUtil::em_realloc(rdata,size);
00687         } else {
00688                 // Just pass on this for a while....see what happens
00689                 rdata = (float*)EMUtil::em_malloc(size);
00690         }
00691 //      rdata = static_cast < float *>(realloc(rdata, size));
00692         if ( rdata == 0 )
00693         {
00694                 stringstream ss;
00695                 string gigs;
00696                 ss << (float) size/1000000000.0;
00697                 ss >> gigs;
00698                 string message = "Cannot allocate " + gigs + " GB - not enough memory.";
00699                 throw BadAllocException(message);
00700         }
00701 
00702 #ifdef EMAN2_USING_CUDA
00703         // This is important
00704         free_cuda_memory();
00705 #endif // EMAN2_USING_CUDA
00706 
00707         nx = x;
00708         ny = y;
00709         nz = z;
00710         nxy = nx*ny;
00711 
00712         if (old_nx == 0) {
00713                 EMUtil::em_memset(get_data(),0,size);
00714         }
00715 
00716         if (supp) {
00717                 EMUtil::em_free(supp);
00718                 supp = 0;
00719         }
00720 
00721         update();
00722         EXITFUNC;
00723 }

void EMAN::EMData::set_complex_size ( int  nx,
int  ny = 1,
int  nz = 1 
) [inline]

Resize 'this' complex image.

Parameters:
nx x size of this image.
ny y size of this image.
nz z size of this image.

Definition at line 598 of file emdata.h.

00810                                           {

void EMAN::EMData::set_path ( const string &  new_path  )  [inline]

Set the path.

Parameters:
new_path The new path.

Definition at line 606 of file emdata.h.

Referenced by calc_mutual_correlation(), and get_clip().

00810                                           {

void EMAN::EMData::set_pathnum ( int  n  )  [inline]

Set the number of paths.

Parameters:
n The number of paths.

Definition at line 615 of file emdata.h.

Referenced by get_clip().

00810                                           {

MArray2D EMData::get_2dview (  )  const

Get image raw pixel data in a 2D multi-array format.

The array shares the memory space with the image data. Notice: the subscription order is d[y][x] in Python, it's d[x][y] in C++

It should be used on 2D image only.

Returns:
2D multi-array format of the raw data.

Definition at line 767 of file emdata_metadata.cpp.

References get_data(), get_ndim(), ImageDimensionException, nx, and ny.

00768 {
00769         const int ndims = 2;
00770         if (get_ndim() != ndims) {
00771                 throw ImageDimensionException("2D only");
00772         }
00773         boost::array<std::size_t,ndims> dims = {{nx, ny}};
00774         MArray2D marray(get_data(), dims, boost::fortran_storage_order());
00775         return marray;
00776 }

MArray3D EMData::get_3dview (  )  const

Get image raw pixel data in a 3D multi-array format.

The array shares the memory space with the image data. Notice: the subscription order is d[z][y][x] in Python, it's d[x][y][z] in C++ --grant Tang

It should be used on 3D image only.

Returns:
3D multi-array format of the raw data.

Definition at line 779 of file emdata_metadata.cpp.

References get_data(), nx, ny, and nz.

00780 {
00781         const int ndims = 3;
00782         boost::array<std::size_t,ndims> dims = {{nx, ny, nz}};
00783         MArray3D marray(get_data(), dims, boost::fortran_storage_order());
00784         return marray;
00785 }

MCArray2D EMData::get_2dcview (  )  const

Get complex image raw pixel data in a 2D multi-array format.

The array shares the memory space with the image data.

It should be used on 2D image only.

Returns:
2D multi-array format of the raw data.

Definition at line 788 of file emdata_metadata.cpp.

References get_data(), get_ndim(), ImageDimensionException, nx, and ny.

00789 {
00790         const int ndims = 2;
00791         if (get_ndim() != ndims) {
00792                 throw ImageDimensionException("2D only");
00793         }
00794         boost::array<std::size_t,ndims> dims = {{nx/2, ny}};
00795         std::complex<float>* cdata = reinterpret_cast<std::complex<float>*>(get_data());
00796         MCArray2D marray(cdata, dims, boost::fortran_storage_order());
00797         return marray;
00798 }

MCArray3D EMData::get_3dcview (  )  const

Get complex image raw pixel data in a 3D multi-array format.

The array shares the memory space with the image data.

It should be used on 3D image only.

Returns:
3D multi-array format of the raw data.

Definition at line 801 of file emdata_metadata.cpp.

References get_data(), nx, ny, and nz.

00802 {
00803         const int ndims = 3;
00804         boost::array<std::size_t,ndims> dims = {{nx/2, ny, nz}};
00805         std::complex<float>* cdata = reinterpret_cast<std::complex<float>*>(get_data());
00806         MCArray3D marray(cdata, dims, boost::fortran_storage_order());
00807         return marray;
00808 }

MCArray3D * EMData::get_3dcviewptr (  )  const

Get pointer to a complex image raw pixel data in a 3D multi-array format.

The array shares the memory space with the image data.

It should be used on 3D image only.

Returns:
Pointer to a 3D multi-array format of the raw data.

Definition at line 811 of file emdata_metadata.cpp.

References get_data(), nx, ny, and nz.

00812 {
00813         const int ndims = 3;
00814         boost::array<std::size_t,ndims> dims = {{nx/2, ny, nz}};
00815         std::complex<float>* cdata = reinterpret_cast<std::complex<float>*>(get_data());
00816         MCArray3D* marray = new MCArray3D(cdata, dims,
00817                                                                           boost::fortran_storage_order());
00818         return marray;
00819 }

MArray2D EMData::get_2dview ( int  x0,
int  y0 
) const

Get image raw pixel data in a 2D multi-array format.

The data coordinates is translated by (x0,y0) such that array[y0][x0] points to the pixel at the origin location. the data coordiates translated by (x0,y0). The array shares the memory space with the image data.

It should be used on 2D image only.

Parameters:
x0 X-axis translation amount.
y0 Y-axis translation amount.
Returns:
2D multi-array format of the raw data.

Definition at line 822 of file emdata_metadata.cpp.

References get_data(), get_ndim(), ImageDimensionException, nx, and ny.

00823 {
00824         const int ndims = 2;
00825         if (get_ndim() != ndims) {
00826                 throw ImageDimensionException("2D only");
00827         }
00828         boost::array<std::size_t,ndims> dims = {{nx, ny}};
00829         MArray2D marray(get_data(), dims, boost::fortran_storage_order());
00830         boost::array<std::size_t,ndims> bases={{x0, y0}};
00831         marray.reindex(bases);
00832         return marray;
00833 }

MArray3D EMData::get_3dview ( int  x0,
int  y0,
int  z0 
) const

Get image raw pixel data in a 3D multi-array format.

The data coordinates is translated by (x0,y0,z0) such that array[z0][y0][x0] points to the pixel at the origin location. the data coordiates translated by (x0,y0,z0). The array shares the memory space with the image data.

It should be used on 3D image only.

Parameters:
x0 X-axis translation amount.
y0 Y-axis translation amount.
z0 Z-axis translation amount.
Returns:
3D multi-array format of the raw data.

Definition at line 836 of file emdata_metadata.cpp.

References get_data(), nx, ny, and nz.

00837 {
00838         const int ndims = 3;
00839         boost::array<std::size_t,ndims> dims = {{nx, ny, nz}};
00840         MArray3D marray(get_data(), dims, boost::fortran_storage_order());
00841         boost::array<std::size_t,ndims> bases={{x0, y0, z0}};
00842         marray.reindex(bases);
00843         return marray;
00844 }

MCArray2D EMData::get_2dcview ( int  x0,
int  y0 
) const

Get complex image raw pixel data in a 2D multi-array format.

The data coordinates is translated by (x0,y0) such that array[y0][x0] points to the pixel at the origin location. the data coordiates translated by (x0,y0). The array shares the memory space with the image data.

It should be used on 2D image only.

Parameters:
x0 X-axis translation amount.
y0 Y-axis translation amount.
Returns:
2D multi-array format of the raw data.

Definition at line 847 of file emdata_metadata.cpp.

References get_data(), get_ndim(), ImageDimensionException, nx, and ny.

00848 {
00849         const int ndims = 2;
00850         if (get_ndim() != ndims) {
00851                 throw ImageDimensionException("2D only");
00852         }
00853         boost::array<std::size_t,ndims> dims = {{nx/2, ny}};
00854         std::complex<float>* cdata = reinterpret_cast<std::complex<float>*>(get_data());
00855         MCArray2D marray(cdata, dims, boost::fortran_storage_order());
00856         boost::array<std::size_t,ndims> bases={{x0, y0}};
00857         marray.reindex(bases);
00858         return marray;
00859 }

MCArray3D EMData::get_3dcview ( int  x0,
int  y0,
int  z0 
) const

Get complex image raw pixel data in a 3D multi-array format.

The data coordinates is translated by (x0,y0,z0) such that array[z0][y0][x0] points to the pixel at the origin location. the data coordiates translated by (x0,y0,z0). The array shares the memory space with the image data.

It should be used on 3D image only.

Parameters:
x0 X-axis translation amount.
y0 Y-axis translation amount.
z0 Z-axis translation amount.
Returns:
3D multi-array format of the raw data.

Definition at line 862 of file emdata_metadata.cpp.

References get_data(), nx, ny, and nz.

00863 {
00864         const int ndims = 3;
00865         boost::array<std::size_t,ndims> dims = {{nx/2, ny, nz}};
00866         std::complex<float>* cdata = reinterpret_cast<std::complex<float>*>(get_data());
00867         MCArray3D marray(cdata, dims, boost::fortran_storage_order());
00868         boost::array<std::size_t,ndims> bases={{x0, y0, z0}};
00869         marray.reindex(bases);
00870         return marray;
00871 }

EMObject EMData::get_attr ( const string &  attr_name  )  const

The generic way to get any image header information given a header attribute name.

If the attribute does not exist, it will raise an exception.

Parameters:
attr_name The header attribute name.
Returns:
The attribute value.
Exceptions:
NotExistingObjectException when attribute not exist

Definition at line 883 of file emdata_metadata.cpp.

References attr_dict, BadAllocException, changecount, data, ENTERFUNC, EXITFUNC, get_data(), greaterthan(), EMAN::Dict::has_key(), ImageFormatException, is_complex(), median(), NotExistingObjectException, nx, ny, nz, t, and update_stat().

Referenced by EMAN::file_store::add_image(), EMAN::newfile_store::add_image(), EMAN::CtfCWautoAverager::add_image(), ali3d_d(), EMAN::RotateFlipAligner::align(), EMAN::RotateTranslateFlipAligner::align(), EMAN::RotateTranslateAligner::align(), EMAN::RotationalAligner::align(), EMAN::Util::BPCQ(), calc_center_density(), calc_center_of_mass(), calc_hist(), EMAN::NormalizeStdProcessor::calc_mean(), EMAN::NormalizeMaxMinProcessor::calc_mean(), EMAN::NormalizeMaxMinProcessor::calc_sigma(), EMAN::NormalizeUnitSumProcessor::calc_sigma(), EMAN::NormalizeUnitProcessor::calc_sigma(), EMAN::NormalizeProcessor::calc_sigma(), calc_sigma_diff(), EMAN::FRCCmp::cmp(), EMAN::TomoDotCmp::cmp(), EMAN::DotCmp::cmp(), EMAN::SetSFProcessor::create_radial_func(), EMAN::MatchSFProcessor::create_radial_func(), EMAN::FourierReconstructor::determine_slice_agreement(), find_3d_threshold(), EMAN::IterationAverager::finish(), get_attr_default(), EMAN::AddSigmaNoiseProcessor::get_sigma(), wustl_mm::SkeletonMaker::VolumeData::GetOriginX(), wustl_m