vtk-dicom  0.8.17
vtkNIFTIHeader.h
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkNIFTIHeader.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
36 #ifndef vtkNIFTIHeader_h
37 #define vtkNIFTIHeader_h
38 
39 #include "vtkObject.h"
40 #include "vtkDICOMModule.h" // For export macro
41 #include "vtkDICOMConfig.h" // For configuration details
42 
43 struct nifti_1_header;
44 struct nifti_2_header;
45 
46 //----------------------------------------------------------------------------
47 class VTKDICOM_EXPORT vtkNIFTIHeader : public vtkObject
48 {
49 public:
50 
53  IntentNone = 0,
54  IntentCorrel = 2,
55  IntentTTest = 3,
56  IntentFTest = 4,
57  IntentZScore = 5,
58  IntentChiSQ = 6,
59  IntentBeta = 7,
60  IntentBinom = 8,
61  IntentGamma = 9,
62  IntentPoisson = 10,
63  IntentNormal = 11,
64  IntentFTestNonc = 12,
65  IntentChiSQNonc = 13,
66  IntentLogistic = 14,
67  IntentLaplace = 15,
68  IntentUniform = 16,
69  IntentTTestNonc = 17,
70  IntentWeibull = 18,
71  IntentChi = 19,
72  IntentInvGauss = 20,
73  IntentExtVal = 21,
74  IntentPVal = 22,
75  IntentLogPVal = 23,
76  IntentLog10PVal = 24,
77  IntentEstimate = 1001,
78  IntentLabel = 1002,
79  IntentNeuroName = 1003,
80  IntentGenMatrix = 1004,
81  IntentSymMatrix = 1005,
82  IntentDispVect = 1006,
83  IntentVector = 1007,
84  IntentPointSet = 1008,
85  IntentTriangle = 1009,
86  IntentQuaternion = 1010,
87  IntentDimless = 1011,
88  IntentTimeSeries = 2001,
89  IntentNodeIndex = 2002,
90  IntentRGBVector = 2003,
91  IntentRGBAVector = 2004,
92  IntentShape = 2005
93  };
94 
97  XFormUnkown = 0,
98  XFormScannerAnat = 1,
99  XFormAlignedAnat = 2,
100  XFormTalairach = 3,
101  XFormMNI152 = 4,
102  XFormTemplateOther = 5
103  };
104 
107  SliceUnknown = 0,
108  SliceSeqInc = 1,
109  SliceSeqDec = 2,
110  SliceAltInc = 3,
111  SliceAltDec = 4,
112  SliceAltInc2 = 5,
113  SliceAltDec2 = 6
114  };
115 
118  UnitsUnknown = 0,
119  UnitsMeter = 1,
120  UnitsMM = 2,
121  UnitsMicron = 3,
122  UnitsSpace = 7,
123  UnitsSec = 8,
124  UnitsMSec = 16,
125  UnitsUSec = 24,
126  UnitsHz = 32,
127  UnitsPPM = 40,
128  UnitsRads = 48,
129  UnitsTime = 56
130  };
131 
133 
139  TypeUInt8 = 2,
140  TypeInt16 = 4,
141  TypeInt32 = 8,
142  TypeFloat32 = 16,
143  TypeComplex64 = 32,
144  TypeFloat64 = 64,
145  TypeRGB24 = 128,
146  TypeInt8 = 256,
147  TypeUInt16 = 512,
148  TypeUInt32 = 768,
149  TypeInt64 = 1024,
150  TypeUInt64 = 1280,
151  TypeFloat128 = 1536,
152  TypeComplex128 = 1792,
153  TypeComplex256 = 2048,
154  TypeRGBA32 = 2304
155  };
156 
159  Nifti1HeaderSize = 348,
160  Nifti2HeaderSize = 540
161  };
162 
164  static vtkNIFTIHeader *New();
165  vtkTypeMacro(vtkNIFTIHeader, vtkObject);
166 
168  void PrintSelf(ostream& os, vtkIndent indent) VTK_DICOM_OVERRIDE;
169 
171  const char *GetMagic() { return this->Magic; }
173 
175  vtkTypeInt64 GetVoxOffset() { return this->VoxOffset; }
176 
178  int GetDataType() { return this->DataType; }
179 
181  int GetBitPix() { return this->BitPix; }
183 
185 
189  vtkTypeInt64 GetDim(int i) {
190  return (i < 0 || i > 7 ? 0 : this->Dim[i]); }
191 
193 
197  double GetPixDim(int i) {
198  return (i < 0 || i > 7 ? 0.0 : this->PixDim[i]); }
200 
202 
207  vtkSetMacro(IntentCode, int);
208  int GetIntentCode() { return this->IntentCode; }
210 
212  void SetIntentName(const char *name);
214  const char *GetIntentName() { return this->IntentName; }
216 
218 
222  vtkSetMacro(IntentP1, double);
223  double GetIntentP1() { return this->IntentP1; }
224  vtkSetMacro(IntentP2, double);
225  double GetIntentP2() { return this->IntentP2; }
226  vtkSetMacro(IntentP3, double);
227  double GetIntentP3() { return this->IntentP3; }
229 
231  vtkSetMacro(SclSlope, double);
233  double GetSclSlope() { return this->SclSlope; }
234  vtkSetMacro(SclInter, double);
235  double GetSclInter() { return this->SclInter; }
237 
239  vtkSetMacro(CalMin, double);
241  double GetCalMin() { return this->CalMin; }
242  vtkSetMacro(CalMax, double);
243  double GetCalMax() { return this->CalMax; }
245 
247  vtkSetMacro(SliceDuration, double);
249  double GetSliceDuration() { return this->SliceDuration; }
250  vtkSetMacro(TOffset, double);
251  double GetTOffset() { return this->TOffset; }
253 
255  vtkSetMacro(SliceStart, vtkTypeInt64);
257  vtkTypeInt64 GetSliceStart() { return this->SliceStart; }
258  vtkSetMacro(SliceEnd, vtkTypeInt64);
259  vtkTypeInt64 GetSliceEnd() { return this->SliceEnd; }
261 
263  vtkSetMacro(SliceCode, int);
265  int GetSliceCode() { return this->SliceCode; }
267 
269  vtkSetMacro(XYZTUnits, int);
271  int GetXYZTUnits() { return this->XYZTUnits; }
273 
275 
280  vtkSetMacro(DimInfo, int);
281  int GetDimInfo() { return this->DimInfo; }
283 
285 
290  void SetDescrip(const char *descrip);
291  const char *GetDescrip() { return this->Descrip; }
293 
295 
301  void SetAuxFile(const char *auxfile);
302  const char *GetAuxFile() { return this->AuxFile; }
304 
306  vtkSetMacro(QFormCode, int);
308  int GetQFormCode() { return this->QFormCode; }
309  vtkSetMacro(SFormCode, int);
310  int GetSFormCode() { return this->SFormCode; }
312 
314 
319  vtkSetMacro(QuaternB, double);
320  double GetQuaternB() { return this->QuaternB; }
321  vtkSetMacro(QuaternC, double);
322  double GetQuaternC() { return this->QuaternC; }
323  vtkSetMacro(QuaternD, double);
324  double GetQuaternD() { return this->QuaternD; }
325  vtkSetMacro(QOffsetX, double);
326  double GetQOffsetX() { return this->QOffsetX; }
327  vtkSetMacro(QOffsetY, double);
328  double GetQOffsetY() { return this->QOffsetY; }
329  vtkSetMacro(QOffsetZ, double);
330  double GetQOffsetZ() { return this->QOffsetZ; }
332 
334 
339  vtkSetVector4Macro(SRowX, double);
340  vtkGetVector4Macro(SRowX, double);
341  vtkSetVector4Macro(SRowY, double);
342  vtkGetVector4Macro(SRowY, double);
343  vtkSetVector4Macro(SRowZ, double);
344  vtkGetVector4Macro(SRowZ, double);
346 
348  void Initialize();
351 
353  void DeepCopy(vtkNIFTIHeader *o);
356 
358  void SetHeader(const nifti_1_header *hdr);
360  void GetHeader(nifti_1_header *hdr);
361  void SetHeader(const nifti_2_header *hdr);
362  void GetHeader(nifti_2_header *hdr);
364 
366  static void ByteSwapHeader(nifti_1_header *hdr);
368  static void ByteSwapHeader(nifti_2_header *hdr);
370 
371 protected:
372  vtkNIFTIHeader();
373  ~vtkNIFTIHeader() VTK_DICOM_OVERRIDE;
374 
375  char Magic[12];
376  vtkTypeInt64 VoxOffset;
377  int DataType;
378  int BitPix;
379  vtkTypeInt64 Dim[8];
380  double PixDim[8];
381  int IntentCode;
382  char IntentName[18];
383  double IntentP1;
384  double IntentP2;
385  double IntentP3;
386  double SclSlope;
387  double SclInter;
388  double CalMin;
389  double CalMax;
390  double SliceDuration;
391  double TOffset;
392  vtkTypeInt64 SliceStart;
393  vtkTypeInt64 SliceEnd;
394  int SliceCode;
395  int XYZTUnits;
396  int DimInfo;
397  char Descrip[82];
398  char AuxFile[26];
399  int QFormCode;
400  int SFormCode;
401  double QuaternB;
402  double QuaternC;
403  double QuaternD;
404  double QOffsetX;
405  double QOffsetY;
406  double QOffsetZ;
407  double SRowX[4];
408  double SRowY[4];
409  double SRowZ[4];
410 
411  void SetStringValue(char *x, const char *y, size_t n);
412 
413 private:
414 #ifdef VTK_DICOM_DELETE
415  vtkNIFTIHeader(const vtkNIFTIHeader&) VTK_DICOM_DELETE;
416  void operator=(const vtkNIFTIHeader&) VTK_DICOM_DELETE;
417 #else
418  vtkNIFTIHeader(const vtkNIFTIHeader&) = delete;
419  void operator=(const vtkNIFTIHeader&) = delete;
420 #endif
421 };
422 
423 #endif // vtkNIFTIHeader_h
Store NIfTI header information.
Definition: vtkNIFTIHeader.h:48
XFormCodeEnum
NIFTI transform codes.
Definition: vtkNIFTIHeader.h:96
static vtkNIFTIHeader * New()
Static method for construction.
void SetDescrip(const char *descrip)
Get a null-terminated file descriptor, this usually gives the.
int GetDataType()
Get the data type.
Definition: vtkNIFTIHeader.h:178
double GetPixDim(int i)
Get the sample spacing in the nth dimension, 1 is first dimension.
Definition: vtkNIFTIHeader.h:197
DataTypeEnum
NIFTI data types.
Definition: vtkNIFTIHeader.h:138
void PrintSelf(ostream &os, vtkIndent indent) VTK_DICOM_OVERRIDE
Print information about this object.
vtkTypeInt64 GetVoxOffset()
Get the offset to the pixel data within the file.
Definition: vtkNIFTIHeader.h:175
void SetAuxFile(const char *auxfile)
Get an auxiliary file, e.g. a color table, that is associated.
HeaderSizeEnum
NIFTI header sizes.
Definition: vtkNIFTIHeader.h:158
UnitsXYZTEnum
NIFTI unit codes.
Definition: vtkNIFTIHeader.h:117
IntentCodeEnum
NIFTI intent codes.
Definition: vtkNIFTIHeader.h:52
vtkTypeInt64 GetDim(int i)
Get the nth dimension of the data, where 1 is first dimension.
Definition: vtkNIFTIHeader.h:189
int GetBitPix()
Get the number of bits per pixel.
Definition: vtkNIFTIHeader.h:181
SliceCodeEnum
NIFTI slice codes.
Definition: vtkNIFTIHeader.h:106
abstract base class for most VTK objects
Definition: vtkObject.h:54
Data structure defining the fields in the nifti1 header. This binary header should be found at the be...
Definition: vtkNIFTIPrivate.h:36
Data structure defining the fields in the nifti2 header. This binary header should be found at the be...
Definition: vtkNIFTIPrivate.h:227