VTK  9.1.0
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 
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(VTK_FILEPATH const char* auxfile);
335  VTK_FILEPATH 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 
390 
392 
396  void SetHeader(const nifti_1_header* hdr);
398  void SetHeader(const nifti_2_header* hdr);
401 
402 protected:
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
a simple class to control print indentation
Definition: vtkIndent.h:34
Store NIfTI header information.
vtkTypeInt64 GetVoxOffset()
Get the offset to the pixel data within the file.
double GetIntentP2()
Get one of the NIFTI intent parameters.
IntentCodeEnum
NIFTI intent codes.
double GetSclInter()
Get the scale and slope to apply to the data in order to get the real-valued data values.
UnitsXYZTEnum
NIFTI unit codes.
void GetHeader(nifti_1_header *hdr)
Set the values from an existing nifti struct, or store the values in an existing nifti struct.
int GetDataType()
Get the data type.
double GetQuaternB()
Get information about the quaternion transformation.
int GetDimInfo()
Get a bitfield with extra information about the dimensions, it states which dimensions are the phase ...
void SetAuxFile(VTK_FILEPATH const char *auxfile)
Get an auxiliary file, e.g.
int GetIntentCode()
Get the NIFTI intent code.
const char * GetIntentName()
const char * GetMagic()
Get the magic number for the NIFTI file as a null-terminated string.
double GetCalMax()
Get the calibrated range of the data, i.e.
void SetHeader(const nifti_1_header *hdr)
Set the values from an existing nifti struct, or store the values in an existing nifti struct.
void SetIntentName(const char *name)
Get the intent name.
double GetTOffset()
Get the slice_duration and toffset from the header.
int GetQFormCode()
Get the QForm or SForm code.
int GetBitPix()
Get the number of bits per pixel.
int GetSFormCode()
Get the QForm or SForm code.
void Initialize()
Initialize the header to default values.
void SetDescrip(const char *descrip)
Get a null-terminated file descriptor, this usually gives the name of the software that wrote the fil...
double GetSclSlope()
Get the scale and slope to apply to the data in order to get the real-valued data values.
~vtkNIFTIImageHeader() override
void SetHeader(const nifti_2_header *hdr)
Set the values from an existing nifti struct, or store the values in an existing nifti struct.
SliceCodeEnum
NIFTI slice codes.
XFormCodeEnum
NIFTI transform codes.
static vtkNIFTIImageHeader * New()
Static method for construction.
double GetPixDim(int i)
Get the sample spacing in the nth dimension.
int GetXYZTUnits()
Get a bitfield that describes the units for the first 4 dims.
vtkTypeInt64 GetDim(int i)
Get the nth dimension of the data, where GetDim(0) returns the number of dimensions that are defined ...
void GetHeader(nifti_2_header *hdr)
Set the values from an existing nifti struct, or store the values in an existing nifti struct.
double GetQOffsetY()
Get information about the quaternion transformation.
vtkTypeInt64 GetSliceStart()
Get the slice range for the data.
vtkTypeInt64 GetSliceEnd()
Get the slice range for the data.
void PrintSelf(ostream &os, vtkIndent indent) override
Print information about this object.
double GetSliceDuration()
Get the slice_duration and toffset from the header.
double GetIntentP3()
Get one of the NIFTI intent parameters.
double GetQuaternC()
Get information about the quaternion transformation.
VTK_FILEPATH const char * GetAuxFile()
void DeepCopy(vtkNIFTIImageHeader *o)
Make a copy of the header.
DataTypeEnum
NIFTI data types.
double GetIntentP1()
Get one of the NIFTI intent parameters.
HeaderSizeEnum
NIFTI header sizes.
double GetQuaternD()
Get information about the quaternion transformation.
double GetCalMin()
Get the calibrated range of the data, i.e.
void SetStringValue(char *x, const char *y, size_t n)
double GetQOffsetX()
Get information about the quaternion transformation.
int GetSliceCode()
Get the slice code for the data.
double GetQOffsetZ()
Get information about the quaternion transformation.
abstract base class for most VTK objects
Definition: vtkObject.h:63
@ name
Definition: vtkX3D.h:225
Data structure defining the fields in the nifti1 header. This binary header should be found at the be...
Data structure defining the fields in the nifti2 header. This binary header should be found at the be...
#define VTK_FILEPATH