ITK  6.0.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 * https://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
26namespace itk
27{
28
48class ITKIOMRC_EXPORT MRCHeaderObject : public LightObject
49{
50public:
51 ITK_DISALLOW_COPY_AND_MOVE(MRCHeaderObject);
52
58
66 struct Header
67 {
68
84 int32_t mode;
85
87 int32_t nxstart;
88 int32_t nystart;
89 int32_t nzstart;
90
92 int32_t mx;
93 int32_t my;
94 int32_t mz;
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)
161 int16_t lens;
162 int16_t nd1; // for idtype = 1, nd1 = axis (1, 2, or 3)
163 int16_t nd2;
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
240public:
242 itkNewMacro(Self);
243
245 itkOverrideGetNameOfClassMacro(MRCHeaderObject);
246
247 void
249
260 bool
261 SetHeader(const Header * buffer);
262
263 const Header &
264 GetHeader() const;
265
274 bool
275 SetExtendedHeader(const void * buffer);
276
282
286 {
287 return sizeof(Header);
288 }
289
293 bool
295
297 Header m_Header{}; // FIXME : This should be private and
298 // should have Get/Set Methods.
299
300protected:
303
305 void
306 swapHeader(bool bigEndian);
307
309 void
310 PrintSelf(std::ostream & os, Indent indent) const override;
311
312private:
313 SizeValueType m_ExtendedHeaderSize{ 0 };
314 void * m_ExtendedHeader{ nullptr };
315
316 FeiExtendedHeader * m_ExtendedFeiHeader{ nullptr };
317
318 bool m_BigEndianHeader{};
319};
320} // namespace itk
321
322#endif
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Light weight base class for most itk classes.
This class is a light wrapper for a couple of plain old data structures, so that they can be utilized...
const Header & GetHeader() const
bool SetHeader(const Header *buffer)
void DeepCopy(ConstPointer h)
bool SetExtendedHeader(const void *buffer)
SizeValueType GetHeaderSize() const
bool IsOriginalHeaderBigEndian() const
SizeValueType GetExtendedHeaderSize() const
void swapHeader(bool bigEndian)
void PrintSelf(std::ostream &os, Indent indent) const override
~MRCHeaderObject() override
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition: itkIntTypes.h:86