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 
57  static vtkNIFTIImageReader *New();
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 
170  vtkNIFTIImageHeader *GetNIFTIHeader();
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
virtual const char * GetDescriptiveName()
Return a descriptive name that might be useful in a GUI.
double QFac
Is -1 if VTK slice order is opposite to NIFTI slice order, +1 otherwise.
double GetQFac()
QFac gives the slice order in the NIFTI file versus the VTK image.
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
static vtkImageReader2 * New()
Store vtkAlgorithm input/output information.
Data structure defining the fields in the nifti1 header. This binary header should be found at the be...
vtkMatrix4x4 * GetQFormMatrix()
Get a matrix that gives the "qform" orientation and offset for the data.
virtual int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
Subclasses can reimplement this method to collect information from their inputs and set information f...
double GetRescaleSlope()
Get the slope and intercept for rescaling the scalar values.
Read NIfTI-1 and NIfTI-2 medical image files.
virtual const char * GetFileExtensions()
Valid extensions for this file type.
virtual int CanReadFile(const char *vtkNotUsed(fname))
Return non zero if the reader can read the given file name.
double RescaleIntercept
Information for rescaling data to quantitative units.
int GetTimeDimension()
Get the time dimension that was stored in the NIFTI header.
a simple class to control print indentation
Definition: vtkIndent.h:39
bool PlanarRGB
Use planar RGB instead of the default (packed).
double RescaleSlope
Information for rescaling data to quantitative units.
Superclass of binary file readers.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
vtkMatrix4x4 * GetSFormMatrix()
Get a matrix that gives the "sform" orientation and offset for the data.
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkNIFTIImageHeader * NIFTIHeader
A copy of the header from the file that was most recently read.
Store zero or more vtkInformation instances.
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called in response to a REQUEST_DATA request from the executive.
Store NIfTI header information.
vtkMatrix4x4 * SFormMatrix
The orientation matrices for the NIFTI file.
vtkMatrix4x4 * QFormMatrix
The orientation matrices for the NIFTI file.
bool TimeAsVector
Read the time dimension as if it was a vector dimension.