VTK  9.0.1
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 =========================================================================*/
35 #ifndef vtkNIFTIImageReader_h
36 #define vtkNIFTIImageReader_h
37 
38 #include "vtkIOImageModule.h" // For export macro
39 #include "vtkImageReader2.h"
40 
42 class vtkMatrix4x4;
43 
44 struct nifti_1_header;
45 
46 //----------------------------------------------------------------------------
47 class VTKIOIMAGE_EXPORT vtkNIFTIImageReader : public vtkImageReader2
48 {
49 public:
51 
54  static vtkNIFTIImageReader* New();
57 
61  void PrintSelf(ostream& os, vtkIndent indent) override;
62 
66  const char* GetFileExtensions() override { return ".nii .nii.gz .img .img.gz .hdr .hdr.gz"; }
67 
71  const char* GetDescriptiveName() override { return "NIfTI"; }
72 
76  int CanReadFile(const char* filename) override;
77 
79 
86  vtkGetMacro(TimeAsVector, bool);
87  vtkSetMacro(TimeAsVector, bool);
88  vtkBooleanMacro(TimeAsVector, bool);
90 
94  int GetTimeDimension() { return this->Dim[4]; }
95  double GetTimeSpacing() { return this->PixDim[4]; }
96 
104  double GetRescaleSlope() { return this->RescaleSlope; }
105  double GetRescaleIntercept() { return this->RescaleIntercept; }
106 
108 
115  vtkGetMacro(PlanarRGB, bool);
116  vtkSetMacro(PlanarRGB, bool);
117  vtkBooleanMacro(PlanarRGB, bool);
119 
130  double GetQFac() { return this->QFac; }
131 
144  vtkMatrix4x4* GetQFormMatrix() { return this->QFormMatrix; }
145 
160  vtkMatrix4x4* GetSFormMatrix() { return this->SFormMatrix; }
161 
165  vtkNIFTIImageHeader* GetNIFTIHeader();
166 
167 protected:
169  ~vtkNIFTIImageReader() override;
170 
174  int RequestInformation(vtkInformation* request, vtkInformationVector** inputVector,
175  vtkInformationVector* outputVector) override;
176 
180  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
181  vtkInformationVector* outputVector) override;
182 
188  static bool CheckExtension(const char* fname, const char* ext);
189 
198  static char* ReplaceExtension(const char* fname, const char* ext1, const char* ext2);
199 
203  static int CheckNIFTIVersion(const nifti_1_header* hdr);
204 
208  static bool CheckAnalyzeHeader(const nifti_1_header* hdr);
209 
214 
216 
220  double RescaleSlope;
222 
226  double QFac;
227 
229 
235 
239  int Dim[8];
240 
244  double PixDim[8];
245 
250 
254  bool PlanarRGB;
255 
256 private:
257  vtkNIFTIImageReader(const vtkNIFTIImageReader&) = delete;
258  void operator=(const vtkNIFTIImageReader&) = delete;
259 };
260 
261 #endif // vtkNIFTIImageReader_h
double QFac
Is -1 if VTK slice order is opposite to NIFTI slice order, +1 otherwise.
const char * GetFileExtensions() override
Valid extensions for this file type.
double GetQFac()
QFac gives the slice order in the NIFTI file versus the VTK image.
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
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.
double GetRescaleSlope()
Get the slope and intercept for rescaling the scalar values.
Read NIfTI-1 and NIfTI-2 medical image files.
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:33
bool PlanarRGB
Use planar RGB instead of the default (packed).
double RescaleSlope
Information for rescaling data to quantitative units.
Superclass of binary file readers.
vtkMatrix4x4 * GetSFormMatrix()
Get a matrix that gives the "sform" orientation and offset for the data.
int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Subclasses can reimplement this method to collect information from their inputs and set information f...
vtkNIFTIImageHeader * NIFTIHeader
A copy of the header from the file that was most recently read.
const char * GetDescriptiveName() override
Return a descriptive name that might be useful in a GUI.
Store zero or more vtkInformation instances.
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.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkMatrix4x4 * QFormMatrix
The orientation matrices for the NIFTI file.
bool TimeAsVector
Read the time dimension as if it was a vector dimension.