ITK  5.3.0
Insight Toolkit
itkMRCHeaderObject.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkMRCHeaderObject_h
19 #define itkMRCHeaderObject_h
20 #include "ITKIOMRCExport.h"
21 
22 #include "itkObjectFactory.h"
23 #include "itkLightObject.h"
24 #include "itkIntTypes.h"
25 
26 namespace itk
27 {
28 
48 class ITKIOMRC_EXPORT MRCHeaderObject : public LightObject
49 {
50 public:
51  ITK_DISALLOW_COPY_AND_MOVE(MRCHeaderObject);
52 
58 
66  struct Header
67  {
68 
85 
90 
95 
97  float xlen;
98  float ylen;
99  float zlen;
100 
102  float alpha;
103  float beta;
104  float gamma;
105 
112  // These need to be set for proper scaling of
113  // non byte data.
130  // These two values specify the structure of data in the
131  // extended header; their meaning depend on whether the
132  // extended header has the Agard format, a series of
133  // 4-byte integers then real numbers, or has data
134  // produced by SerialEM, a series of short integers.
135  // SerialEM stores a float as two shorts, s1 and s2, by:
136  // value = (sign of s1)*(|s1|*256 + (|s2| modulo 256))
137  // * 2**((sign of s2) * (|s2|/256))
138 
139  int16_t nint; // Number of integers per section (Agard format) or
140  // number of bytes per section (SerialEM format)
141  int16_t nreal; // Number of reals per section (Agard format) or
142  // flags for which types of short data (SerialEM format):
143  // 1 = tilt angle * 100 (2 bytes)
144  // 2 = piece coordinates for montage (6 bytes)
145  // 4 = Stage position * 25 (4 bytes)
146  // 8 = Magnification / 100 (2 bytes)
147  // 16 = Intensity * 25000 (2 bytes)
148  // 32 = Exposure dose in e-/A2, a float in 4 bytes
149  // 128, 512: Reserved for 4-byte items
150  // 64, 256, 1024: Reserved for 2-byte items
151  // If the number of bytes implied by these flags does
152  // not add up to the value in nint, then nint and nreal
153  // are interpreted as ints and reals per section
154 
156  int8_t notused2[28];
157 
158  // Explanation of type of data.
159  int16_t idtype; // ( 0 = mono, 1 = tilt, 2 = tilts, 3 = lina, 4 =
160  // lins)
162  int16_t nd1; // for idtype = 1, nd1 = axis (1, 2, or 3)
164  int16_t vd1; // vd1 = 100. * tilt increment
165  int16_t vd2; // vd2 = 100. * starting angle
166 
167  // Used to rotate model to match new rotated image.
168  float tiltangles[6]; // 0,1,2 = original: 3,4,5 = current
169 
170  // NEW-STYLE MRC image2000 HEADER - IMOD 2.6.20 and above:
171  float xorg; // Origin of image. Used to auto translate model
172  float yorg; // to match a new image that has been translated.
173  float zorg;
174 
179  float rms;
180 
181  // ALL HEADERS:
185  };
186 
189  {
190 
215 
217  };
218 
220  enum
221  {
222  MRCHEADER_MODE_UINT8 = 0,
223  MRCHEADER_MODE_INT8 = 0,
224  MRCHEADER_MODE_IN16 = 1,
225  MRCHEADER_MODE_FLOAT = 2,
226  MRCHEADER_MODE_COMPLEX_INT16 = 3,
227  MRCHEADER_MODE_COMPLEX_FLOAT = 4,
228  MRCHEADER_MODE_UINT16 = 6,
229  MRCHEADER_MODE_RGB_BYTE = 16
230  };
231 
233  enum
234  {
235  MRCHEADER_MAP_X = 1,
236  MRCHEADER_MAP_Y = 2,
237  MRCHEADER_MAP_Z = 3
238  };
239 
240 public:
242  itkNewMacro(Self);
243 
245  itkTypeMacro(MRCHeaderObject, LightObject);
246 
247  void
248  DeepCopy(ConstPointer h);
249 
260  bool
261  SetHeader(const Header * buffer);
262 
263  const Header &
264  GetHeader() const;
265 
274  bool
275  SetExtendedHeader(const void * buffer);
276 
281  GetExtendedHeaderSize() const;
282 
286  {
287  return sizeof(Header);
288  }
289 
293  bool
294  IsOriginalHeaderBigEndian() const;
295 
297  Header m_Header; // FIXME : This should be private and
298  // should have Get/Set Methods.
299 
300 protected:
301  MRCHeaderObject();
302  ~MRCHeaderObject() override;
303 
305  void
306  swapHeader(bool bigEndian);
307 
309  void
310  PrintSelf(std::ostream & os, Indent indent) const override;
311 
312 private:
313  SizeValueType m_ExtendedHeaderSize{ 0 };
314  void * m_ExtendedHeader{ nullptr };
315 
316  FeiExtendedHeader * m_ExtendedFeiHeader{ nullptr };
317 
319 };
320 } // namespace itk
321 
322 #endif
itk::MRCHeaderObject::Header::mz
int32_t mz
Definition: itkMRCHeaderObject.h:94
itk::MRCHeaderObject::Header::nreal
int16_t nreal
Definition: itkMRCHeaderObject.h:141
itk::MRCHeaderObject::Header::zlen
float zlen
Definition: itkMRCHeaderObject.h:99
itkObjectFactory.h
itk::MRCHeaderObject
This class is a light wrapper for a couple of plain old data structures, so that they can be utilized...
Definition: itkMRCHeaderObject.h:48
itk::MRCHeaderObject::Header::yorg
float yorg
Definition: itkMRCHeaderObject.h:172
itk::MRCHeaderObject::Header
Definition: itkMRCHeaderObject.h:66
itk::MRCHeaderObject::Header::nint
int16_t nint
Definition: itkMRCHeaderObject.h:139
itk::MRCHeaderObject::Header::idtype
int16_t idtype
Definition: itkMRCHeaderObject.h:159
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::MRCHeaderObject::GetHeaderSize
SizeValueType GetHeaderSize() const
Definition: itkMRCHeaderObject.h:285
itk::MRCHeaderObject::Header::rms
float rms
Definition: itkMRCHeaderObject.h:179
itk::MRCHeaderObject::FeiExtendedHeader
Definition: itkMRCHeaderObject.h:188
itk::MRCHeaderObject::Header::my
int32_t my
Definition: itkMRCHeaderObject.h:93
itk::MRCHeaderObject::Header::nxstart
int32_t nxstart
Definition: itkMRCHeaderObject.h:87
itk::MRCHeaderObject::Header::vd2
int16_t vd2
Definition: itkMRCHeaderObject.h:165
itk::MRCHeaderObject::Header::xlen
float xlen
Definition: itkMRCHeaderObject.h:97
itk::MRCHeaderObject::Header::nd2
int16_t nd2
Definition: itkMRCHeaderObject.h:163
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::MRCHeaderObject::m_BigEndianHeader
bool m_BigEndianHeader
Definition: itkMRCHeaderObject.h:318
itk::int8_t
std::int8_t int8_t
Definition: itkIntTypes.h:28
itk::MRCHeaderObject::Header::ylen
float ylen
Definition: itkMRCHeaderObject.h:98
itk::MRCHeaderObject::FeiExtendedHeader::magnification
float magnification
Definition: itkMRCHeaderObject.h:214
itk::MRCHeaderObject::Header::beta
float beta
Definition: itkMRCHeaderObject.h:103
itk::MRCHeaderObject::Header::mode
int32_t mode
Definition: itkMRCHeaderObject.h:84
itkIntTypes.h
itk::MRCHeaderObject::Header::nzstart
int32_t nzstart
Definition: itkMRCHeaderObject.h:89
itk::MRCHeaderObject::Header::alpha
float alpha
Definition: itkMRCHeaderObject.h:102
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::MRCHeaderObject::Header::gamma
float gamma
Definition: itkMRCHeaderObject.h:104
itk::MRCHeaderObject::Header::vd1
int16_t vd1
Definition: itkMRCHeaderObject.h:164
itk::MRCHeaderObject::m_Header
Header m_Header
Definition: itkMRCHeaderObject.h:297
itk::MRCHeaderObject::Header::nystart
int32_t nystart
Definition: itkMRCHeaderObject.h:88
itk::MRCHeaderObject::Header::xorg
float xorg
Definition: itkMRCHeaderObject.h:171
itk::MRCHeaderObject::Header::mx
int32_t mx
Definition: itkMRCHeaderObject.h:92
itk::int32_t
std::int32_t int32_t
Definition: itkIntTypes.h:32
itk::MRCHeaderObject::Header::zorg
float zorg
Definition: itkMRCHeaderObject.h:173
itk::MRCHeaderObject::Header::nd1
int16_t nd1
Definition: itkMRCHeaderObject.h:162
itkLightObject.h
itk::MRCHeaderObject::Header::lens
int16_t lens
Definition: itkMRCHeaderObject.h:161
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::int16_t
std::int16_t int16_t
Definition: itkIntTypes.h:30