VTK  9.2.6
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) override;
65 
69  const char* GetFileExtensions() override { return ".nii .nii.gz .img .img.gz .hdr .hdr.gz"; }
70 
74  const char* GetDescriptiveName() override { return "NIfTI"; }
75 
79  int CanReadFile(VTK_FILEPATH const char* filename) override;
80 
82 
89  vtkGetMacro(TimeAsVector, bool);
90  vtkSetMacro(TimeAsVector, bool);
91  vtkBooleanMacro(TimeAsVector, bool);
93 
97  int GetTimeDimension() { return this->Dim[4]; }
98  double GetTimeSpacing() { return this->PixDim[4]; }
99 
107  double GetRescaleSlope() { return this->RescaleSlope; }
108  double GetRescaleIntercept() { return this->RescaleIntercept; }
109 
111 
118  vtkGetMacro(PlanarRGB, bool);
119  vtkSetMacro(PlanarRGB, bool);
120  vtkBooleanMacro(PlanarRGB, bool);
122 
133  double GetQFac() { return this->QFac; }
134 
147  vtkMatrix4x4* GetQFormMatrix() { return this->QFormMatrix; }
148 
163  vtkMatrix4x4* GetSFormMatrix() { return this->SFormMatrix; }
164 
168  vtkNIFTIImageHeader* GetNIFTIHeader();
169 
170 protected:
172  ~vtkNIFTIImageReader() override;
173 
177  int RequestInformation(vtkInformation* request, vtkInformationVector** inputVector,
178  vtkInformationVector* outputVector) override;
179 
183  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
184  vtkInformationVector* outputVector) override;
185 
191  static bool CheckExtension(const char* filename, const char* ext);
192 
201  static char* ReplaceExtension(const char* filename, const char* ext1, const char* ext2);
202 
206  static int CheckNIFTIVersion(const nifti_1_header* hdr);
207 
211  static bool CheckAnalyzeHeader(const nifti_1_header* hdr);
212 
217 
219 
223  double RescaleSlope;
225 
229  double QFac;
230 
232 
238 
242  int Dim[8];
243 
247  double PixDim[8];
248 
253 
257  bool PlanarRGB;
258 
259 private:
260  vtkNIFTIImageReader(const vtkNIFTIImageReader&) = delete;
261  void operator=(const vtkNIFTIImageReader&) = delete;
262 };
263 
264 #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: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.
double GetRescaleSlope()
Get the slope and intercept for rescaling the scalar values.
virtual int CanReadFile(VTK_FILEPATH const char *vtkNotUsed(fname))
Return non zero if the reader can read the given file name.
Read NIfTI-1 and NIfTI-2 medical image files.
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.
vtkMatrix4x4 * GetSFormMatrix()
Get a matrix that gives the "sform" orientation and offset for the data.
#define VTK_FILEPATH
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.