EMAN2
Functions
emdata_metadata.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

EMDataget_fft_amplitude ()
 This file is a part of "emdata.h", to use functions in this file, you should "#include "emdata.h", NEVER directly include this file. More...
 
EMDataget_fft_amplitude2D ()
 return the amplitudes of the 2D FFT including the left half PRB More...
 
EMDataget_fft_phase ()
 return the phases of the FFT including the left half More...
 
float * get_data () const
 Get the image pixel density data in a 1D float array. More...
 
const float * get_const_data () const
 Get the image pixel density data in a 1D float array - const version of get_data. More...
 
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! More...
 
void set_data (float *data)
 
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. More...
 
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. More...
 
void update ()
 Mark EMData as changed, statistics, etc will be updated at need. More...
 
void clearupdate ()
 turn off updates. More...
 
bool has_ctff () const
 check whether the image physical file has the CTF info or not. More...
 
float calc_center_density ()
 Calculates the density value at the peak of the image histogram, sort of like the mode of the density. More...
 
float calc_sigma_diff ()
 Calculates sigma above and below the mean and returns the difference between them. More...
 
IntPoint calc_min_location () const
 Calculates the coordinates of the minimum-value pixel. More...
 
IntPoint calc_max_location () const
 Calculates the coordinates of the maximum-value pixel. More...
 
IntPoint calc_max_location_wrap (const int maxshiftx=-1, const int maxshifty=-1, const int maxshiftz=-1, float *value=0)
 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 If *value is provided, it will be set to the value at the max location. More...
 
vector< float > calc_max_location_wrap_intp (const int maxshiftx=-1, const int maxshifty=-1, const int maxshiftz=-1)
 Calculates the wrapped coordinates of the maximum value, and uses quadration intp to subpixel prec 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. More...
 
FloatPoint calc_center_of_mass (const float threshold=0)
 Calculate the center of mass with a threshold (Default 0, so only positive values are considered) More...
 
size_t calc_min_index () const
 Calculates the index of minimum-value pixel when assuming all pixels are in a 1D array. More...
 
size_t calc_max_index () const
 Calculates the index of maximum-value pixel when assuming all pixels are in a 1D array. More...
 
vector< Pixelcalc_highest_locations (float threshold) const
 Calculate and return a sorted list of pixels whose values are above a specified threshold. More...
 
vector< Pixelcalc_n_highest_locations (int n)
 Calculate and return a sorted list of N highest pixels in the map. More...
 
vector< Pixelfind_pixels_with_value (float val)
 Find pixels in the image with exactly the specified values. More...
 
float get_edge_mean () const
 Calculates the mean pixel values around the (1 pixel) edge of the image. More...
 
float get_circle_mean ()
 Calculates the circular edge mean by applying a circular mask on 'this' image. More...
 
Ctfget_ctf () const
 Get ctf parameter of this image. More...
 
void set_ctf (Ctf *ctf)
 Set the CTF parameter of this image. More...
 
Vec3f get_translation () const
 Get 'this' image's translation vector from the original location. More...
 
void set_translation (const Vec3f &t)
 Set 'this' images' translation vector from the original location. More...
 
void set_translation (float dx, float dy, float dz)
 Set 'this' images' translation vector from the original location. More...
 
Transform get_transform () const
 Get the 3D orientation of 'this' image. More...
 
void set_rotation (float az, float alt, float phi)
 Define the 3D orientation of this particle, also used to indicate relative rotations for reconstructions. More...
 
void set_rotation (const Transform &t3d)
 Define the 3D orientation of this particle Orientation information is extracted from a Transform object and stored internally in EMAN (az,alt,phi) format. More...
 
void set_size (int nx, int ny=1, int nz=1, bool noalloc=false)
 Resize this EMData's main board memory pointer. More...
 
void set_complex_size (int nx, int ny=1, int nz=1)
 Resize 'this' complex image. More...
 
void set_path (const string &new_path)
 Set the path. More...
 
void set_pathnum (int n)
 Set the number of paths. More...
 
MArray2D get_2dview () const
 Get image raw pixel data in a 2D multi-array format. More...
 
MArray3D get_3dview () const
 Get image raw pixel data in a 3D multi-array format. More...
 
MCArray2D get_2dcview () const
 Get complex image raw pixel data in a 2D multi-array format. More...
 
MCArray3D get_3dcview () const
 Get complex image raw pixel data in a 3D multi-array format. More...
 
EMObject get_attr (const string &attr_name) const
 The generic way to get any image header information given a header attribute name. More...
 
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. More...
 
void set_attr (const string &key, EMObject val)
 Set a header attribute's value. More...
 
void set_attr_python (const string &key, EMObject val)
 Set a header attribute's value from Python. More...
 
bool has_attr (const string &key) const
 Ask if the header has a particular attribute. More...
 
Dict get_attr_dict () const
 Get the image attribute dictionary containing all the image attribute names and attribute values. More...
 
void set_attr_dict (const Dict &new_dict)
 Merge the new values with the existing dictionary. More...
 
void del_attr (const string &attr_name)
 Delete the attribute from dictionary. More...
 
void del_attr_dict (const vector< string > &del_keys)
 Delete the attributes from the dictionary. More...
 
int get_xsize () const
 Get the image x-dimensional size. More...
 
int get_ysize () const
 Get the image y-dimensional size. More...
 
int get_zsize () const
 Get the image z-dimensional size. More...
 
IntSize get_sizes () const
 
size_t get_size () const
 Get the number of allocated floats in the image (nx*ny*nz) More...
 
vector< float > get_data_as_vector () const
 Get the pixel data as a vector. More...
 
int get_ndim () const
 Get image dimension. More...
 
bool is_shuffled () const
 Has this image been shuffled? More...
 
bool is_FH () const
 Is this a FH image? More...
 
bool is_complex () const
 Is this a complex image? More...
 
bool is_real () const
 Is this a real image? More...
 
void set_shuffled (bool is_shuffled)
 Mark this image as a shuffled image. More...
 
void set_FH (bool is_FH)
 Mark this complex image as a FH image. More...
 
void set_complex (bool is_complex)
 Mark this image as a complex image. More...
 
bool is_complex_x () const
 Is this image a 1D FFT image in X direction? More...
 
void set_complex_x (bool is_complex_x)
 Marks this image a 1D FFT image in X direction. More...
 
bool is_flipped () const
 Is this image flipped? More...
 
void set_flipped (bool is_flipped)
 Mark this image as flipped. More...
 
bool is_ri () const
 Is this image a real/imaginary format complex image? More...
 
void set_ri (bool is_ri)
 Mark this image as a real/imaginary format complex image. More...
 
bool is_fftpadded () const
 Is this image already extended along x for ffts? More...
 
void set_fftpad (bool is_fftpadded)
 Mark this image as already extended along x for ffts. More...
 
bool is_fftodd () const
 Does this image correspond to a (real-space) odd nx? More...
 
void set_fftodd (bool is_fftodd)
 Mark this image as having (real-space) odd nx. More...
 
void set_nxc (int nxc)
 Set the number of complex elements along x. More...
 
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) More...
 
string get_path () const
 
int get_pathnum () const
 
EMBytes get_data_pickle () const
 
void set_data_pickle (std::string vf)
 
int get_supp_pickle () const
 
void set_supp_pickle (int i)
 
vector< Vec3i > mask_contig_region (const float &val, const Vec3i &seed)
 
float get_amplitude_thres (float thres)
 return the FFT amplitude which is greater than thres % More...
 
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. More...
 

Function Documentation

◆ calc_center_density()

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 251 of file emdata_metadata.cpp.

252{
253 ENTERFUNC;
254
255 float center = get_attr("mean");
256 float sigma = get_attr("sigma");
257 float ds = sigma / 2;
258 size_t size = (size_t)nx * ny * nz;
259 float *d = get_data();
260 float sigma1 = sigma / 20;
261 float sigma2 = sigma / 1000;
262
263 while (ds > sigma1) {
264 double sum = 0;
265 int norm = 0;
266
267 for (size_t i = 0; i < size; ++i) {
268 if (fabs(d[i] - center) < ds) {
269 sum += d[i];
270 norm++;
271 }
272 }
273 if (!norm) {
274 break;
275 }
276 float mean = (float)(sum / norm);
277 if (fabs(mean - center) < sigma2) {
278 ds *= 0.5f;
279 }
280 center = mean;
281 }
282 EXITFUNC;
283
284 return center;
285}
EMObject get_attr(const string &attr_name) const
The generic way to get any image header information given a header attribute name.
float * get_data() const
Get the image pixel density data in a 1D float array.
#define ENTERFUNC
Definition: log.h:48
#define EXITFUNC
Definition: log.h:49

References ENTERFUNC, EXITFUNC, get_attr(), get_data(), EMAN::EMData::nx, EMAN::EMData::ny, and EMAN::EMData::nz.

◆ calc_center_of_mass()

FloatPoint EMData::calc_center_of_mass ( const float  threshold = 0)

Calculate the center of mass with a threshold (Default 0, so only positive values are considered)

Author
Steve Ludtke
Date
Fri Jun 6th 2008

Definition at line 572 of file emdata_metadata.cpp.

573{
574 float *data = get_data();
575
576 //float sigma = get_attr("sigma");
577 //float mean = get_attr("mean");
578 float m = 0.0;
579
580 FloatPoint com(0,0,0);
581 for (int i = 0; i < nx; ++i) {
582 for (int j = 0; j < ny; ++j) {
583 int j2 = nx * j;
584 for (int k = 0; k < nz; ++k) {
585 size_t l = i + j2 + (size_t)k * nxy;
586 if (data[l] >= threshold) { // threshold out noise (and negative density)
587 com[0] += i * data[l];
588 com[1] += j * data[l];
589 com[2] += k * data[l];
590 m += data[l];
591 }
592 }
593 }
594 }
595
596 com[0] /= m;
597 com[1] /= m;
598 com[2] /= m;
599
600 return com;
601}
FloatPoint defines a float-coordinate point in a 1D/2D/3D space.
Definition: geometry.h:278

References get_data(), EMAN::EMData::nx, EMAN::EMData::nxy, EMAN::EMData::ny, and EMAN::EMData::nz.

◆ calc_highest_locations()

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

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

The pixels are sorted from high to low.

Parameters
thresholdThe 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 620 of file emdata_metadata.cpp.

621{
622 ENTERFUNC;
623
624 vector<Pixel> result;
625
626 int di = 1;
627 if (is_complex() && !is_ri()) {
628 di = 2;
629 }
630
631 int nxy = nx * ny;
632 float * data = get_data();
633
634 for (int j = 0; j < nz; ++j) {
635 size_t cur_z = (size_t)j * nxy;
636
637 for (int k = 0; k < ny; ++k) {
638 size_t cur_y = k * nx + cur_z;
639
640 for (int l = 0; l < nx; l += di) {
641 float v =data[l + cur_y];
642 if (v > threshold) {
643 result.push_back(Pixel(l, k, j, v));
644 }
645 }
646 }
647 }
648
649 std::sort(result.begin(), result.end());
650 std::reverse(result.begin(), result.end());
651
652 EXITFUNC;
653 return result;
654}
Pixel describes a 3D pixel's coordinates and its intensity value.
Definition: geometry.h:452
bool is_ri() const
Is this image a real/imaginary format complex image?
bool is_complex() const
Is this a complex image?

References ENTERFUNC, EXITFUNC, get_data(), is_complex(), is_ri(), EMAN::EMData::nx, EMAN::EMData::nxy, EMAN::EMData::ny, and EMAN::EMData::nz.

◆ calc_max_index()

size_t 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 612 of file emdata_metadata.cpp.

613{
614 IntPoint max_location = calc_max_location();
615 size_t i = max_location[0] + max_location[1] * nx + (size_t)max_location[2] * nx * ny;
616 return i;
617}
IntPoint defines an integer-coordinate point in a 1D/2D/3D space.
Definition: geometry.h:192
IntPoint calc_max_location() const
Calculates the coordinates of the maximum-value pixel.

References calc_max_location(), EMAN::EMData::nx, and EMAN::EMData::ny.

◆ calc_max_location()

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 363 of file emdata_metadata.cpp.

364{
365 ENTERFUNC;
366
367 int di = 1;
368 if (is_complex() && !is_ri()) {
369 di = 2;
370 }
371
372 float max = -FLT_MAX;
373 int max_x = 0;
374 int max_y = 0;
375 int max_z = 0;
376 int nxy = nx * ny;
377 float * data = get_data();
378
379 for (int j = 0; j < nz; ++j) {
380 size_t cur_z = (size_t)j * nxy;
381
382 for (int k = 0; k < ny; ++k) {
383 size_t cur_y = k * nx + cur_z;
384
385 for (int l = 0; l < nx; l += di) {
386 float t = data[l + cur_y];
387 if (t > max) {
388 max_x = l;
389 max_y = k;
390 max_z = j;
391 max = t;
392 }
393 }
394 }
395 }
396
397 EXITFUNC;
398 return IntPoint(max_x, max_y, max_z);
399}

References ENTERFUNC, EXITFUNC, get_data(), is_complex(), is_ri(), EMAN::EMData::nx, EMAN::EMData::nxy, EMAN::EMData::ny, and EMAN::EMData::nz.

Referenced by calc_max_index().

◆ calc_max_location_wrap()

IntPoint EMData::calc_max_location_wrap ( const int  maxshiftx = -1,
const int  maxshifty = -1,
const int  maxshiftz = -1,
float *  value = 0 
)

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 If *value is provided, it will be set to the value at the max location.

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

Definition at line 402 of file emdata_metadata.cpp.

403{
404 int maxshiftx = maxdx, maxshifty = maxdy, maxshiftz = maxdz;
405 if (maxdx == -1) maxshiftx = get_xsize()/4;
406 if (maxdy == -1) maxshifty = get_ysize()/4;
407 if (maxdz == -1) maxshiftz = get_zsize()/4;
408
409 float max_value = -FLT_MAX;
410
411 IntPoint peak(0,0,0);
412
413#ifdef EMAN2_USING_CUDA //CUDA
414 if(EMData::usecuda == 1 && cudarwdata){
415
416 CudaPeakInfo* soln = calc_max_location_wrap_cuda(cudarwdata, nx, ny, nz, maxdx, maxdy, maxdz);
417
418 peak[0] = soln->px;
419 peak[1] = soln->py;
420 peak[2] = soln->pz;
421 free(soln);
422
423// cout << "x " << peak[0] << " y " << peak[1] << " z " << peak[2] << endl;
424 return peak;
425 }
426#endif
427 for (int k = -maxshiftz; k <= maxshiftz; k++) {
428 for (int j = -maxshifty; j <= maxshifty; j++) {
429 for (int i = -maxshiftx; i <= maxshiftx; i++) {
430
431 float value = get_value_at_wrap(i,j,k);
432
433 if (value > max_value) {
434 max_value = value;
435 peak[0] = i;
436 peak[1] = j;
437 peak[2] = k;
438 }
439 }
440 }
441 }
442 if (value) *value=max_value;
443
444 return peak;
445}
CudaPeakInfo * calc_max_location_wrap_cuda(const float *in, const int nx, const int ny, const int nz, const int maxdx, const int maxdy, const int maxdz)
float get_value_at_wrap(int x, int y, int z) const
Get the pixel density value at coordinates (x,y,z).
int get_ysize() const
Get the image y-dimensional size.
int get_zsize() const
Get the image z-dimensional size.
int get_xsize() const
Get the image x-dimensional size.

References calc_max_location_wrap_cuda(), get_value_at_wrap(), get_xsize(), get_ysize(), get_zsize(), EMAN::EMData::nx, EMAN::EMData::ny, EMAN::EMData::nz, CudaPeakInfo::px, CudaPeakInfo::py, and CudaPeakInfo::pz.

◆ calc_max_location_wrap_intp()

vector< float > EMData::calc_max_location_wrap_intp ( const int  maxshiftx = -1,
const int  maxshifty = -1,
const int  maxshiftz = -1 
)

Calculates the wrapped coordinates of the maximum value, and uses quadration intp to subpixel prec 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
John Flanagan
Date
Mon Mar 7th 2011

#ifdef EMAN2_USING_CUDA //CUDA if(cudarwdata){

    CudaPeakInfo* soln = calc_max_location_wrap_cuda(cudarwdata, nx, ny, nz, maxdx, maxdy, maxdz);

    peak[0] = soln->px;
    peak[1] = soln->py;
    peak[2] = soln->pz;
    free(soln);

cout << "x " << peak[0] << " y " << peak[1] << " z " << peak[2] << endl; return peak; } #endif

I guess I could use GSL, but this is faster.... float x1 = float(peak[0]) - 1.0f; float x2 = float(peak[0]); float x3 = float(peak[0]) + 1.0f; float y1 = float(peak[1]) - 1.0f; float y2 = float(peak[1]); float y3 = float(peak[1]) + 1.0f; float z1 = float(peak[2]) - 1.0f; float z2 = float(peak[2]); float z3 = float(peak[2]) + 1.0f;

float yx1 = get_value_at_wrap(x1,y2,z2); float yx2 = get_value_at_wrap(x2,y2,z2); float yx3 = get_value_at_wrap(x3,y2,z2); float yy1 = get_value_at_wrap(x2,y1,z2); float yy2 = get_value_at_wrap(x2,y2,z2); float yy3 = get_value_at_wrap(x2,y3,z2); float yz1 = get_value_at_wrap(x2,y2,z1); float yz2 = get_value_at_wrap(x2,y2,z2); float yz3 = get_value_at_wrap(x2,y2,z3);

Fit peak in X to y = ax^2 + bx +c float bx = ((yx1 - yx2)*(x2*x2 - x3*x3)/(x1*x1 - x2*x2) - (yx2-yx3))/(-(x2 - x3) + (x1 - x2)*(x2*x2 - x3*x3)/(x1*x1 - x2*x2)); float ax = ((yx1 - yx2) - bx*(x1 - x2))/(x1*x1 - x2*x2); Find minima float xintp = -bx/(2*ax);

Fit peak in X to y = ax^2 + bx +c float by = ((yy1 - yy2)*(x2*x2 - x3*x3)/(x1*x1 - x2*x2) - (yy2-yy3))/(-(x2 - x3) + (x1 - x2)*(x2*x2 - x3*x3)/(x1*x1 - x2*x2)); float ay = ((yy1 - yy2) - by*(x1 - x2))/(x1*x1 - x2*x2); Find minima float yintp = -by/(2*ay);

Fit peak in X to y = ax^2 + bx +c float bz = ((yz1 - yz2)*(x2*x2 - x3*x3)/(x1*x1 - x2*x2) - (yz2-yz3))/(-(x2 - x3) + (x1 - x2)*(x2*x2 - x3*x3)/(x1*x1 - x2*x2)); float az = ((yz1 - yz2) - bz*(x1 - x2))/(x1*x1 - x2*x2); Find minima float zintp = -bz/(2*az);

vector<float> mydata; mydata.push_back(xintp); mydata.push_back(yintp); mydata.push_back(zintp); mydata.push_back(max_value);

Definition at line 447 of file emdata_metadata.cpp.

448{
449 int maxshiftx = maxdx, maxshifty = maxdy, maxshiftz = maxdz;
450 if (maxdx == -1) maxshiftx = get_xsize()/4;
451 if (maxdy == -1) maxshifty = get_ysize()/4;
452 if (maxdz == -1) maxshiftz = get_zsize()/4;
453
454 float max_value = -FLT_MAX;
455 float is3d=(get_zsize()==1?0:1);
456 maxshiftz=maxshiftz*is3d;
457
458 IntPoint peak(0,0,0);
459
460// NOT yet working......
477 for (int k = -maxshiftz; k <= maxshiftz; k++) {
478 for (int j = -maxshifty; j <= maxshifty; j++) {
479 for (int i = -maxshiftx; i <= maxshiftx; i++) {
480
481 float value = get_value_at_wrap(i,j,k);
482
483 if (value > max_value) {
484 max_value = value;
485 peak[0] = i;
486 peak[1] = j;
487 peak[2] = k;
488 }
489 }
490 }
491 }
492
493// printf("%d,%d,%d\t%f\n",peak[0], peak[1], peak[2], max_value);
494 // compute the center of mass
495 float cmx = 0.0; float cmy = 0.0f; float cmz = 0.0f;
496 float sval = 0.0f;
497 for (float x = float(peak[0])-2.0f; x <= float(peak[0])+2.0f; x++) {
498 for (float y = float(peak[1])-2.0f; y <= float(peak[1])+2.0f; y++) {
499 for (float z = float(peak[2])-is3d*2.0f; z <= float(peak[2])+is3d*2.0f; z++) {
500 //Compute center of mass
501 float val = get_value_at_wrap(x,y,z);
502
503// printf("%.2f,%.2f, %.2f\t%.2f,%.2f,%.2f\n",x, y, val, cmx, cmy, sval);
504 if (val>0){
505 cmx += x*val;
506 cmy += y*val;
507 cmz += z*val;
508 sval += val;
509 }
510 }
511 }
512 }
513 cmx /= sval;
514 cmy /= sval;
515 cmz /= sval;
516
517 vector<float> mydata;
518 mydata.push_back(cmx);
519 mydata.push_back(cmy);
520 mydata.push_back(cmz);
521 mydata.push_back(max_value);
522
569 return mydata;
570}
#define y(i, j)
Definition: projector.cpp:1516
#define x(i)
Definition: projector.cpp:1517

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

◆ calc_min_index()

size_t 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 604 of file emdata_metadata.cpp.

605{
606 IntPoint min_location = calc_min_location();
607 size_t i = min_location[0] + min_location[1] * nx + (size_t)min_location[2] * nx * ny;
608 return i;
609}
IntPoint calc_min_location() const
Calculates the coordinates of the minimum-value pixel.

References calc_min_location(), EMAN::EMData::nx, and EMAN::EMData::ny.

◆ calc_min_location()

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 325 of file emdata_metadata.cpp.

326{
327 ENTERFUNC;
328
329 int di = 1;
330 if (is_complex() && !is_ri()) {
331 di = 2;
332 }
333
334 float min = FLT_MAX;
335 int min_x = 0;
336 int min_y = 0;
337 int min_z = 0;
338 int nxy = nx * ny;
339 float * data = get_data();
340
341 for (int j = 0; j < nz; ++j) {
342 size_t cur_z = (size_t)j * nxy;
343
344 for (int k = 0; k < ny; ++k) {
345 size_t cur_y = k * nx + cur_z;
346
347 for (int l = 0; l < nx; l += di) {
348 float t = data[l + cur_y];
349 if (t < min) {
350 min_x = l;
351 min_y = k;
352 min_z = j;
353 min = t;
354 }
355 }
356 }
357 }
358
359 return IntPoint(min_x, min_y, min_z);
360}

References ENTERFUNC, get_data(), is_complex(), is_ri(), EMAN::EMData::nx, EMAN::EMData::nxy, EMAN::EMData::ny, and EMAN::EMData::nz.

Referenced by calc_min_index().

◆ calc_n_highest_locations()

vector< Pixel > EMData::calc_n_highest_locations ( int  n)

Calculate and return a sorted list of N highest pixels in the map.

Parameters
nThe number of highest value pixels should be returned.
Returns
A sorted list of N pixels with their values, and locations.

Definition at line 656 of file emdata_metadata.cpp.

657{
658 ENTERFUNC;
659
660 vector<Pixel> result;
661
662 int di = 1;
663 if (is_complex() && !is_ri()) {
664 di = 2;
665 }
666
667 // initialize with n elements
668 float * data = get_data();
669 for ( int i=0; i<n; i++) result.push_back(Pixel(0,0,0,-data[0]));
670
671 int nxy = nx * ny;
672
673 for (int j = 0; j < nz; ++j) {
674 size_t cur_z = (size_t)j * nxy;
675
676 for (int k = 0; k < ny; ++k) {
677 size_t cur_y = k * nx + cur_z;
678
679 for (int l = 0; l < nx; l += di) {
680 float v =data[l + cur_y];
681 if (v<result[n-1].value) continue;
682 for (vector<Pixel>::iterator i=result.begin(); i<result.end(); i++) {
683 if (v>(*i).value) { result.insert(i,Pixel(l, k, j, v)); result.pop_back(); break; }
684 }
685 }
686 }
687 }
688
689 EXITFUNC;
690 return result;
691}

References ENTERFUNC, EXITFUNC, get_data(), is_complex(), is_ri(), EMAN::EMData::nx, EMAN::EMData::nxy, EMAN::EMData::ny, and EMAN::EMData::nz.

◆ calc_sigma_diff()

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 288 of file emdata_metadata.cpp.

289{
290 ENTERFUNC;
291
292 float *d = get_data();
293 float mean = get_attr("mean");
294 float sigma = get_attr("sigma");
295
296 double sum_up = 0;
297 double sum_down = 0;
298 int nup = 0;
299 int ndown = 0;
300
301 size_t size = (size_t)nx * ny * nz;
302
303 for (size_t i = 0; i < size; ++i) {
304 if (d[i] > mean) {
305 sum_up += Util::square(d[i] - mean);
306 nup++;
307 }
308 else {
309 sum_down += Util::square(mean - d[i]);
310 ndown++;
311 }
312 }
313
314 float sigup = std::sqrt((float)sum_up / nup);
315 float sigdown = std::sqrt((float)sum_down / ndown);
316 float sig_diff = fabs(sigup - sigdown) / sigma;
317
318
319 EXITFUNC;
320 return sig_diff;
321
322}
EMData * sqrt() const
return square root of current image

References ENTERFUNC, EXITFUNC, get_attr(), get_data(), EMAN::EMData::nx, EMAN::EMData::ny, EMAN::EMData::nz, sqrt(), and EMAN::Util::square().

◆ clearupdate()

void clearupdate ( )
inline

turn off updates.

Useful to avoid wasteful recacling stats

Definition at line 149 of file emdata_metadata.h.

150{
151 flags &= ~EMDATA_NEEDUPD;
152 changecount--;
153}

◆ del_attr()

void EMData::del_attr ( const string &  attr_name)

Delete the attribute from dictionary.

Parameters
attr_namethe attribute name to be removed

Definition at line 1200 of file emdata_metadata.cpp.

1201{
1202 attr_dict.erase(attr_name);
1203}

References EMAN::EMData::attr_dict, and EMAN::Dict::erase().

Referenced by del_attr_dict().

◆ del_attr_dict()

void EMData::del_attr_dict ( const vector< string > &  del_keys)

Delete the attributes from the dictionary.

Parameters
del_keysthe attrutes' names to be removed

Definition at line 1205 of file emdata_metadata.cpp.

1206{
1207 vector<string>::const_iterator it;
1208 for(it=del_keys.begin(); it!=del_keys.end(); ++it) {
1209 this->del_attr(*it);
1210 }
1211}
void del_attr(const string &attr_name)
Delete the attribute from dictionary.

References del_attr().

◆ find_pixels_with_value()

vector< Pixel > EMData::find_pixels_with_value ( float  val)

Find pixels in the image with exactly the specified values.

Parameters
valThe value to look for
Returns
An array of pixels with the specified values

Definition at line 693 of file emdata_metadata.cpp.

694{
695 ENTERFUNC;
696
697 if ( is_complex() ) throw ImageFormatException("Error - find_pixels_with_value real only");
698
699 vector<Pixel> result;
700
701 for (int k = 0; k < nz; k++) {
702 for (int j = 0; j < ny; j++) {
703 for (int i = 0; i < nx; i++) {
704 if (get_value_at(i,j,k)==val) result.push_back(Pixel(i,j,k,val));
705 }
706 }
707 }
708
709 EXITFUNC;
710 return result;
711}
float get_value_at(int x, int y, int z) const
Get the pixel density value at coordinates (x,y,z).
Definition: emdata_core.h:221
#define ImageFormatException(desc)
Definition: exception.h:147

References ENTERFUNC, EXITFUNC, get_value_at(), ImageFormatException, is_complex(), EMAN::EMData::nx, EMAN::EMData::ny, and EMAN::EMData::nz.

◆ get_2dcview()

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 973 of file emdata_metadata.cpp.

974{
975 const int ndims = 2;
976 if (get_ndim() != ndims) {
977 throw ImageDimensionException("2D only");
978 }
979 boost::array<std::size_t,ndims> dims = {{(size_t)nx/2, (size_t)ny}};
980 std::complex<float>* cdata = reinterpret_cast<std::complex<float>*>(get_data());
981 MCArray2D marray(cdata, dims, boost::fortran_storage_order());
982 return marray;
983}
int get_ndim() const
Get image dimension.
#define ImageDimensionException(desc)
Definition: exception.h:166
boost::multi_array_ref< std::complex< float >, 2 > MCArray2D
Definition: emdata.h:70

References get_data(), get_ndim(), ImageDimensionException, EMAN::EMData::nx, and EMAN::EMData::ny.

◆ get_2dview()

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 952 of file emdata_metadata.cpp.

953{
954 const int ndims = 2;
955 if (get_ndim() != ndims) {
956 throw ImageDimensionException("2D only");
957 }
958 boost::array<std::size_t,ndims> dims = {{(size_t)nx, (size_t)ny}};
959 MArray2D marray(get_data(), dims, boost::fortran_storage_order());
960 return marray;
961}
boost::multi_array_ref< float, 2 > MArray2D
Definition: emdata.h:68

References get_data(), get_ndim(), ImageDimensionException, EMAN::EMData::nx, and EMAN::EMData::ny.

◆ get_3dcview()

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 986 of file emdata_metadata.cpp.

987{
988 const int ndims = 3;
989 boost::array<std::size_t,ndims> dims = {{(size_t)nx/2, (size_t)ny, (size_t)nz}};
990 std::complex<float>* cdata = reinterpret_cast<std::complex<float>*>(get_data());
991 MCArray3D marray(cdata, dims, boost::fortran_storage_order());
992 return marray;
993}
boost::multi_array_ref< std::complex< float >, 3 > MCArray3D
Definition: emdata.h:71

References get_data(), EMAN::EMData::nx, EMAN::EMData::ny, and EMAN::EMData::nz.

◆ get_3dview()

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 964 of file emdata_metadata.cpp.

965{
966 const int ndims = 3;
967 boost::array<std::size_t,ndims> dims = {{(size_t)nx, (size_t)ny, (size_t)nz}};
968 MArray3D marray(get_data(), dims, boost::fortran_storage_order());
969 return marray;
970}
boost::multi_array_ref< float, 3 > MArray3D
Definition: emdata.h:69

References get_data(), EMAN::EMData::nx, EMAN::EMData::ny, and EMAN::EMData::nz.

◆ get_amplitude_thres()

float EMData::get_amplitude_thres ( float  thres)

return the FFT amplitude which is greater than thres %

Exceptions
ImageFormatExceptionIf the image is not a complex image.
Returns
The FFT amplitude which is greater than thres %.

Definition at line 1326 of file emdata_metadata.cpp.

1327{
1328
1329 if (thres < 0 || thres > 1){
1330 LOGERR("threshold bust be between 0 and 1.");
1331 throw InvalidValueException(thres, "thres: 0 <= thres <= 1");
1332 }
1333
1334 EMData * amps = get_fft_amplitude();
1335 vector<float> ampvector = amps->get_data_as_vector();
1336 // yes I realize this may be slow if the map is big, but then again this function is only suited for tomo alignments, which if you have a big map will be VERY slow anyways!
1337 sort (ampvector.begin(), ampvector.end());
1338 int thresidx = int(thres * ampvector.size());
1339 float thresamp = ampvector[thresidx];
1340
1341 return thresamp;
1342}
EMData stores an image's data and defines core image processing routines.
Definition: emdata.h:82
EMData * get_fft_amplitude()
This file is a part of "emdata.h", to use functions in this file, you should "#include "emdata....
#define InvalidValueException(val, desc)
Definition: exception.h:285
#define LOGERR
Definition: log.h:51

References get_fft_amplitude(), InvalidValueException, and LOGERR.

◆ get_attr()

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_nameThe header attribute name.
Returns
The attribute value.
Exceptions
NotExistingObjectExceptionwhen attribute not exist

Definition at line 1006 of file emdata_metadata.cpp.

1007{
1008 ENTERFUNC;
1009
1010 if ((flags & EMDATA_NEEDUPD) && (key != "is_fftpad") && (key != "xform.align2d")){update_stat();} //this gives a spped up of 7.3% according to e2speedtest
1011
1012 size_t size = (size_t)nx * ny * nz;
1013 if (key == "kurtosis") {
1014 float mean = attr_dict["mean"];
1015 float sigma = attr_dict["sigma"];
1016
1017 float *data = get_data();
1018 double kurtosis_sum = 0;
1019
1020 for (size_t k = 0; k < size; ++k) {
1021 float t = (data[k] - mean) / sigma;
1022 float tt = t * t;
1023 kurtosis_sum += tt * tt;
1024 }
1025
1026 float kurtosis = (float)(kurtosis_sum / size - 3.0);
1027 return kurtosis;
1028 }
1029 else if (key == "skewness") {
1030 float mean = attr_dict["mean"];
1031 float sigma = attr_dict["sigma"];
1032
1033 float *data = get_data();
1034 double skewness_sum = 0;
1035 for (size_t k = 0; k < size; ++k) {
1036 float t = (data[k] - mean) / sigma;
1037 skewness_sum += t * t * t;
1038 }
1039 float skewness = (float)(skewness_sum / size);
1040 return skewness;
1041 }
1042 else if (key == "moment_inertia") {
1043 double moment=0;
1044 if (ny==1 && nz==1) throw ImageFormatException("Error - cannot calculate moment of inertia of 1-D image");
1045 if (nz==1) {
1046 for (int y=0; y<ny; y++) {
1047 for (int x=0; x<nx; x++) {
1048 double v=get_value_at(x,y);
1049 if (v<=0) continue;
1050 moment+=v*(double)Util::hypot2sq(x-nx/2,y-ny/2);
1051 }
1052 }
1053 }
1054 else {
1055 for (int z=0; z<nz; z++) {
1056 for (int y=0; y<ny; y++) {
1057 for (int x=0; x<nx; x++) {
1058 double v=get_value_at(x,y,z);
1059 if (v<=0) continue;
1060 moment+=v*(double)Util::hypot3sq(x-nx/2,y-ny/2,z-nz/2);
1061 }
1062 }
1063 }
1064 }
1065 return (float)moment;
1066 }
1067 else if (key == "radius_gyration") {
1068 double moment=0;
1069 double mass=0;
1070 if (ny==1 && nz==1) throw ImageFormatException("Error - cannot calculate moment of inertia of 1-D image");
1071 if (nz==1) {
1072 for (int y=0; y<ny; y++) {
1073 for (int x=0; x<nx; x++) {
1074 double v=get_value_at(x,y);
1075 if (v<=0) continue;
1076 mass+=v;
1077 moment+=v*(double)Util::hypot2sq(x-nx/2,y-ny/2);
1078 }
1079 }
1080 }
1081 else {
1082 for (int z=0; z<nz; z++) {
1083 for (int y=0; y<ny; y++) {
1084 for (int x=0; x<nx; x++) {
1085 double v=get_value_at(x,y,z);
1086 if (v<=0) continue;
1087 mass+=v;
1088 moment+=v*(double)Util::hypot3sq(x-nx/2,y-ny/2,z-nz/2);
1089 }
1090 }
1091 }
1092 }
1093 return (float)(std::sqrt(moment/mass));
1094 }
1095 else if (key == "median")
1096 {
1097 if ( is_complex() ) throw ImageFormatException("Error - can not calculate the median of a complex image");
1098 size_t n = size;
1099 float* tmp = new float[n];
1100 float* d = get_data();
1101 if (tmp == 0 ) throw BadAllocException("Error - could not create deep copy of image data");
1102// for(size_t i=0; i < n; ++i) tmp[i] = d[i]; // should just be a memcpy
1103 std::copy(d, d+n, tmp);
1104 qsort(tmp, n, sizeof(float), &greaterthan);
1105 float median;
1106 if (n%2==1) median = tmp[n/2];
1107 else median = (tmp[n/2-1]+tmp[n/2])/2.0f;
1108 delete [] tmp;
1109 return median;
1110 }
1111 else if (key == "nonzero_median")
1112 {
1113 if ( is_complex() ) throw ImageFormatException("Error - can not calculate the median of a complex image");
1114 vector<float> tmp;
1115 size_t n = size;
1116 float* d = get_data();
1117 for( size_t i = 0; i < n; ++i ) {
1118 if ( d[i] != 0 ) tmp.push_back(d[i]);
1119 }
1120 sort(tmp.begin(), tmp.end());
1121 unsigned int vsize = tmp.size();
1122 float median;
1123 if (vsize%2==1) median = tmp[vsize/2];
1124 else median = (tmp[vsize/2-1]+tmp[vsize/2])/2.0f;
1125 return median;
1126 }
1127 else if (key == "changecount") return EMObject(changecount);
1128 else if (key == "nx") {
1129 return nx;
1130 }
1131 else if (key == "ny") {
1132 return ny;
1133 }
1134 else if (key == "nz") {
1135 return nz;
1136 }
1137
1138 if(attr_dict.has_key(key)) {
1139 return attr_dict[key];
1140 }
1141 else {
1142 throw NotExistingObjectException(key, "The requested key does not exist");
1143 }
1144
1145 EXITFUNC;
1146}
EMObject is a wrapper class for types including int, float, double, etc as defined in ObjectType.
Definition: emobject.h:123
EMData * copy() const
This file is a part of "emdata.h", to use functions in this file, you should "#include "emdata....
int greaterthan(const void *p1, const void *p2)
#define NotExistingObjectException(objname, desc)
Definition: exception.h:130
#define BadAllocException(desc)
Definition: exception.h:387

References EMAN::EMData::attr_dict, BadAllocException, EMAN::EMData::changecount, copy(), EMAN::EMData::EMDATA_NEEDUPD, ENTERFUNC, EXITFUNC, EMAN::EMData::flags, get_data(), get_value_at(), greaterthan(), EMAN::Dict::has_key(), EMAN::Util::hypot2sq(), EMAN::Util::hypot3sq(), ImageFormatException, is_complex(), NotExistingObjectException, EMAN::EMData::nx, EMAN::EMData::ny, EMAN::EMData::nz, sqrt(), EMAN::EMData::update_stat(), x, and y.

Referenced by calc_center_density(), EMAN::EMData::calc_hist(), calc_sigma_diff(), is_fftpadded(), is_FH(), is_flipped(), is_shuffled(), EMAN::KMeansAnalyzer::reseed(), and EMAN::KMeansAnalyzer::update_centers().

◆ get_attr_default()

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.

If the attribute does not exist, it will return a default EMObject() object, which will be converted to None in Python. Or return any object user submit.

Parameters
attr_nameThe header attribute name.
em_objthe default attribute to return when this attr_name not exist in attr_dict
Returns
The attribute value, default to None.

Referenced by EMAN::EMData::calc_radial_dist(), and EMAN::KMeansAnalyzer::reclassify().

◆ get_attr_dict()

Dict EMData::get_attr_dict ( ) const

Get the image attribute dictionary containing all the image attribute names and attribute values.

Returns
The image attribute dictionary containing all attribute names and values.

Definition at line 1162 of file emdata_metadata.cpp.

1163{
1164 if(rdata) {
1165 update_stat();
1166 }
1167
1168 Dict tmp=Dict(attr_dict);
1169 tmp["nx"]=nx;
1170 tmp["ny"]=ny;
1171 tmp["nz"]=nz;
1172 tmp["changecount"]=changecount;
1173
1174 return tmp;
1175}
#define rdata(i)
Definition: analyzer.cpp:592
Dict is a dictionary to store <string, EMObject> pair.
Definition: emobject.h:385

References EMAN::EMData::attr_dict, EMAN::EMData::changecount, EMAN::EMData::nx, EMAN::EMData::ny, EMAN::EMData::nz, EMAN::EMData::rdata, and EMAN::EMData::update_stat().

◆ get_changecount()

int get_changecount ( ) const
inline

Definition at line 915 of file emdata_metadata.h.

916{
917 return changecount;
918}

◆ get_circle_mean()

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 773 of file emdata_metadata.cpp.

774{
775 ENTERFUNC;
776
777 static bool busy = false;
778 static EMData *mask = 0;
779
780 while (busy);
781 busy = true;
782
783 if (!mask || !EMUtil::is_same_size(this, mask)) {
784 if (!mask) {
785 mask = new EMData();
786 }
787 mask->set_size(nx, ny, nz);
788 mask->to_one();
789
790 float radius = (float)(ny / 2 - 2);
791 mask->process_inplace("mask.sharp", Dict("inner_radius", radius - 1,
792 "outer_radius", radius + 1));
793
794 }
795 double n = 0,s=0;
796 float *d = mask->get_data();
797 float * data = get_data();
798 size_t size = (size_t)nx*ny*nz;
799 for (size_t i = 0; i < size; ++i) {
800 if (d[i]) { n+=1.0; s+=data[i]; }
801 }
802
803
804 float result = (float)(s/n);
805 busy = false;
806
807 EXITFUNC;
808 return result;
809}

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

◆ get_const_data()

const float * get_const_data ( ) const
inline

Get the image pixel density data in a 1D float array - const version of get_data.

Returns
The image pixel density data.

Definition at line 84 of file emdata_metadata.h.

84{ return get_data(); }

References get_data().

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

◆ get_ctf()

Ctf * EMData::get_ctf ( ) const

Get ctf parameter of this image.

Returns
The ctf parameter.

Definition at line 822 of file emdata_metadata.cpp.

823{
824 if(attr_dict.has_key("ctf")) {
825 EMAN1Ctf * ctf = new EMAN1Ctf();
826 ctf->from_vector(attr_dict["ctf"]);
827
828 return dynamic_cast<Ctf *>(ctf);
829 }
830 else {
831 return 0;
832 }
833}
Ctf is the base class for all CTF model.
Definition: ctf.h:60
EMAN1Ctf is the CTF model used in EMAN1.
Definition: ctf.h:120
void from_vector(const vector< float > &vctf)
Definition: ctf.cpp:112

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

◆ get_data()

float * get_data ( ) const
inline

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

Returns
The image pixel density data.

Definition at line 78 of file emdata_metadata.h.

78{ return rdata; }

References rdata.

Referenced by absi(), EMAN::EMData::add_incoherent(), EMAN::EMData::apply_radial_func(), EMAN::EMData::calc_az_dist(), EMAN::EMData::calc_ccfx(), calc_center_density(), calc_center_of_mass(), EMAN::EMData::calc_dist(), calc_highest_locations(), EMAN::EMData::calc_hist(), calc_max_location(), calc_min_location(), calc_n_highest_locations(), EMAN::EMData::calc_radial_dist(), calc_sigma_diff(), EMAN::EMData::clip_inplace(), cmplx(), EMAN::EMData::common_lines(), EMAN::EMData::common_lines_real(), EMAN::EMData::cut_slice(), do_fft(), do_fft_inplace(), do_ift(), do_ift_inplace(), EMAN::EMData::dot_rotate_translate(), EMAN::EMData::extract_box(), get_2dcview(), get_2dview(), get_3dcview(), get_3dview(), get_attr(), get_circle_mean(), get_col(), get_const_data(), get_data_as_vector(), get_data_pickle(), get_edge_mean(), get_fft_amplitude(), get_fft_phase(), get_row(), EMAN::EMData::get_top_half(), get_value_at(), get_value_at_wrap(), EMAN::EMData::little_big_dot(), log(), log10(), mult_value_at_fast(), EMAN::EMData::oneDfftPolar(), operator()(), phase(), EMAN::OutlierProcessor::process_inplace(), read_binedimage(), render_amp24(), render_ap24(), ri2ap(), ri2inten(), EMAN::EMData::rotate_x(), set_data_pickle(), set_value_at(), set_value_at_fast(), EMAN::EMData::setup4slice(), sget_value_at(), sqrt(), to_value(), EMAN::EMData::uncut_slice(), EMAN::EMData::unwrap_largerR(), and EMAN::EMData::update_stat().

◆ get_data_as_vector()

vector< float > get_data_as_vector ( ) const
inline

Get the pixel data as a vector.

Returns
a vector containing the pixel data.

Definition at line 585 of file emdata_metadata.h.

585 {
586 size_t size = get_size();
587 vector<float> v(size);
588 float* data = get_data();
589 std::copy(data,data+size,v.begin());
590 return v;
591}
size_t get_size() const
Get the number of allocated floats in the image (nx*ny*nz)

References copy(), get_data(), and get_size().

◆ get_data_pickle()

EMBytes EMData::get_data_pickle ( ) const

Definition at line 1294 of file emdata_metadata.cpp.

1295{
1296// vector<float> vf;
1297// vf.resize(nx*ny*nz);
1298// std::copy(rdata, rdata+nx*ny*nz, vf.begin());
1299
1300 EMBytes vf;
1301 vf.assign((const char *)get_data(),nx*ny*nz*sizeof(float));
1302
1303 return vf;
1304}

References get_data(), EMAN::EMData::nx, EMAN::EMData::ny, and EMAN::EMData::nz.

◆ get_edge_mean()

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 713 of file emdata_metadata.cpp.

714{
715 ENTERFUNC;
716#ifdef EMAN2_USING_CUDA
717 if(EMData::usecuda == 1 && cudarwdata){
718
719 return get_edgemean_cuda(cudarwdata, nx, ny, nz);
720
721 }
722#endif
723 int di = 0;
724 double edge_sum = 0;
725 float edge_mean = 0;
726 size_t nxy = nx * ny;
727 float * data = get_data();
728 if (nz == 1) {
729 for (int i = 0, j = (ny - 1) * nx; i < nx; ++i, ++j) {
730 edge_sum += data[i] + data[j];
731 }
732 for (size_t i = 0, j = nx - 1; i < nxy; i += nx, j += nx) {
733 edge_sum += data[i] + data[j];
734 }
735 edge_mean = (float)edge_sum / (nx * 2 + ny * 2);
736 }
737 else {
738 if (nx == ny && nx == nz * 2 - 1) {
739 for (size_t j = (nxy * (nz - 1)); j < nxy * nz; ++j, ++di) {
740 edge_sum += data[j];
741 }
742 }
743 else {
744 for (size_t i = 0, j = (nxy * (nz - 1)); i < nxy; ++i, ++j, ++di) {
745 edge_sum += data[i] + data[j];
746 }
747 }
748
749 int nxy2 = nx * (ny - 1);
750 for (int k = 1; k < nz - 1; ++k) {
751 size_t k2 = k * nxy;
752 size_t k3 = k2 + nxy2;
753 for (int i = 0; i < nx; ++i, ++di) {
754 edge_sum += data[i + k2] + data[i + k3];
755 }
756 }
757 for (int k = 1; k < nz - 1; ++k) {
758 size_t k2 = k * nxy;
759 size_t k3 = nx - 1 + k2;
760 for (int i = 1; i < ny - 1; ++i, ++di) {
761 edge_sum += data[i * nx + k2] + data[i * nx + k3];
762 }
763 }
764
765 edge_mean = (float)edge_sum / (di * 2);
766 }
767 EXITFUNC;
768
769 return edge_mean;
770}
float get_edgemean_cuda(const float *data, const int nx, const int ny, const int nz)

References ENTERFUNC, EXITFUNC, get_data(), get_edgemean_cuda(), EMAN::EMData::nx, EMAN::EMData::nxy, EMAN::EMData::ny, and EMAN::EMData::nz.

Referenced by EMAN::EMData::calc_fast_sigma_image(), and EMAN::EMData::make_rotational_footprint_e1().

◆ get_fft_amplitude()

EMData * EMData::get_fft_amplitude ( )

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
ImageFormatExceptionIf the image is not a complex image.
Returns
The current FFT image's amplitude image.

Definition at line 91 of file emdata_metadata.cpp.

92{
94
95 if (!is_complex()) {
96 LOGERR("complex image expected. Input image is real image.");
97 throw ImageFormatException("complex image expected. Input image is a real image.");
98 }
99
100 ri2ap();
101
102 int nx2 = nx - 2;
103 EMData *dat = copy_head();
104 dat->set_size(nx2, ny, nz);
105 dat->to_zero();
106
107 float *d = dat->get_data();
108 float *data = get_data();
109 int ndim = get_ndim();
110
111 size_t idx1, idx2, idx3;
112 if (ndim == 3) {
113 for (int k = 1; k < nz; ++k) {
114 for (int j = 1; j < ny; ++j) {
115 for (int i = 0; i < nx2/2; ++i) {
116 idx1 = (size_t)k*nx2*ny+j*nx2+nx2/2+i;
117 idx2 = (size_t)k*nx*ny+j*nx+2*i;
118 idx3 = (size_t)(nz-k)*nx2*ny+(ny-j)*nx2+nx2/2-i;
119 d[idx1] = data[idx2];
120 d[idx3] = data[idx2];
121 }
122 }
123 }
124 }
125 else if (ndim == 2) {
126 for (int j = 1; j < ny; ++j) {
127 for (int i = 0; i < nx2/2; ++i) {
128 d[j*nx2+nx2/2+i] = data[j*nx+2*i];
129 d[(ny-j)*nx2+nx2/2-i] = data[j*nx+2*i];
130 }
131 }
132 }
133
134 dat->update();
135 dat->set_complex(false);
136 if(dat->get_ysize()==1 && dat->get_zsize()==1) {
137 dat->set_complex_x(false);
138 }
139 dat->set_ri(false);
140
141 EXITFUNC;
142 return dat;
143}
EMData * copy_head() const
Make an image with a copy of the current image's header.
void ri2ap()
convert the complex image from real/imaginary to amplitude/phase

References copy_head(), ENTERFUNC, EXITFUNC, get_data(), get_ndim(), ImageFormatException, is_complex(), LOGERR, EMAN::EMData::nx, EMAN::EMData::ny, EMAN::EMData::nz, and ri2ap().

Referenced by get_amplitude_thres().

◆ get_fft_amplitude2D()

EMData * EMData::get_fft_amplitude2D ( )

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

Exceptions
ImageFormatExceptionIf the image is not a complex image.
Returns
The current FFT image's amplitude image.

Definition at line 50 of file emdata_metadata.cpp.

51{
53
54// int ndim = get_ndim();
55 if (!is_complex()) {
56 LOGERR("complex image expected. Input image is real image.");
57 throw ImageFormatException("complex image expected. Input image is a real image.");
58 }
59 if (nz>1) {
60 LOGERR("2D image expected. Input image is 3D");
61 throw ImageFormatException("2D odd square complex image"
62 " expected Input image is 3D.");
63 }
64
65 int nx2 = nx/2;
66
67 EMData *dat = copy_head();
68
69 dat->set_size(nx2, ny, nz);
70 dat->to_zero();
71
72 float temp=0;
73
74 for (int j = 0; j < ny; j++) {
75 for (int i = 0; i < nx2; i++) {
76 temp = (*this)(2*i,j)*(*this)(2*i,j);
77 temp += (*this)(2*i+1,j)*(*this)(2*i+1,j);
78 (*dat)(i,j) = std::sqrt(temp);
79 }
80 }
81
82 dat->update();
83 dat->set_complex(false);
84 dat->set_ri(false);
85
87 return dat;
88}

References copy_head(), ENTERFUNC, EXITFUNC, ImageFormatException, is_complex(), LOGERR, EMAN::EMData::nx, EMAN::EMData::ny, EMAN::EMData::nz, and sqrt().

◆ get_fft_phase()

EMData * EMData::get_fft_phase ( )

return the phases of the FFT including the left half

Exceptions
ImageFormatExceptionIf the image is not a complex image.
Returns
The current FFT image's phase image.

Definition at line 146 of file emdata_metadata.cpp.

147{
148 ENTERFUNC;
149
150 if (!is_complex()) {
151 LOGERR("complex image expected. Input image is real image.");
152 throw ImageFormatException("complex image expected. Input image is a real image.");
153 }
154
155 ri2ap();
156
157 int nx2 = nx - 2;
158 EMData *dat = copy_head();
159 dat->set_size(nx2, ny, nz);
160 dat->to_zero();
161
162 float *d = dat->get_data();
163 float * data = get_data();
164
165 int ndim = get_ndim();
166 size_t idx1, idx2, idx3;
167 if (ndim == 3) {
168 for (int k = 1; k < nz; ++k) {
169 for (int j = 1; j < ny; ++j) {
170 for (int i = 0; i < nx2/2; ++i) {
171 idx1 = (size_t)k*nx2*ny+j*nx2+nx2/2+i;
172 idx2 = (size_t)k*nx*ny+j*nx+2*i+1;
173 idx3 = (size_t)(nz-k)*nx2*ny+(ny-j)*nx2+nx2/2-i;
174 d[idx1] = data[idx2];
175 d[idx3] = -data[idx2];
176 }
177 }
178 }
179 }
180 else if (ndim == 2) {
181 for (int j = 1; j < ny; ++j) {
182 for (int i = 0; i < nx2/2; ++i) {
183 d[j*nx2+nx2/2+i] = data[j*nx+2*i+1];
184 d[(ny-j)*nx2+nx2/2-i] = -data[j*nx+2*i+1];
185 }
186 }
187 }
188
189 dat->update();
190 dat->set_complex(false);
191 if(dat->get_ysize()==1 && dat->get_zsize()==1) {
192 dat->set_complex_x(false);
193 }
194 dat->set_ri(false);
195
196 EXITFUNC;
197 return dat;
198}

References copy_head(), ENTERFUNC, EXITFUNC, get_data(), get_ndim(), ImageFormatException, is_complex(), LOGERR, EMAN::EMData::nx, EMAN::EMData::ny, EMAN::EMData::nz, and ri2ap().

◆ get_flags()

int get_flags ( ) const
inline

Definition at line 905 of file emdata_metadata.h.

906{
907 return flags;
908}

◆ get_ndim()

int get_ndim ( ) const
inline

◆ get_path()

string get_path ( ) const
inline

Definition at line 954 of file emdata_metadata.h.

955{
956 return path;
957}

◆ get_pathnum()

int get_pathnum ( ) const
inline

Definition at line 959 of file emdata_metadata.h.

960{
961 return pathnum;
962}

◆ get_size()

size_t get_size ( ) const
inline

Get the number of allocated floats in the image (nx*ny*nz)

Returns
nx*ny*nz

Definition at line 577 of file emdata_metadata.h.

578{
579 return (size_t)nx*(size_t)ny*(size_t)nz;
580}

Referenced by get_data_as_vector(), and to_value().

◆ get_sizes()

IntSize get_sizes ( ) const
inline

Definition at line 568 of file emdata_metadata.h.

569{
570 return IntSize(get_xsize(), get_ysize(), get_zsize());
571}

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

◆ get_supp_pickle()

int EMData::get_supp_pickle ( ) const

Definition at line 1316 of file emdata_metadata.cpp.

1317{
1318 return 0;
1319}

◆ get_transform()

Transform get_transform ( ) const
inline

Get the 3D orientation of 'this' image.

Returns
The 3D orientation of 'this' image.

Definition at line 320 of file emdata_metadata.h.

321{
322 Dict rotation_dict;
323 rotation_dict["type"] = "eman";
324 rotation_dict["alt"] = attr_dict["euler_alt"];
325 rotation_dict["az"] = attr_dict["euler_az"];
326 rotation_dict["phi"] = attr_dict["euler_phi"];
327
328 Transform trans;
329 trans.to_identity();
330 trans.set_rotation(rotation_dict);
331
332 return trans;
333}

◆ get_translation()

Vec3f 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 289 of file emdata_metadata.h.

290{
291 return all_translation;
292}

◆ get_xoff()

int get_xoff ( ) const
inline

Definition at line 925 of file emdata_metadata.h.

926{
927 return xoff;
928}

◆ get_xsize()

int get_xsize ( ) const
inline

◆ get_yoff()

int get_yoff ( ) const
inline

Definition at line 930 of file emdata_metadata.h.

931{
932 return yoff;
933}

◆ get_ysize()

int get_ysize ( ) const
inline

Get the image y-dimensional size.

Returns
Image y-dimensional size.

Definition at line 553 of file emdata_metadata.h.

554{
555 return ny;
556}

Referenced by absi(), EMAN::KMeansAnalyzer::analyze(), calc_max_location_wrap(), calc_max_location_wrap_intp(), get_sizes(), phase(), EMAN::BispecSliceProcessor::process(), real2complex(), and EMAN::EMData::unwrap_largerR().

◆ get_zoff()

int get_zoff ( ) const
inline

Definition at line 935 of file emdata_metadata.h.

936{
937 return zoff;
938}

◆ get_zsize()

int get_zsize ( ) const
inline

Get the image z-dimensional size.

Returns
Image z-dimensional size.

Definition at line 562 of file emdata_metadata.h.

563{
564 return nz;
565}

Referenced by absi(), EMAN::KMeansAnalyzer::analyze(), calc_max_location_wrap(), calc_max_location_wrap_intp(), get_sizes(), phase(), and real2complex().

◆ has_attr()

bool has_attr ( const string &  key) const
inline

Ask if the header has a particular attribute.

Parameters
keythe header attribute name
Returns
whether or not the header has the name as a key/value entry

Definition at line 498 of file emdata_metadata.h.

498 {
499 return attr_dict.has_key(key);
500}

Referenced by has_ctff(), is_fftpadded(), is_FH(), is_shuffled(), and EMAN::KMeansAnalyzer::reseed().

◆ has_ctff()

bool 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 158 of file emdata_metadata.h.

159{
160 if (this->has_attr("ctf")) {
161 return true;
162 }
163 else {
164 return false;
165 }
166}
bool has_attr(const string &key) const
Ask if the header has a particular attribute.

References has_attr().

◆ is_complex()

bool is_complex ( ) const
inline

◆ is_complex_x()

bool is_complex_x ( ) const
inline

Is this image a 1D FFT image in X direction?

Returns
Whether this image is a 1D FFT image in X direction.

Definition at line 727 of file emdata_metadata.h.

728{
729 if(attr_dict.has_key("is_complex_x")) {
730 if (int(attr_dict["is_complex_x"])) {
731 return true;
732 }
733 else {
734 return false;
735 }
736 }
737 else {
738 return false;
739 }
740}

Referenced by EMAN::EMData::calc_ccfx(), and set_complex_x().

◆ is_fftodd()

bool is_fftodd ( ) const
inline

Does this image correspond to a (real-space) odd nx?

Returns
Whether this image has a (real-space) odd nx.

Definition at line 864 of file emdata_metadata.h.

865{
866 if(flags & EMDATA_FFTODD) {
867 return true;
868 }
869 else if( attr_dict.has_key("is_fftodd") && (int)attr_dict["is_fftodd"] == 1 ) {
870 return true;
871 }
872 else {
873 return false;
874 }
875}

Referenced by EMAN::EMData::cconj(), do_fft(), do_fft_inplace(), do_ift(), do_ift_inplace(), set_fftodd(), EMAN::FourierReconstructorSimple2D::setup(), EMAN::FourierReconstructor::setup(), EMAN::FourierReconstructor::setup_seed(), EMAN::FourierReconstructor::setup_seedandweights(), and EMAN::EMData::window_center().

◆ is_fftpadded()

bool is_fftpadded ( ) const
inline

Is this image already extended along x for ffts?

Returns
Whether this image is extended along x for ffts.

Definition at line 831 of file emdata_metadata.h.

832{
833 if (flags & EMDATA_PAD) {
834 return true;
835 }
836
837 if(has_attr("is_fftpad")) {
838 return get_attr("is_fftpad");
839 }
840
841 return false;
842
843}

References get_attr(), and has_attr().

Referenced by do_fft(), do_fft_inplace(), set_fftpad(), and EMAN::EMData::window_center().

◆ is_FH()

bool is_FH ( ) const
inline

Is this a FH image?

Returns
Whether this is a FH image or not.

Definition at line 631 of file emdata_metadata.h.

632{ // PRB
633 if (flags & EMDATA_FH) {
634 return true;
635 }
636
637 if(has_attr("is_fh")) {
638 return get_attr("is_fh");
639 }
640
641 return false;
642}

References get_attr(), and has_attr().

Referenced by set_FH().

◆ is_flipped()

bool is_flipped ( ) const
inline

Is this image flipped?

Returns
Whether this image is flipped or not.

Definition at line 761 of file emdata_metadata.h.

762{
763 if (flags & EMDATA_FLIP) { //keep here for back compatibility
764 return true;
765 }
766
767 if(attr_dict.has_key("is_flipped")) {
768 if(get_attr("is_flipped")) {
769 return true;
770 }
771 }
772
773 return false;
774
775}

References get_attr().

Referenced by set_flipped().

◆ is_real()

bool is_real ( ) const
inline

Is this a real image?

Returns
Whether this is image is real (not complex) or not.

Definition at line 667 of file emdata_metadata.h.

668{
669 return !is_complex();
670}

References is_complex().

Referenced by absi(), EMAN::EMData::convolute(), EMAN::EMData::EMData(), phase(), and EMAN::TransformProcessor::transform().

◆ is_ri()

bool is_ri ( ) const
inline

Is this image a real/imaginary format complex image?

Returns
Whether this image is real/imaginary format complex image.

Definition at line 797 of file emdata_metadata.h.

798{
799 if(attr_dict.has_key("is_complex_ri")) {
800 if (int(attr_dict["is_complex_ri"])) {
801 return true;
802 }
803 else {
804 return false;
805 }
806 }
807 else {
808 return false;
809 }
810}

Referenced by absi(), EMAN::EMData::calc_az_dist(), calc_highest_locations(), calc_max_location(), calc_min_location(), calc_n_highest_locations(), EMAN::EMData::calc_radial_dist(), EMAN::EMData::cconj(), do_ift(), do_ift_inplace(), phase(), ri2ap(), ri2inten(), set_ri(), and EMAN::EMData::update_stat().

◆ is_shuffled()

bool is_shuffled ( ) const
inline

Has this image been shuffled?

Returns
Whether this image has been shuffled to put origin in the center.

Definition at line 614 of file emdata_metadata.h.

615{ // PRB
616 if (flags & EMDATA_SHUFFLE) {
617 return true;
618 }
619
620 if(has_attr("is_shuffled")) {
621 return get_attr("is_shuffled");
622 }
623
624 return false;
625}

References get_attr(), and has_attr().

Referenced by set_shuffled().

◆ mask_contig_region()

vector< Vec3i > mask_contig_region ( const float &  val,
const Vec3i &  seed 
)

◆ read_data()

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.

The image should already have the correct dimensions.

Parameters
fspThe filename to read the image data from
locLocation to seek to in the file before writing (size_t)
areaThe image region you want to read, default 0 means read the whole image
file_nxImage x size.
file_nyImage y size.
file_nzImage z size.
Author
Steve Ludtke
Date
Mon Jun 23, 2008

◆ scale_pixel()

void EMData::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)

Author
Unknown

Definition at line 1280 of file emdata_metadata.cpp.

1281{
1282 attr_dict["apix_x"] = ((float) attr_dict["apix_x"]) * scale;
1283 attr_dict["apix_y"] = ((float) attr_dict["apix_y"]) * scale;
1284 attr_dict["apix_z"] = ((float) attr_dict["apix_z"]) * scale;
1285 if (attr_dict.has_key("ctf")) {
1286 Ctf *ctf=(Ctf *)attr_dict["ctf"];
1287 ctf->apix*=scale;
1288 attr_dict["ctf"]=ctf;
1289 if(ctf) {delete ctf; ctf=0;}
1290 }
1291}
float apix
Definition: ctf.h:88

References EMAN::Ctf::apix, EMAN::EMData::attr_dict, EMAN::Dict::has_key(), and EMAN::EMData::scale().

◆ set_attr()

void set_attr ( const string &  key,
EMObject  val 
)

Set a header attribute's value.

Parameters
keyThe header attribute name.
valThe attribute value.

Referenced by EMAN::KMeansAnalyzer::analyze(), EMAN::EMData::compute_missingwedge(), ri2inten(), set_fftodd(), set_fftpad(), set_FH(), set_flipped(), and set_shuffled().

◆ set_attr_dict()

void set_attr_dict ( const Dict &  new_dict)

Merge the new values with the existing dictionary.

Parameters
new_dictThe new attribute dictionary.

◆ set_attr_dict_explicit()

void set_attr_dict_explicit ( const Dict &  new_dict)
private

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.

Parameters
new_dictThe attribute dictionary that will become this image's attribute dictionary.

◆ set_attr_python()

void set_attr_python ( const string &  key,
EMObject  val 
)

Set a header attribute's value from Python.

Parameters
keyThe header attribute name.
valThe attribute value.

◆ set_changecount()

void set_changecount ( int  c)
inline

Definition at line 920 of file emdata_metadata.h.

921{
922 changecount = c;
923}

◆ set_complex()

void set_complex ( bool  is_complex)
inline

Mark this image as a complex image.

Parameters
is_complexIf true, a complex image. If false, a real image.

Definition at line 712 of file emdata_metadata.h.

713{
714 if (is_complex) {
715 attr_dict["is_complex"] = int(1);
716 }
717 else {
718 attr_dict["is_complex"] = int(0);
719 }
720}

References is_complex().

Referenced by do_fft_inplace(), do_ift_inplace(), and read_binedimage().

◆ set_complex_size()

void set_complex_size ( int  nx,
int  ny = 1,
int  nz = 1 
)

Resize 'this' complex image.

Parameters
nxx size of this image.
nyy size of this image.
nzz size of this image.

Definition at line 393 of file emdata_metadata.h.

393 {
394 set_size(nx*2, ny, nz);
395}
void set_size(int nx, int ny=1, int nz=1, bool noalloc=false)
Resize this EMData's main board memory pointer.

References set_size().

◆ set_complex_x()

void set_complex_x ( bool  is_complex_x)
inline

Marks this image a 1D FFT image in X direction.

Parameters
is_complex_xIf true, a 1D FFT image in X direction; If false, not such an image.

Definition at line 747 of file emdata_metadata.h.

748{
749 if (is_complex_x) {
750 attr_dict["is_complex_x"] = int(1);
751 }
752 else {
753 attr_dict["is_complex_x"] = int(0);
754 }
755}
bool is_complex_x() const
Is this image a 1D FFT image in X direction?

References is_complex_x().

Referenced by do_fft_inplace(), and do_ift_inplace().

◆ set_ctf()

void set_ctf ( Ctf *  ctf)

Set the CTF parameter of this image.

Parameters
ctfThe CTF parameter object.

◆ set_data() [1/2]

void set_data ( float *  data)
inline

Definition at line 106 of file emdata_metadata.h.

106 {
107 rdata = data;
108}

References rdata.

◆ set_data() [2/2]

void 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
dataa pointer to the pixel data which is stored in memory. Takes possession
xthe number of pixels in the x direction
ythe number of pixels in the y direction
zthe number of pixels in the z direction

Definition at line 93 of file emdata_metadata.h.

93 {
94 if (rdata) { EMUtil::em_free(rdata); rdata = 0; }
95#ifdef EMAN2_USING_CUDA
96 //cout << "set data" << endl;
97// free_cuda_memory();
98#endif
99 rdata = data;
100 nx = x; ny = y; nz = z;
101 nxy = nx*ny;
102 nxyz = (size_t)nx*ny*nz;
103 update();
104}
void update()
Mark EMData as changed, statistics, etc will be updated at need.

References rdata, update(), x, and y.

◆ set_data_pickle()

void EMData::set_data_pickle ( std::string  vf)

Definition at line 1307 of file emdata_metadata.cpp.

1308{
1309// if (rdata) printf("rdata exists\n");
1310// rdata = (float *)malloc(nx*ny*nz*sizeof(float));
1311// std::copy(vf.begin(), vf.end(), rdata);
1312 EMUtil::em_memcpy(get_data(),vf.data(),(size_t)nx*ny*nz*sizeof(float));
1313
1314}

References EMAN::EMUtil::em_memcpy(), get_data(), EMAN::EMData::nx, EMAN::EMData::ny, and EMAN::EMData::nz.

◆ set_fftodd()

void set_fftodd ( bool  is_fftodd)
inline

Mark this image as having (real-space) odd nx.

Parameters
is_fftoddIf true, mark as nx odd; If false, mark as nx not odd.

Definition at line 882 of file emdata_metadata.h.

883{
884 if (is_fftodd) {
885 set_attr("is_fftodd", int(1));
886 }
887 else {
888 set_attr("is_fftodd", int(0));
889 }
890}
bool is_fftodd() const
Does this image correspond to a (real-space) odd nx?
void set_attr(const string &key, EMObject val)
Set a header attribute's value.

References is_fftodd(), and set_attr().

Referenced by do_fft_inplace(), and read_binedimage().

◆ set_fftpad()

void set_fftpad ( bool  is_fftpadded)
inline

Mark this image as already extended along x for ffts.

Parameters
is_fftpaddedIf true, mark as padded along x; If false, mark as not padded along x.

Definition at line 850 of file emdata_metadata.h.

851{
852 if (is_fftpadded) {
853 set_attr("is_fftpad", int(1));
854 }
855 else {
856 set_attr("is_fftpad", int(0));
857 }
858}
bool is_fftpadded() const
Is this image already extended along x for ffts?

References is_fftpadded(), and set_attr().

Referenced by do_fft_inplace(), do_ift_inplace(), and read_binedimage().

◆ set_FH()

void set_FH ( bool  is_FH)
inline

Mark this complex image as a FH image.

Parameters
is_FHIf true, a FH image. If false, not a FH image.

Definition at line 695 of file emdata_metadata.h.

696{ // PRB
697 if (is_FH) {
698// flags |= EMDATA_FH;
699 set_attr("is_fh", (int)1);
700 }
701 else {
702// flags &= ~EMDATA_FH;
703 set_attr("is_fh", (int)0);
704 }
705}
bool is_FH() const
Is this a FH image?

References is_FH(), and set_attr().

◆ set_flags()

void set_flags ( int  f)
inline

Definition at line 910 of file emdata_metadata.h.

911{
912 flags = f;
913}

◆ set_flipped()

void set_flipped ( bool  is_flipped)
inline

Mark this image as flipped.

Parameters
is_flippedIf true, mark this image as flipped; If false, mark this image as not flipped.

Definition at line 782 of file emdata_metadata.h.

783{
784 if (is_flipped) {
785 set_attr("is_flipped", (int)1);
786 }
787 else {
788 set_attr("is_flipped", (int)0);
789 }
790}
bool is_flipped() const
Is this image flipped?

References is_flipped(), and set_attr().

◆ set_nxc()

void set_nxc ( int  nxc)
inline

Set the number of complex elements along x.

Parameters
nxcis the number of complex elements along x.

Definition at line 896 of file emdata_metadata.h.

897{
898 attr_dict["nxc"] = nxc;
899}

◆ set_path()

void set_path ( const string &  new_path)
inline

Set the path.

Parameters
new_pathThe new path.

Definition at line 401 of file emdata_metadata.h.

402{
403 path = new_path;
404}

◆ set_pathnum()

void set_pathnum ( int  n)
inline

Set the number of paths.

Parameters
nThe number of paths.

Definition at line 410 of file emdata_metadata.h.

411{
412 pathnum = n;
413}

◆ set_ri()

void set_ri ( bool  is_ri)
inline

Mark this image as a real/imaginary format complex image.

Parameters
is_riIf true, mark as real/imaginary format; If false, mark as amp/phase format.

Definition at line 817 of file emdata_metadata.h.

818{
819 if (is_ri) {
820 attr_dict["is_complex_ri"] = int(1);
821 }
822 else {
823 attr_dict["is_complex_ri"] = int(0);
824 }
825}

References is_ri().

Referenced by do_fft_inplace(), do_ift_inplace(), read_binedimage(), ri2ap(), to_one(), and to_zero().

◆ set_rotation() [1/2]

void set_rotation ( const Transform &  t3d)
inline

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

Parameters
t3da Transform object containing the particle orientation

Definition at line 356 of file emdata_metadata.h.

357{
358 Dict d = t3d.get_rotation("eman");
359 attr_dict["orientation_convention"] = "EMAN";
360 attr_dict["euler_alt"] = (float) d["alt"];
361 attr_dict["euler_az"] = (float) d["az"];
362 attr_dict["euler_phi"] = (float) d["phi"];;
363}

◆ set_rotation() [2/2]

void 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 342 of file emdata_metadata.h.

343{
344 attr_dict["orientation_convention"] = "EMAN";
345 attr_dict["euler_alt"]=alt;
346 attr_dict["euler_az"]=az;
347 attr_dict["euler_phi"]=phi;
348}

◆ set_shuffled()

void set_shuffled ( bool  is_shuffled)
inline

Mark this image as a shuffled image.

Parameters
is_shuffledIf true, a shuffled image. If false, not a shuffled image.

Definition at line 677 of file emdata_metadata.h.

678{ // PRB
679 if (is_shuffled) {
680// printf("entered correct part of set_shuffled \n");
681// flags |= EMDATA_SHUFFLE;
682 set_attr("is_shuffled", (int)1);
683 }
684 else {
685// flags &= ~EMDATA_SHUFFLE;
686 set_attr("is_shuffled", (int)0);
687 }
688}
bool is_shuffled() const
Has this image been shuffled?

References is_shuffled(), and set_attr().

◆ set_size()

void set_size ( int  nx,
int  ny = 1,
int  nz = 1,
bool  noalloc = false 
)

Resize this EMData's main board memory pointer.

Parameters
nxx size of this image.
nyy size of this image.
nzz size of this image.
Exceptions
BadAllocExceptionif memory allocation returns a null pointer

Referenced by bispecRotTransInvN(), EMAN::EMData::clip_inplace(), EMAN::EMData::common_lines(), EMAN::EMData::common_lines_real(), do_fft_inplace(), EMAN::EMData::EMData(), EMAN::EMData::operator=(), read_binedimage(), and set_complex_size().

◆ set_supp_pickle()

void EMData::set_supp_pickle ( int  i)

Definition at line 1321 of file emdata_metadata.cpp.

1322{
1323 this->supp = 0;
1324}

References EMAN::EMData::supp.

◆ set_translation() [1/2]

void set_translation ( const Vec3f &  t)
inline

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

Parameters
tThe new translation vector.

Definition at line 299 of file emdata_metadata.h.

300{
301 all_translation = t;
302}

◆ set_translation() [2/2]

void set_translation ( float  dx,
float  dy,
float  dz 
)
inline

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

Parameters
dxThe translation distance in x direction.
dyThe translation distance in y direction.
dzThe translation distance in z direction.

Definition at line 311 of file emdata_metadata.h.

312{
313 all_translation = Vec3f(dx, dy, dz);
314}
Vec3< float > Vec3f
Definition: vec3.h:693

◆ set_xyzoff()

void set_xyzoff ( int  x,
int  y,
int  z 
)
inline

Definition at line 940 of file emdata_metadata.h.

941{
942 xoff = x;
943 yoff = y;
944 zoff = z;
945}

References x, and y.

◆ update()

void update ( )
inline

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

Definition at line 138 of file emdata_metadata.h.

139{
140 flags |= EMDATA_NEEDUPD;
141 changecount++;
142#ifdef FFT_CACHING
143 if (fftcache!=0) { delete fftcache; fftcache=0; }
144#endif //FFT_CACHING
145
146}

Referenced by EMAN::EMData::add_incoherent(), EMAN::EMData::apply_radial_func(), EMAN::EMData::clip_inplace(), EMAN::EMData::common_lines(), EMAN::EMData::common_lines_real(), EMAN::EMData::cut_slice(), do_fft_inplace(), do_ift_inplace(), EMAN::EMData::EMData(), mult_value_at_fast(), EMAN::RotateInFSProcessor::process_inplace(), read_binedimage(), ri2ap(), ri2inten(), EMAN::EMData::rotate_x(), set_data(), set_value_at(), set_value_at_fast(), to_one(), to_value(), to_zero(), and EMAN::EMData::unwrap_largerR().

◆ write_data()

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.

Parameters
fspThe filename to write the image data to
locLocation to seek to in the file before writing (size_t)
areaThe image region you want to read, default 0 means read the whole image
file_nxImage x size.
file_nyImage y size.
file_nzImage z size.
Author
Steve Ludtke
Date
Mon Jun 23, 2008