Xmipp  v3.23.11-Nereus
Functions
Collaboration diagram for RAW Data type:

Functions

DataType datatypeRAW (String strDT)
 
int readRAW (size_t select_img, bool isStack=false)
 
DataType ImageBase::datatypeRAW (String strDT)
 
int ImageBase::readRAW (size_t select_img, bool isStack=false)
 

Detailed Description

Function Documentation

◆ datatypeRAW() [1/2]

DataType datatypeRAW ( String  strDT)

RAW Reader

◆ datatypeRAW() [2/2]

DataType ImageBase::datatypeRAW ( String  strDT)
protected

RAW Reader

Definition at line 31 of file rwRAW.cpp.

32 {
34 
35  if(strDT=="uint8")
36  datatype = DT_UChar;
37  else if (strDT=="int8")
38  datatype = DT_SChar;
39  else if (strDT=="uint16")
40  datatype = DT_UShort;
41  else if (strDT=="int16")
42  datatype = DT_Short;
43  else if (strDT=="uint32")
44  datatype = DT_UInt;
45  else if (strDT=="int32")
46  datatype = DT_Int;
47  else if (strDT=="long")
48  datatype = DT_Long;
49  else if (strDT=="float")
50  datatype = DT_Float;
51  else if (strDT=="double")
52  datatype = DT_Double;
53  else if (strDT=="cint16")
54  datatype = DT_CShort;
55  else if (strDT=="cint32")
56  datatype = DT_CInt;
57  else if (strDT=="cfloat")
58  datatype = DT_CFloat;
59  else if (strDT=="cdouble")
60  datatype = DT_CDouble;
61  else if (strDT=="bool")
62  datatype = DT_Bool;
63  else
64  datatype = DT_Unknown;
65 
66  return datatype;
67 }
DataType
DataType datatype() const

◆ readRAW() [1/2]

int readRAW ( size_t  select_img,
bool  isStack = false 
)

RAW Reader

◆ readRAW() [2/2]

int ImageBase::readRAW ( size_t  select_img,
bool  isStack = false 
)
protected

RAW Reader

Definition at line 70 of file rwRAW.cpp.

71 {
72 #undef DEBUG
73  //#define DEBUG
74 #ifdef DEBUG
75  printf("DEBUG readRAW: Reading RAW file\n");
76 #endif
77 
78  int _xDim,_yDim,_zDim;
79  size_t _nDim;
80  int rPos;
81 
82  size_t found;
83  FileName infolist;
84  StringVector info;
86 
87  found = filename.find_first_of("#");
88  infolist = filename.substr(found+1);
89  filename = filename.substr(0,found);
90  infolist.toLowercase();
91  splitString(infolist,",",info, false);
92 
93  if (info.size() < 4)
94  REPORT_ERROR(ERR_ARG_MISSING, (String) " Cannot open file " + filename +
95  ". Not enough header arguments.");
96 
97  _xDim = textToInteger(info[0]);
98  _yDim = textToInteger(info[1]);
99 
100  if (atoi(info[3].c_str()) == 0 && info[3]!="0") // Check if zdim is not included
101  {
102  rPos = 2;
103  _zDim = 1;
104  }
105  else
106  {
107  rPos = 3;
108  _zDim = textToInteger(info[2]);
109  }
110 
111  offset = (size_t)textToInteger(info[rPos]);
112  datatype = datatypeRAW(info[rPos+1]);
113  _nDim = 1;
114 
115  // Check the reverse argument
116  swap = (info.back() == "r");
117 
118  // Map the parameters
119  setDimensions(_xDim, _yDim, _zDim, _nDim);
120 
123  MDMainHeader.setValue(MDL_DATATYPE,(int)datatype);
124 
125  if (dataMode==HEADER || (dataMode == _HEADER_ALL && _nDim > 1)) // Stop reading if not necessary
126  return 0;
127 
128  size_t imgStart = IMG_INDEX(select_img);
129  size_t imgEnd = (select_img != ALL_IMAGES) ? imgStart + 1 : _nDim;
130 
131  MD.clear();
132  for (size_t i = 0; i < imgEnd-imgStart; i++)
133  MD.push_back(std::unique_ptr<MDRowVec>(new MDRowVec(MDL::emptyHeaderVec())));
134 
135  if( dataMode < DATA )
136  return 0;
137 
138  size_t pad = 0;
139  readData(fimg, select_img, datatype, pad);
140 
141  return(0);
142 }
Argument missing.
Definition: xmipp_error.h:114
sampling rate in A/pixel (double)
sampling rate in A/pixel (double)
DataMode dataMode
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
virtual void readData(FILE *fimg, size_t select_img, DataType datatype, size_t pad)=0
void setValue(const MDObject &object) override
std::vector< std::unique_ptr< MDRow > > MD
if read from file original image datatype, this is an struct defined in image
std::vector< String > StringVector
Definition: xmipp_strings.h:35
#define i
int splitString(const String &input, const String &delimiter, StringVector &results, bool includeEmpties)
virtual void setDimensions(int Xdim, int Ydim, int Zdim, size_t Ndim)=0
static MDRowVec emptyHeaderVec()
DataType
FileName toLowercase() const
MDRowVec MDMainHeader
DataType datatype() const
std::string String
Definition: xmipp_strings.h:34
#define ALL_IMAGES
int textToInteger(const char *str)
#define IMG_INDEX(select_img)
FileName filename
DataType datatypeRAW(String strDT)
Definition: rwRAW.cpp:31