ITK  5.2.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 
49 class ITKIOMRC_EXPORT MRCHeaderObject : public LightObject
50 {
51 public:
52  ITK_DISALLOW_COPY_AND_ASSIGN(MRCHeaderObject);
53 
59 
67  struct Header
68  {
69 
86 
91 
96 
98  float xlen;
99  float ylen;
100  float zlen;
101 
103  float alpha;
104  float beta;
105  float gamma;
106 
113  // These need to be set for proper scaling of
114  // non byte data.
131  // These two values specify the structure of data in the
132  // extended header; their meaning depend on whether the
133  // extended header has the Agard format, a series of
134  // 4-byte integers then real numbers, or has data
135  // produced by SerialEM, a series of short integers.
136  // SerialEM stores a float as two shorts, s1 and s2, by:
137  // value = (sign of s1)*(|s1|*256 + (|s2| modulo 256))
138  // * 2**((sign of s2) * (|s2|/256))
139 
140  int16_t nint; // Number of integers per section (Agard format) or
141  // number of bytes per section (SerialEM format)
142  int16_t nreal; // Number of reals per section (Agard format) or
143  // flags for which types of short data (SerialEM format):
144  // 1 = tilt angle * 100 (2 bytes)
145  // 2 = piece coordinates for montage (6 bytes)
146  // 4 = Stage position * 25 (4 bytes)
147  // 8 = Magnification / 100 (2 bytes)
148  // 16 = Intensity * 25000 (2 bytes)
149  // 32 = Exposure dose in e-/A2, a float in 4 bytes
150  // 128, 512: Reserved for 4-byte items
151  // 64, 256, 1024: Reserved for 2-byte items
152  // If the number of bytes implied by these flags does
153  // not add up to the value in nint, then nint and nreal
154  // are interpreted as ints and reals per section
155 
157  int8_t notused2[28];
158 
159  // Explanation of type of data.
160  int16_t idtype; // ( 0 = mono, 1 = tilt, 2 = tilts, 3 = lina, 4 =
161  // lins)
163  int16_t nd1; // for idtype = 1, nd1 = axis (1, 2, or 3)
165  int16_t vd1; // vd1 = 100. * tilt increment
166  int16_t vd2; // vd2 = 100. * starting angle
167 
168  // Used to rotate model to match new rotated image.
169  float tiltangles[6]; // 0,1,2 = original: 3,4,5 = current
170 
171  // NEW-STYLE MRC image2000 HEADER - IMOD 2.6.20 and above:
172  float xorg; // Origin of image. Used to auto translate model
173  float yorg; // to match a new image that has been translated.
174  float zorg;
175 
180  float rms;
181 
182  // ALL HEADERS:
186  };
187 
190  {
191 
216 
218  };
219 
221  enum
222  {
223  MRCHEADER_MODE_UINT8 = 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:95
itk::MRCHeaderObject::Header::nreal
int16_t nreal
Definition: itkMRCHeaderObject.h:142
itk::MRCHeaderObject::Header::zlen
float zlen
Definition: itkMRCHeaderObject.h:100
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:49
itk::MRCHeaderObject::Header::yorg
float yorg
Definition: itkMRCHeaderObject.h:173
itk::MRCHeaderObject::Header
Definition: itkMRCHeaderObject.h:67
itk::int16_t
::int16_t int16_t
Definition: itkIntTypes.h:30
itk::MRCHeaderObject::Header::nint
int16_t nint
Definition: itkMRCHeaderObject.h:140
itk::int8_t
::int8_t int8_t
Definition: itkIntTypes.h:28
itk::MRCHeaderObject::Header::idtype
int16_t idtype
Definition: itkMRCHeaderObject.h:160
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:180
itk::MRCHeaderObject::FeiExtendedHeader
Definition: itkMRCHeaderObject.h:189
itk::MRCHeaderObject::Header::my
int32_t my
Definition: itkMRCHeaderObject.h:94
itk::MRCHeaderObject::Header::nxstart
int32_t nxstart
Definition: itkMRCHeaderObject.h:88
itk::MRCHeaderObject::Header::vd2
int16_t vd2
Definition: itkMRCHeaderObject.h:166
itk::MRCHeaderObject::Header::xlen
float xlen
Definition: itkMRCHeaderObject.h:98
itk::MRCHeaderObject::Header::nd2
int16_t nd2
Definition: itkMRCHeaderObject.h:164
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::MRCHeaderObject::Header::ylen
float ylen
Definition: itkMRCHeaderObject.h:99
itk::MRCHeaderObject::FeiExtendedHeader::magnification
float magnification
Definition: itkMRCHeaderObject.h:215
itk::MRCHeaderObject::Header::beta
float beta
Definition: itkMRCHeaderObject.h:104
itk::MRCHeaderObject::Header::mode
int32_t mode
Definition: itkMRCHeaderObject.h:85
itkIntTypes.h
itk::MRCHeaderObject::Header::nzstart
int32_t nzstart
Definition: itkMRCHeaderObject.h:90
itk::MRCHeaderObject::Header::alpha
float alpha
Definition: itkMRCHeaderObject.h:103
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:105
itk::MRCHeaderObject::Header::vd1
int16_t vd1
Definition: itkMRCHeaderObject.h:165
itk::MRCHeaderObject::m_Header
Header m_Header
Definition: itkMRCHeaderObject.h:297
itk::MRCHeaderObject::Header::nystart
int32_t nystart
Definition: itkMRCHeaderObject.h:89
itk::int32_t
::int32_t int32_t
Definition: itkIntTypes.h:32
itk::MRCHeaderObject::Header::xorg
float xorg
Definition: itkMRCHeaderObject.h:172
itk::MRCHeaderObject::Header::mx
int32_t mx
Definition: itkMRCHeaderObject.h:93
itk::MRCHeaderObject::Header::zorg
float zorg
Definition: itkMRCHeaderObject.h:174
itk::MRCHeaderObject::Header::nd1
int16_t nd1
Definition: itkMRCHeaderObject.h:163
itkLightObject.h
itk::MRCHeaderObject::Header::lens
int16_t lens
Definition: itkMRCHeaderObject.h:162
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83