VTK  9.0.20200808
vtkNIFTIImageHeader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkNIFTIImageHeader.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 vtkNIFTIImageHeader_h
37 #define vtkNIFTIImageHeader_h
38 
39 #include "vtkIOImageModule.h" // For export macro
40 #include "vtkObject.h"
41 
42 struct nifti_1_header;
43 struct nifti_2_header;
44 
45 //----------------------------------------------------------------------------
46 class VTKIOIMAGE_EXPORT vtkNIFTIImageHeader : public vtkObject
47 {
48 public:
53  {
54  IntentNone = 0,
55  IntentCorrel = 2,
56  IntentTTest = 3,
57  IntentFTest = 4,
58  IntentZScore = 5,
59  IntentChiSQ = 6,
60  IntentBeta = 7,
61  IntentBinom = 8,
62  IntentGamma = 9,
63  IntentPoisson = 10,
64  IntentNormal = 11,
65  IntentFTestNonc = 12,
66  IntentChiSQNonc = 13,
67  IntentLogistic = 14,
68  IntentLaplace = 15,
69  IntentUniform = 16,
70  IntentTTestNonc = 17,
71  IntentWeibull = 18,
72  IntentChi = 19,
73  IntentInvGauss = 20,
74  IntentExtVal = 21,
75  IntentPVal = 22,
76  IntentLogPVal = 23,
77  IntentLog10PVal = 24,
78  IntentEstimate = 1001,
79  IntentLabel = 1002,
80  IntentNeuroName = 1003,
81  IntentGenMatrix = 1004,
82  IntentSymMatrix = 1005,
83  IntentDispVect = 1006,
84  IntentVector = 1007,
85  IntentPointSet = 1008,
86  IntentTriangle = 1009,
87  IntentQuaternion = 1010,
88  IntentDimless = 1011,
89  IntentTimeSeries = 2001,
90  IntentNodeIndex = 2002,
91  IntentRGBVector = 2003,
92  IntentRGBAVector = 2004,
93  IntentShape = 2005
94  };
95 
100  {
101  XFormUnkown = 0,
102  XFormScannerAnat = 1,
103  XFormAlignedAnat = 2,
104  XFormTalairach = 3,
105  XFormMNI152 = 4
106  };
107 
112  {
113  SliceUnknown = 0,
114  SliceSeqInc = 1,
115  SliceSeqDec = 2,
116  SliceAltInc = 3,
117  SliceAltDec = 4,
118  SliceAltInc2 = 5,
119  SliceAltDec2 = 6
120  };
121 
126  {
127  UnitsUnknown = 0,
128  UnitsMeter = 1,
129  UnitsMM = 2,
130  UnitsMicron = 3,
131  UnitsSpace = 7,
132  UnitsSec = 8,
133  UnitsMSec = 16,
134  UnitsUSec = 24,
135  UnitsHz = 32,
136  UnitsPPM = 40,
137  UnitsRads = 48,
138  UnitsTime = 56
139  };
140 
148  {
149  TypeUInt8 = 2,
150  TypeInt16 = 4,
151  TypeInt32 = 8,
152  TypeFloat32 = 16,
153  TypeComplex64 = 32,
154  TypeFloat64 = 64,
155  TypeRGB24 = 128,
156  TypeInt8 = 256,
157  TypeUInt16 = 512,
158  TypeUInt32 = 768,
159  TypeInt64 = 1024,
160  TypeUInt64 = 1280,
161  TypeFloat128 = 1536,
162  TypeComplex128 = 1792,
163  TypeComplex256 = 2048,
164  TypeRGBA32 = 2304
165  };
166 
171  {
172  NIFTI1HeaderSize = 348,
173  NIFTI2HeaderSize = 540
174  };
175 
177 
180  static vtkNIFTIImageHeader* New();
183 
187  void PrintSelf(ostream& os, vtkIndent indent) override;
188 
192  const char* GetMagic() { return this->Magic; }
193 
197  vtkTypeInt64 GetVoxOffset() { return this->VoxOffset; }
198 
202  int GetDataType() { return this->DataType; }
203 
207  int GetBitPix() { return this->BitPix; }
208 
213  vtkTypeInt64 GetDim(int i) { return (i < 0 || i > 7 ? 0 : this->Dim[i]); }
214 
220  double GetPixDim(int i) { return (i < 0 || i > 7 ? 0.0 : this->PixDim[i]); }
221 
223 
227  vtkSetMacro(IntentCode, int);
228  int GetIntentCode() { return this->IntentCode; }
230 
234  void SetIntentName(const char* name);
235  const char* GetIntentName() { return this->IntentName; }
236 
238 
242  vtkSetMacro(IntentP1, double);
243  double GetIntentP1() { return this->IntentP1; }
244  vtkSetMacro(IntentP2, double);
245  double GetIntentP2() { return this->IntentP2; }
246  vtkSetMacro(IntentP3, double);
247  double GetIntentP3() { return this->IntentP3; }
249 
251 
255  vtkSetMacro(SclSlope, double);
256  double GetSclSlope() { return this->SclSlope; }
257  vtkSetMacro(SclInter, double);
258  double GetSclInter() { return this->SclInter; }
260 
262 
266  vtkSetMacro(CalMin, double);
267  double GetCalMin() { return this->CalMin; }
268  vtkSetMacro(CalMax, double);
269  double GetCalMax() { return this->CalMax; }
271 
273 
276  vtkSetMacro(SliceDuration, double);
277  double GetSliceDuration() { return this->SliceDuration; }
278  vtkSetMacro(TOffset, double);
279  double GetTOffset() { return this->TOffset; }
281 
283 
286  vtkSetMacro(SliceStart, vtkTypeInt64);
287  vtkTypeInt64 GetSliceStart() { return this->SliceStart; }
288  vtkSetMacro(SliceEnd, vtkTypeInt64);
289  vtkTypeInt64 GetSliceEnd() { return this->SliceEnd; }
291 
293 
296  vtkSetMacro(SliceCode, int);
297  int GetSliceCode() { return this->SliceCode; }
299 
301 
304  vtkSetMacro(XYZTUnits, int);
305  int GetXYZTUnits() { return this->XYZTUnits; }
307 
309 
314  vtkSetMacro(DimInfo, int);
315  int GetDimInfo() { return this->DimInfo; }
317 
325  void SetDescrip(const char* descrip);
326  const char* GetDescrip() { return this->Descrip; }
327 
334  void SetAuxFile(const char* auxfile);
335  const char* GetAuxFile() { return this->AuxFile; }
336 
338 
341  vtkSetMacro(QFormCode, int);
342  int GetQFormCode() { return this->QFormCode; }
343  vtkSetMacro(SFormCode, int);
344  int GetSFormCode() { return this->SFormCode; }
346 
348 
353  vtkSetMacro(QuaternB, double);
354  double GetQuaternB() { return this->QuaternB; }
355  vtkSetMacro(QuaternC, double);
356  double GetQuaternC() { return this->QuaternC; }
357  vtkSetMacro(QuaternD, double);
358  double GetQuaternD() { return this->QuaternD; }
359  vtkSetMacro(QOffsetX, double);
360  double GetQOffsetX() { return this->QOffsetX; }
361  vtkSetMacro(QOffsetY, double);
362  double GetQOffsetY() { return this->QOffsetY; }
363  vtkSetMacro(QOffsetZ, double);
364  double GetQOffsetZ() { return this->QOffsetZ; }
366 
368 
373  vtkSetVector4Macro(SRowX, double);
374  vtkGetVector4Macro(SRowX, double);
375  vtkSetVector4Macro(SRowY, double);
376  vtkGetVector4Macro(SRowY, double);
377  vtkSetVector4Macro(SRowZ, double);
378  vtkGetVector4Macro(SRowZ, double);
380 
384  void Initialize();
385 
389  void DeepCopy(vtkNIFTIImageHeader* o);
390 
392 
396  void SetHeader(const nifti_1_header* hdr);
397  void GetHeader(nifti_1_header* hdr);
398  void SetHeader(const nifti_2_header* hdr);
399  void GetHeader(nifti_2_header* hdr);
401 
402 protected:
404  ~vtkNIFTIImageHeader() override;
405 
406  char Magic[12];
407  vtkTypeInt64 VoxOffset;
408  int DataType;
409  int BitPix;
410  vtkTypeInt64 Dim[8];
411  double PixDim[8];
413  char IntentName[18];
414  double IntentP1;
415  double IntentP2;
416  double IntentP3;
417  double SclSlope;
418  double SclInter;
419  double CalMin;
420  double CalMax;
422  double TOffset;
423  vtkTypeInt64 SliceStart;
424  vtkTypeInt64 SliceEnd;
427  int DimInfo;
428  char Descrip[82];
429  char AuxFile[26];
432  double QuaternB;
433  double QuaternC;
434  double QuaternD;
435  double QOffsetX;
436  double QOffsetY;
437  double QOffsetZ;
438  double SRowX[4];
439  double SRowY[4];
440  double SRowZ[4];
441 
442  void SetStringValue(char* x, const char* y, size_t n);
443 
444 private:
445  vtkNIFTIImageHeader(const vtkNIFTIImageHeader&) = delete;
446  void operator=(const vtkNIFTIImageHeader&) = delete;
447 };
448 
449 #endif // vtkNIFTIImageHeader_h
vtkNIFTIImageHeader::GetTOffset
double GetTOffset()
Definition: vtkNIFTIImageHeader.h:279
vtkNIFTIImageHeader::XFormCodeEnum
XFormCodeEnum
NIFTI transform codes.
Definition: vtkNIFTIImageHeader.h:99
vtkNIFTIImageHeader::GetIntentP3
double GetIntentP3()
Definition: vtkNIFTIImageHeader.h:247
vtkNIFTIImageHeader::GetDataType
int GetDataType()
Get the data type.
Definition: vtkNIFTIImageHeader.h:202
vtkNIFTIImageHeader::GetSclSlope
double GetSclSlope()
Definition: vtkNIFTIImageHeader.h:256
vtkNIFTIImageHeader::SclSlope
double SclSlope
Definition: vtkNIFTIImageHeader.h:417
vtkNIFTIImageHeader::VoxOffset
vtkTypeInt64 VoxOffset
Definition: vtkNIFTIImageHeader.h:407
vtkNIFTIImageHeader::GetQFormCode
int GetQFormCode()
Definition: vtkNIFTIImageHeader.h:342
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkNIFTIImageHeader::IntentCode
int IntentCode
Definition: vtkNIFTIImageHeader.h:412
vtkNIFTIImageHeader::IntentP3
double IntentP3
Definition: vtkNIFTIImageHeader.h:416
vtkNIFTIImageHeader::SliceEnd
vtkTypeInt64 SliceEnd
Definition: vtkNIFTIImageHeader.h:424
vtkNIFTIImageHeader::GetIntentP2
double GetIntentP2()
Definition: vtkNIFTIImageHeader.h:245
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkNIFTIImageHeader::GetQuaternD
double GetQuaternD()
Definition: vtkNIFTIImageHeader.h:358
vtkNIFTIImageHeader::GetDimInfo
int GetDimInfo()
Definition: vtkNIFTIImageHeader.h:315
vtkNIFTIImageHeader::QFormCode
int QFormCode
Definition: vtkNIFTIImageHeader.h:430
vtkNIFTIImageHeader::GetAuxFile
const char * GetAuxFile()
Definition: vtkNIFTIImageHeader.h:335
vtkNIFTIImageHeader::SliceCode
int SliceCode
Definition: vtkNIFTIImageHeader.h:425
vtkNIFTIImageHeader::IntentP1
double IntentP1
Definition: vtkNIFTIImageHeader.h:414
vtkNIFTIImageHeader::GetMagic
const char * GetMagic()
Get the magic number for the NIFTI file as a null-terminated string.
Definition: vtkNIFTIImageHeader.h:192
vtkNIFTIImageHeader::QOffsetY
double QOffsetY
Definition: vtkNIFTIImageHeader.h:436
vtkNIFTIImageHeader
Store NIfTI header information.
Definition: vtkNIFTIImageHeader.h:46
vtkNIFTIImageHeader::TOffset
double TOffset
Definition: vtkNIFTIImageHeader.h:422
vtkNIFTIImageHeader::GetSliceDuration
double GetSliceDuration()
Definition: vtkNIFTIImageHeader.h:277
vtkNIFTIImageHeader::IntentP2
double IntentP2
Definition: vtkNIFTIImageHeader.h:415
vtkNIFTIImageHeader::CalMax
double CalMax
Definition: vtkNIFTIImageHeader.h:420
vtkNIFTIImageHeader::SliceCodeEnum
SliceCodeEnum
NIFTI slice codes.
Definition: vtkNIFTIImageHeader.h:111
vtkNIFTIImageHeader::GetIntentP1
double GetIntentP1()
Definition: vtkNIFTIImageHeader.h:243
vtkNIFTIImageHeader::CalMin
double CalMin
Definition: vtkNIFTIImageHeader.h:419
vtkNIFTIImageHeader::GetCalMin
double GetCalMin()
Definition: vtkNIFTIImageHeader.h:267
vtkNIFTIImageHeader::QuaternC
double QuaternC
Definition: vtkNIFTIImageHeader.h:433
vtkNIFTIImageHeader::QOffsetX
double QOffsetX
Definition: vtkNIFTIImageHeader.h:435
vtkNIFTIImageHeader::DataTypeEnum
DataTypeEnum
NIFTI data types.
Definition: vtkNIFTIImageHeader.h:147
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkNIFTIImageHeader::HeaderSizeEnum
HeaderSizeEnum
NIFTI header sizes.
Definition: vtkNIFTIImageHeader.h:170
vtkNIFTIImageHeader::BitPix
int BitPix
Definition: vtkNIFTIImageHeader.h:409
vtkNIFTIImageHeader::QuaternD
double QuaternD
Definition: vtkNIFTIImageHeader.h:434
vtkObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
nifti_1_header
Data structure defining the fields in the nifti1 header. This binary header should be found at the be...
Definition: vtkNIFTIImagePrivate.h:36
nifti_2_header
Data structure defining the fields in the nifti2 header. This binary header should be found at the be...
Definition: vtkNIFTIImagePrivate.h:222
vtkNIFTIImageHeader::GetIntentName
const char * GetIntentName()
Definition: vtkNIFTIImageHeader.h:235
vtkNIFTIImageHeader::GetCalMax
double GetCalMax()
Definition: vtkNIFTIImageHeader.h:269
vtkNIFTIImageHeader::GetIntentCode
int GetIntentCode()
Definition: vtkNIFTIImageHeader.h:228
vtkX3D::name
Definition: vtkX3D.h:225
vtkNIFTIImageHeader::GetQOffsetZ
double GetQOffsetZ()
Definition: vtkNIFTIImageHeader.h:364
vtkNIFTIImageHeader::GetSliceStart
vtkTypeInt64 GetSliceStart()
Definition: vtkNIFTIImageHeader.h:287
vtkObject.h
vtkNIFTIImageHeader::SliceStart
vtkTypeInt64 SliceStart
Definition: vtkNIFTIImageHeader.h:423
vtkNIFTIImageHeader::GetDim
vtkTypeInt64 GetDim(int i)
Get the nth dimension of the data, where GetDim(0) returns the number of dimensions that are defined ...
Definition: vtkNIFTIImageHeader.h:213
vtkNIFTIImageHeader::SclInter
double SclInter
Definition: vtkNIFTIImageHeader.h:418
vtkNIFTIImageHeader::GetSliceEnd
vtkTypeInt64 GetSliceEnd()
Definition: vtkNIFTIImageHeader.h:289
vtkNIFTIImageHeader::GetPixDim
double GetPixDim(int i)
Get the sample spacing in the nth dimension.
Definition: vtkNIFTIImageHeader.h:220
vtkNIFTIImageHeader::XYZTUnits
int XYZTUnits
Definition: vtkNIFTIImageHeader.h:426
vtkNIFTIImageHeader::QOffsetZ
double QOffsetZ
Definition: vtkNIFTIImageHeader.h:437
vtkNIFTIImageHeader::GetSliceCode
int GetSliceCode()
Definition: vtkNIFTIImageHeader.h:297
vtkNIFTIImageHeader::GetQOffsetX
double GetQOffsetX()
Definition: vtkNIFTIImageHeader.h:360
vtkNIFTIImageHeader::GetXYZTUnits
int GetXYZTUnits()
Definition: vtkNIFTIImageHeader.h:305
vtkNIFTIImageHeader::GetVoxOffset
vtkTypeInt64 GetVoxOffset()
Get the offset to the pixel data within the file.
Definition: vtkNIFTIImageHeader.h:197
vtkNIFTIImageHeader::GetQuaternC
double GetQuaternC()
Definition: vtkNIFTIImageHeader.h:356
vtkNIFTIImageHeader::GetQOffsetY
double GetQOffsetY()
Definition: vtkNIFTIImageHeader.h:362
vtkNIFTIImageHeader::QuaternB
double QuaternB
Definition: vtkNIFTIImageHeader.h:432
vtkNIFTIImageHeader::UnitsXYZTEnum
UnitsXYZTEnum
NIFTI unit codes.
Definition: vtkNIFTIImageHeader.h:125
vtkNIFTIImageHeader::DimInfo
int DimInfo
Definition: vtkNIFTIImageHeader.h:427
vtkNIFTIImageHeader::GetDescrip
const char * GetDescrip()
Definition: vtkNIFTIImageHeader.h:326
vtkNIFTIImageHeader::GetBitPix
int GetBitPix()
Get the number of bits per pixel.
Definition: vtkNIFTIImageHeader.h:207
vtkNIFTIImageHeader::SliceDuration
double SliceDuration
Definition: vtkNIFTIImageHeader.h:421
vtkNIFTIImageHeader::GetQuaternB
double GetQuaternB()
Definition: vtkNIFTIImageHeader.h:354
vtkNIFTIImageHeader::SFormCode
int SFormCode
Definition: vtkNIFTIImageHeader.h:431
vtkNIFTIImageHeader::GetSFormCode
int GetSFormCode()
Definition: vtkNIFTIImageHeader.h:344
vtkNIFTIImageHeader::DataType
int DataType
Definition: vtkNIFTIImageHeader.h:408
vtkNIFTIImageHeader::IntentCodeEnum
IntentCodeEnum
NIFTI intent codes.
Definition: vtkNIFTIImageHeader.h:52
vtkNIFTIImageHeader::GetSclInter
double GetSclInter()
Definition: vtkNIFTIImageHeader.h:258