ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkMRCHeaderObject.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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:
49  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 { MRCHEADER_MODE_UINT8 = 0,
222  MRCHEADER_MODE_IN16 = 1,
223  MRCHEADER_MODE_FLOAT = 2,
224  MRCHEADER_MODE_COMPLEX_INT16 = 3,
225  MRCHEADER_MODE_COMPLEX_FLOAT = 4,
226  MRCHEADER_MODE_UINT16 = 6,
227  MRCHEADER_MODE_RGB_BYTE = 16 };
228 
230  enum { MRCHEADER_MAP_X = 1,
231  MRCHEADER_MAP_Y = 2,
232  MRCHEADER_MAP_Z = 3 };
233 
234 public:
235 
237  itkNewMacro(Self);
238 
240  itkTypeMacro(MRCHeaderObject, LightObject);
241 
242  void DeepCopy(ConstPointer h);
243 
254  bool SetHeader(const Header *buffer);
255 
256  const Header & GetHeader() const;
257 
266  bool SetExtendedHeader(const void *buffer);
267 
271  SizeValueType GetExtendedHeaderSize() const;
272 
275  {
276  return sizeof( Header );
277  }
278 
282  bool IsOriginalHeaderBigEndian() const;
283 
285  Header m_Header; // FIXME : This should be private and
286  // should have Get/Set Methods.
287 
288 protected:
289 
290  MRCHeaderObject();
291  ~MRCHeaderObject() override;
292 
294  void swapHeader(bool bigEndian);
295 
297  void PrintSelf(std::ostream & os, Indent indent) const override;
298 
299 private:
300  SizeValueType m_ExtendedHeaderSize{0};
301  void * m_ExtendedHeader{nullptr};
302 
303  FeiExtendedHeader *m_ExtendedFeiHeader{nullptr};
304 
306 };
307 } // namespace itk
308 
309 #endif
Light weight base class for most itk classes.
unsigned long SizeValueType
Definition: itkIntTypes.h:83
This class is a light wrapper for a couple of plain old data structures, so that they can be utilized...
SizeValueType GetHeaderSize() const
Control indentation during Print() invocation.
Definition: itkIndent.h:49
::int8_t int8_t
Definition: itkIntTypes.h:28
::int32_t int32_t
Definition: itkIntTypes.h:32
::int16_t int16_t
Definition: itkIntTypes.h:30