Xmipp  v3.23.11-Nereus
Macros | Functions
xmipp_image_base.cpp File Reference
#include "xmipp_image_base.h"
#include "xmipp_image.h"
#include "xmipp_error.h"
#include <stdlib.h>
#include "metadata_static.h"
#include "metadata_base.h"
#include "xmipp_funcs.h"
#include <tiffio.h>
#include <hdf5.h>
Include dependency graph for xmipp_image_base.cpp:

Go to the source code of this file.

Macros

#define READ_AND_RETURN()
 

Functions

bool isDynamicMRC (const char *envvar, const String &ext)
 
bool isMRCStack (const FileName &ext_name)
 
bool isMRCImageOrVolume (const FileName &ext_name)
 
std::ostream & operator<< (std::ostream &o, const ImageBase &I)
 

Macro Definition Documentation

◆ READ_AND_RETURN

#define READ_AND_RETURN ( )
Value:
ImageFHandler* hFile = openFile(name); \
int err = _read(name, hFile, params.datamode, params.select_img); \
applyGeo(*row, params.only_apply_shifts, params.wrap); \
closeFile(hFile); \
return err

General read functionMacros for don't type

Definition at line 240 of file xmipp_image_base.cpp.

Function Documentation

◆ isDynamicMRC()

bool isDynamicMRC ( const char *  envvar,
const String ext 
)

Definition at line 762 of file xmipp_image_base.cpp.

763 {
764  FileName mrcExtensions;
765  if (getenv(envvar))
766  mrcExtensions=getenv(envvar);
767  String plainExt = ext;
768  size_t found = ext.find_first_of("%");
769  if (found!=String::npos)
770  plainExt = ext.substr(0, found);
771  else
772  return false;
773  return mrcExtensions.contains(plainExt);
774 }
bool contains(const String &str) const
std::string String
Definition: xmipp_strings.h:34

◆ isMRCImageOrVolume()

bool isMRCImageOrVolume ( const FileName ext_name)

Definition at line 784 of file xmipp_image_base.cpp.

785 {
786  return ext_name.contains("mrc") || ext_name.contains("map") ||
787  ext_name.contains("rec") || isDynamicMRC("XMIPP_MRC_EXTENSIONS",ext_name);
788 }
bool contains(const String &str) const
bool isDynamicMRC(const char *envvar, const String &ext)

◆ isMRCStack()

bool isMRCStack ( const FileName ext_name)

Definition at line 776 of file xmipp_image_base.cpp.

777 {
778  return ext_name.contains("mrcs") || ext_name.contains("st") ||
779  ext_name.contains("preali") || ext_name.contains("ali") ||
780  ext_name.contains("fixed") ||
781  isDynamicMRC("XMIPP_MRC_STACK_EXTENSIONS",ext_name);
782 }
bool contains(const String &str) const
bool isDynamicMRC(const char *envvar, const String &ext)

◆ operator<<()

std::ostream& operator<< ( std::ostream &  o,
const ImageBase I 
)

Show image properties

Definition at line 1121 of file xmipp_image_base.cpp.

1122 {
1123  o << std::endl;
1124  DataType * fileDT = NULL;
1125  if (!I.filename.empty())
1126  {
1127  o << "--- File information ---" << std::endl;
1128  o << "Filename : " << I.filename << std::endl;
1129  o << "Endianess : ";
1130  if (I.swap^IsLittleEndian())
1131  o << "Little" << std::endl;
1132  else
1133  o << "Big" << std::endl;
1134 
1135  o << "Reversed : ";
1136  if (I.swap)
1137  o << "True" << std::endl;
1138  else
1139  o << "False" << std::endl;
1140  fileDT = new DataType;
1141  *fileDT = I.datatype();
1142  o << "Data type : " << datatype2StrLong(*fileDT) << std::endl;
1143  o << "Data offset : " << I.offset << std::endl;
1144  }
1145 
1146  o << "--- Image information ---" << std::endl;
1147 
1148  DataType myDT = I.myT();
1149  if ((fileDT == NULL || myDT != *fileDT) && I.dataMode >= DATA )
1150  o << "Memory datatype: " << datatype2StrLong(I.myT()) << std::endl;
1151  o << "Image type : ";
1152  if (I.isComplex())
1153  o << "Fourier-space image" << std::endl;
1154  else
1155  o << "Real-space image" << std::endl;
1156 
1157  delete fileDT;
1158 
1159  size_t xdim, ydim, zdim, ndim;
1160  I.getDimensions(xdim, ydim, zdim, ndim);
1161  o << "Dimensions : " << ndim << " x " << zdim << " x " << ydim << " x " << xdim;
1162  o << " ((N)Objects x (Z)Slices x (Y)Rows x (X)Columns)" << std::endl;
1163 
1164  double sampling;
1166  if (sampling > 0)
1167  {
1168  o << "Sampling rate : " << std::endl;
1169  o << " X-rate (Angstrom/pixel) = " << sampling << std::endl;
1171  o << " Y-rate (Angstrom/pixel) = " << sampling << std::endl;
1173  o << " Z-rate (Angstrom/pixel) = " << sampling << std::endl;
1174  }
1175 
1176  std::stringstream oGeo;
1177 
1179  {
1180  oGeo << "Euler angles : " << std::endl;
1181  oGeo << " Phi (rotation around Z axis) = " << I.rot() << std::endl;
1182  oGeo << " Theta (tilt, second rotation around new Y axis) = " << I.tilt() << std::endl;
1183  oGeo << " Psi (third rotation around new Z axis) = " << I.psi() << std::endl;
1184  }
1186  {
1187  oGeo << "Origin Offsets : " << std::endl;
1188  oGeo << " Xoff (origin offset in X-direction) = " << I.Xoff() << std::endl;
1189  oGeo << " Yoff (origin offset in Y-direction) = " << I.Yoff() << std::endl;
1190  oGeo << " Zoff (origin offset in Z-direction) = " << I.Zoff() << std::endl;
1191  }
1193  oGeo << "Scale : " <<I.scale() << std::endl;
1195  oGeo << "Weight : " << I.weight() << std::endl;
1197  oGeo << "Flip : " << I.flip() << std::endl;
1198 
1199  if (!oGeo.str().empty())
1200  o << "--- Geometry ---" << std::endl << oGeo.str();
1201 
1202  return o;
1203 }
Rotation angle of an image (double,degrees)
sampling rate in A/pixel (double)
sampling rate in A/pixel (double)
DataMode dataMode
sampling rate in A/pixel (double)
bool IsLittleEndian(void)
double psi(const size_t n=0) const
double Zoff(const size_t n=0) const
Shift for the image in the X axis (double)
const T & getValueOrDefault(MDLabel label, const T &def) const
bool isComplex() const
double rot(const size_t n=0) const
double weight(const size_t n=0) const
T & getValue(MDLabel label)
double tilt(const size_t n=0) const
Flip the image? (bool)
#define sampling
double Yoff(const size_t n=0) const
double scale(const size_t n=0) const
DataType
scaling factor for an image or volume (double)
std::string datatype2StrLong(DataType datatype)
MDRowVec MDMainHeader
bool individualContainsLabel(MDLabel label) const
DataType datatype() const
double Xoff(const size_t n=0) const
FileName filename
bool flip(const size_t n=0) const
virtual DataType myT() const =0
< Score 4 for volumes
void getDimensions(size_t &Xdim, size_t &Ydim, size_t &Zdim, size_t &Ndim) const