ITK  4.13.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:
57 
65  struct Header
66  {
67 
84 
89 
94 
96  float xlen;
97  float ylen;
98  float zlen;
99 
101  float alpha;
102  float beta;
103  float gamma;
104 
111  // These need to be set for proper scaling of
112  // non byte data.
129  // These two values specify the structure of data in the
130  // extended header; their meaning depend on whether the
131  // extended header has the Agard format, a series of
132  // 4-byte integers then real numbers, or has data
133  // produced by SerialEM, a series of short integers.
134  // SerialEM stores a float as two shorts, s1 and s2, by:
135  // value = (sign of s1)*(|s1|*256 + (|s2| modulo 256))
136  // * 2**((sign of s2) * (|s2|/256))
137 
138  int16_t nint; // Number of integers per section (Agard format) or
139  // number of bytes per section (SerialEM format)
140  int16_t nreal; // Number of reals per section (Agard format) or
141  // flags for which types of short data (SerialEM format):
142  // 1 = tilt angle * 100 (2 bytes)
143  // 2 = piece coordinates for montage (6 bytes)
144  // 4 = Stage position * 25 (4 bytes)
145  // 8 = Magnification / 100 (2 bytes)
146  // 16 = Intensity * 25000 (2 bytes)
147  // 32 = Exposure dose in e-/A2, a float in 4 bytes
148  // 128, 512: Reserved for 4-byte items
149  // 64, 256, 1024: Reserved for 2-byte items
150  // If the number of bytes implied by these flags does
151  // not add up to the value in nint, then nint and nreal
152  // are interpreted as ints and reals per section
153 
155  int8_t notused2[28];
156 
157  // Explanation of type of data.
158  int16_t idtype; // ( 0 = mono, 1 = tilt, 2 = tilts, 3 = lina, 4 =
159  // lins)
161  int16_t nd1; // for idtype = 1, nd1 = axis (1, 2, or 3)
163  int16_t vd1; // vd1 = 100. * tilt increment
164  int16_t vd2; // vd2 = 100. * starting angle
165 
166  // Used to rotate model to match new rotated image.
167  float tiltangles[6]; // 0,1,2 = original: 3,4,5 = current
168 
169  // NEW-STYLE MRC image2000 HEADER - IMOD 2.6.20 and above:
170  float xorg; // Origin of image. Used to auto translate model
171  float yorg; // to match a new image that has been translated.
172  float zorg;
173 
178  float rms;
179 
180  // ALL HEADERS:
184  };
185 
188  {
189 
214 
216  };
217 
219  enum { MRCHEADER_MODE_UINT8 = 0,
220  MRCHEADER_MODE_IN16 = 1,
221  MRCHEADER_MODE_FLOAT = 2,
222  MRCHEADER_MODE_COMPLEX_INT16 = 3,
223  MRCHEADER_MODE_COMPLEX_FLOAT = 4,
224  MRCHEADER_MODE_UINT16 = 6,
225  MRCHEADER_MODE_RGB_BYTE = 16 };
226 
228  enum { MRCHEADER_MAP_X = 1,
229  MRCHEADER_MAP_Y = 2,
230  MRCHEADER_MAP_Z = 3 };
231 
232 public:
233 
235  itkNewMacro(Self);
236 
238  itkTypeMacro(MRCHeaderObject, LightObject);
239 
240  void DeepCopy(ConstPointer h);
241 
252  bool SetHeader(const Header *buffer);
253 
254  const Header & GetHeader() const;
255 
264  bool SetExtendedHeader(const void *buffer);
265 
269  SizeValueType GetExtendedHeaderSize() const;
270 
273  {
274  return sizeof( Header );
275  }
276 
280  bool IsOriginalHeaderBigEndian() const;
281 
283  Header m_Header; // FIXME : This should be private and
284  // should have Get/Set Methods.
285 
286 protected:
287 
288  MRCHeaderObject();
289  ~MRCHeaderObject() ITK_OVERRIDE;
290 
292  void swapHeader(bool bigEndian);
293 
295  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
296 
297 private:
298  ITK_DISALLOW_COPY_AND_ASSIGN(MRCHeaderObject);
299 
300  SizeValueType m_ExtendedHeaderSize;
301  void * m_ExtendedHeader;
302 
303  FeiExtendedHeader *m_ExtendedFeiHeader;
304 
305  bool m_BigEndianHeader;
306 };
307 } // namespace itk
308 
309 #endif
Light weight base class for most itk classes.
unsigned long SizeValueType
Definition: itkIntTypes.h:143
SmartPointer< const Self > ConstPointer
This class is a light wrapper for a couple of plain old data structures, so that they can be utilized...
KWIML_INT_int16_t int16_t
Definition: itkIntTypes.h:84
SizeValueType GetHeaderSize(void) const
KWIML_INT_int8_t int8_t
Definition: itkIntTypes.h:82
SmartPointer< Self > Pointer
Control indentation during Print() invocation.
Definition: itkIndent.h:49
KWIML_INT_int32_t int32_t
Definition: itkIntTypes.h:86