VTK  9.7.1
vtkNIFTIImageReader.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
27 #ifndef vtkNIFTIImageReader_h
28 #define vtkNIFTIImageReader_h
29 
30 #include "vtkIOImageModule.h" // For export macro
31 #include "vtkImageReader2.h"
32 
33 VTK_ABI_NAMESPACE_BEGIN
35 class vtkMatrix4x4;
36 VTK_ABI_NAMESPACE_END
37 
38 struct nifti_1_header;
39 
40 VTK_ABI_NAMESPACE_BEGIN
41 
42 //----------------------------------------------------------------------------
43 class VTKIOIMAGE_EXPORT vtkNIFTIImageReader : public vtkImageReader2
44 {
45 public:
47 
50  static vtkNIFTIImageReader* New();
53 
57  void PrintSelf(ostream& os, vtkIndent indent) override;
58 
62  const char* GetFileExtensions() override { return ".nii .nii.gz .img .img.gz .hdr .hdr.gz"; }
63 
67  const char* GetDescriptiveName() override { return "NIfTI"; }
68 
69  using Superclass::CanReadFile;
73  int CanReadFile(VTK_FILEPATH const char* filename) override;
74 
76 
83  vtkGetMacro(TimeAsVector, bool);
84  vtkSetMacro(TimeAsVector, bool);
85  vtkBooleanMacro(TimeAsVector, bool);
87 
91  int GetTimeDimension() { return this->Dim[4]; }
92  double GetTimeSpacing() { return this->PixDim[4]; }
93 
101  double GetRescaleSlope() { return this->RescaleSlope; }
102  double GetRescaleIntercept() { return this->RescaleIntercept; }
103 
105 
112  vtkGetMacro(PlanarRGB, bool);
113  vtkSetMacro(PlanarRGB, bool);
114  vtkBooleanMacro(PlanarRGB, bool);
116 
127  double GetQFac() { return this->QFac; }
128 
141  vtkMatrix4x4* GetQFormMatrix() { return this->QFormMatrix; }
142 
157  vtkMatrix4x4* GetSFormMatrix() { return this->SFormMatrix; }
158 
162  vtkNIFTIImageHeader* GetNIFTIHeader();
163 
164 protected:
166  ~vtkNIFTIImageReader() override;
167 
171  int RequestInformation(vtkInformation* request, vtkInformationVector** inputVector,
172  vtkInformationVector* outputVector) override;
173 
177  int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
178  vtkInformationVector* outputVector) override;
179 
185  static bool CheckExtension(const char* filename, const char* ext);
186 
195  static char* ReplaceExtension(const char* filename, const char* ext1, const char* ext2);
196 
200  static int CheckNIFTIVersion(const nifti_1_header* hdr);
201 
205  static bool CheckAnalyzeHeader(const nifti_1_header* hdr);
206 
211 
213 
217  double RescaleSlope;
219 
223  double QFac;
224 
226 
232 
236  int Dim[8];
237 
241  double PixDim[8];
242 
247 
251  bool PlanarRGB;
252 
253 private:
254  vtkNIFTIImageReader(const vtkNIFTIImageReader&) = delete;
255  void operator=(const vtkNIFTIImageReader&) = delete;
256 };
257 
258 VTK_ABI_NAMESPACE_END
259 #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:31
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.
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:28
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...
virtual int CanReadFile(const char *fname)
Return non zero if the reader can read the given file name.
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.