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 =========================================================================*/
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 {
67  return ".nii .nii.gz .img .img.gz .hdr .hdr.gz"; }
68 
72  const char* GetDescriptiveName() override {
73  return "NIfTI"; }
74 
78  int CanReadFile(const char* filename) override;
79 
81 
88  vtkGetMacro(TimeAsVector, bool);
89  vtkSetMacro(TimeAsVector, bool);
90  vtkBooleanMacro(TimeAsVector, bool);
92 
96  int GetTimeDimension() { return this->Dim[4]; }
97  double GetTimeSpacing() { return this->PixDim[4]; }
98 
106  double GetRescaleSlope() { return this->RescaleSlope; }
107  double GetRescaleIntercept() { return this->RescaleIntercept; }
108 
110 
117  vtkGetMacro(PlanarRGB, bool);
118  vtkSetMacro(PlanarRGB, bool);
119  vtkBooleanMacro(PlanarRGB, bool);
121 
132  double GetQFac() { return this->QFac; }
133 
146  vtkMatrix4x4 *GetQFormMatrix() { return this->QFormMatrix; }
147 
162  vtkMatrix4x4 *GetSFormMatrix() { return this->SFormMatrix; }
163 
167  vtkNIFTIImageHeader *GetNIFTIHeader();
168 
169 protected:
171  ~vtkNIFTIImageReader() override;
172 
176  int RequestInformation(
177  vtkInformation* request, vtkInformationVector** inputVector,
178  vtkInformationVector* outputVector) override;
179 
183  int RequestData(
184  vtkInformation* request, vtkInformationVector** inputVector,
185  vtkInformationVector* outputVector) override;
186 
192  static bool CheckExtension(const char *fname, const char *ext);
193 
202  static char *ReplaceExtension(
203  const char *fname, const char *ext1, const char *ext2);
204 
208  static int CheckNIFTIVersion(const nifti_1_header *hdr);
209 
213  static bool CheckAnalyzeHeader(const nifti_1_header *hdr);
214 
219 
221 
225  double RescaleSlope;
227 
231  double QFac;
232 
234 
240 
244  int Dim[8];
245 
249  double PixDim[8];
250 
255 
259  bool PlanarRGB;
260 
261 private:
262  vtkNIFTIImageReader(const vtkNIFTIImageReader&) = delete;
263  void operator=(const vtkNIFTIImageReader&) = delete;
264 };
265 
266 #endif // vtkNIFTIImageReader_h
vtkImageAlgorithm::RequestData
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called in response to a REQUEST_DATA request from the executive.
vtkImageReader2::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkNIFTIImageReader::GetDescriptiveName
const char * GetDescriptiveName() override
Return a descriptive name that might be useful in a GUI.
Definition: vtkNIFTIImageReader.h:72
vtkNIFTIImageReader::GetTimeDimension
int GetTimeDimension()
Get the time dimension that was stored in the NIFTI header.
Definition: vtkNIFTIImageReader.h:96
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:35
vtkNIFTIImageReader::GetSFormMatrix
vtkMatrix4x4 * GetSFormMatrix()
Get a matrix that gives the "sform" orientation and offset for the data.
Definition: vtkNIFTIImageReader.h:162
vtkNIFTIImageReader::RescaleSlope
double RescaleSlope
Definition: vtkNIFTIImageReader.h:225
vtkImageReader2::RequestInformation
int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Subclasses can reimplement this method to collect information from their inputs and set information f...
vtkNIFTIImageReader::QFormMatrix
vtkMatrix4x4 * QFormMatrix
The orientation matrices for the NIFTI file.
Definition: vtkNIFTIImageReader.h:237
vtkNIFTIImageReader::NIFTIHeader
vtkNIFTIImageHeader * NIFTIHeader
A copy of the header from the file that was most recently read.
Definition: vtkNIFTIImageReader.h:254
vtkNIFTIImageReader::GetTimeSpacing
double GetTimeSpacing()
Definition: vtkNIFTIImageReader.h:97
vtkNIFTIImageHeader
Store NIfTI header information.
Definition: vtkNIFTIImageHeader.h:46
vtkNIFTIImageReader::GetQFormMatrix
vtkMatrix4x4 * GetQFormMatrix()
Get a matrix that gives the "qform" orientation and offset for the data.
Definition: vtkNIFTIImageReader.h:146
vtkNIFTIImageReader
Read NIfTI-1 and NIfTI-2 medical image files.
Definition: vtkNIFTIImageReader.h:47
vtkImageReader2::New
static vtkImageReader2 * New()
vtkNIFTIImageReader::GetRescaleSlope
double GetRescaleSlope()
Get the slope and intercept for rescaling the scalar values.
Definition: vtkNIFTIImageReader.h:106
vtkNIFTIImageReader::QFac
double QFac
Is -1 if VTK slice order is opposite to NIFTI slice order, +1 otherwise.
Definition: vtkNIFTIImageReader.h:231
vtkNIFTIImageReader::PlanarRGB
bool PlanarRGB
Use planar RGB instead of the default (packed).
Definition: vtkNIFTIImageReader.h:259
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
vtkImageReader2
Superclass of binary file readers.
Definition: vtkImageReader2.h:52
vtkNIFTIImageReader::TimeAsVector
bool TimeAsVector
Read the time dimension as if it was a vector dimension.
Definition: vtkNIFTIImageReader.h:218
nifti_1_header
Data structure defining the fields in the nifti1 header. This binary header should be found at the be...
Definition: vtkNIFTIImagePrivate.h:35
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:80
vtkNIFTIImageReader::RescaleIntercept
double RescaleIntercept
Information for rescaling data to quantitative units.
Definition: vtkNIFTIImageReader.h:224
vtkNIFTIImageReader::GetRescaleIntercept
double GetRescaleIntercept()
Definition: vtkNIFTIImageReader.h:107
vtkNIFTIImageReader::SFormMatrix
vtkMatrix4x4 * SFormMatrix
Definition: vtkNIFTIImageReader.h:238
vtkNIFTIImageReader::GetQFac
double GetQFac()
QFac gives the slice order in the NIFTI file versus the VTK image.
Definition: vtkNIFTIImageReader.h:132
vtkImageReader2::CanReadFile
virtual int CanReadFile(const char *vtkNotUsed(fname))
Return non zero if the reader can read the given file name.
Definition: vtkImageReader2.h:279
vtkImageReader2.h
vtkNIFTIImageReader::GetFileExtensions
const char * GetFileExtensions() override
Valid extensions for this file type.
Definition: vtkNIFTIImageReader.h:66