VTK
vtkNIFTIImageReader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkNIFTIImageReader.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 =========================================================================*/
38 #ifndef vtkNIFTIImageReader_h
39 #define vtkNIFTIImageReader_h
40 
41 #include "vtkIOImageModule.h" // For export macro
42 #include "vtkImageReader2.h"
43 
45 class vtkMatrix4x4;
46 
47 struct nifti_1_header;
48 
49 //----------------------------------------------------------------------------
50 class VTKIOIMAGE_EXPORT vtkNIFTIImageReader : public vtkImageReader2
51 {
52 public:
54 
60 
64  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
65 
69  virtual const char* GetFileExtensions() {
70  return ".nii .nii.gz .img .img.gz .hdr .hdr.gz"; }
71 
75  virtual const char* GetDescriptiveName() {
76  return "NIfTI"; }
77 
81  int CanReadFile(const char* filename);
82 
84 
91  vtkGetMacro(TimeAsVector, bool);
92  vtkSetMacro(TimeAsVector, bool);
93  vtkBooleanMacro(TimeAsVector, bool);
95 
99  int GetTimeDimension() { return this->Dim[4]; }
100  double GetTimeSpacing() { return this->PixDim[4]; }
101 
109  double GetRescaleSlope() { return this->RescaleSlope; }
110  double GetRescaleIntercept() { return this->RescaleIntercept; }
111 
113 
120  vtkGetMacro(PlanarRGB, bool);
121  vtkSetMacro(PlanarRGB, bool);
122  vtkBooleanMacro(PlanarRGB, bool);
124 
135  double GetQFac() { return this->QFac; }
136 
149  vtkMatrix4x4 *GetQFormMatrix() { return this->QFormMatrix; }
150 
165  vtkMatrix4x4 *GetSFormMatrix() { return this->SFormMatrix; }
166 
171 
172 protected:
175 
179  virtual int RequestInformation(
180  vtkInformation* request, vtkInformationVector** inputVector,
181  vtkInformationVector* outputVector);
182 
186  virtual int RequestData(
187  vtkInformation* request, vtkInformationVector** inputVector,
188  vtkInformationVector* outputVector);
189 
195  static bool CheckExtension(const char *fname, const char *ext);
196 
205  static char *ReplaceExtension(
206  const char *fname, const char *ext1, const char *ext2);
207 
211  static int CheckNIFTIVersion(const nifti_1_header *hdr);
212 
216  static bool CheckAnalyzeHeader(const nifti_1_header *hdr);
217 
222 
224 
228  double RescaleSlope;
230 
234  double QFac;
235 
237 
243 
247  int Dim[8];
248 
252  double PixDim[8];
253 
258 
262  bool PlanarRGB;
263 
264 private:
265  vtkNIFTIImageReader(const vtkNIFTIImageReader&) VTK_DELETE_FUNCTION;
266  void operator=(const vtkNIFTIImageReader&) VTK_DELETE_FUNCTION;
267 };
268 
269 #endif // vtkNIFTIImageReader_h
Superclass of binary file readers.
a simple class to control print indentation
Definition: vtkIndent.h:40
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:42
Store NIfTI header information.
Read NIfTI-1 and NIfTI-2 medical image files.
vtkMatrix4x4 * GetSFormMatrix()
Get a matrix that gives the "sform" orientation and offset for the data.
static bool CheckExtension(const char *fname, const char *ext)
Do a case-insensitive check for the given extension.
double GetQFac()
QFac gives the slice order in the NIFTI file versus the VTK image.
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
Read the header information.
static int CheckNIFTIVersion(const nifti_1_header *hdr)
Check the version of the header.
double QFac
Is -1 if VTK slice order is opposite to NIFTI slice order, +1 otherwise.
vtkMatrix4x4 * GetQFormMatrix()
Get a matrix that gives the "qform" orientation and offset for the data.
double GetRescaleSlope()
Get the slope and intercept for rescaling the scalar values.
virtual const char * GetFileExtensions()
Valid extensions for this file type.
void PrintSelf(ostream &os, vtkIndent indent) override
Print information about this object.
virtual const char * GetDescriptiveName()
Return a descriptive name that might be useful in a GUI.
bool PlanarRGB
Use planar RGB instead of the default (packed).
static char * ReplaceExtension(const char *fname, const char *ext1, const char *ext2)
Make a new filename by replacing extension "ext1" with "ext2".
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
Read the voxel data.
double RescaleIntercept
Information for rescaling data to quantitative units.
vtkMatrix4x4 * QFormMatrix
The orientation matrices for the NIFTI file.
static bool CheckAnalyzeHeader(const nifti_1_header *hdr)
Return true if an Analyze 7.5 header was found.
vtkNIFTIImageHeader * GetNIFTIHeader()
Get the raw header information from the NIfTI file.
static vtkNIFTIImageReader * New()
Static method for construction.
int CanReadFile(const char *filename)
Return true if this reader can read the given file.
vtkMatrix4x4 * SFormMatrix
bool TimeAsVector
Read the time dimension as if it was a vector dimension.
int GetTimeDimension()
Get the time dimension that was stored in the NIFTI header.
vtkNIFTIImageHeader * NIFTIHeader
A copy of the header from the file that was most recently read.
Data structure defining the fields in the nifti1 header. This binary header should be found at the be...
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.