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) override;
65 
69  const char* GetFileExtensions() override {
70  return ".nii .nii.gz .img .img.gz .hdr .hdr.gz"; }
71 
75  const char* GetDescriptiveName() override {
76  return "NIfTI"; }
77 
81  int CanReadFile(const char* filename) override;
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:
174  ~vtkNIFTIImageReader() override;
175 
179  int RequestInformation(
180  vtkInformation* request, vtkInformationVector** inputVector,
181  vtkInformationVector* outputVector) override;
182 
186  int RequestData(
187  vtkInformation* request, vtkInformationVector** inputVector,
188  vtkInformationVector* outputVector) override;
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&) = delete;
266  void operator=(const vtkNIFTIImageReader&) = delete;
267 };
268 
269 #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:75
vtkNIFTIImageReader::GetTimeDimension
int GetTimeDimension()
Get the time dimension that was stored in the NIFTI header.
Definition: vtkNIFTIImageReader.h:99
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:41
vtkNIFTIImageReader::GetSFormMatrix
vtkMatrix4x4 * GetSFormMatrix()
Get a matrix that gives the "sform" orientation and offset for the data.
Definition: vtkNIFTIImageReader.h:165
vtkNIFTIImageReader::RescaleSlope
double RescaleSlope
Definition: vtkNIFTIImageReader.h:228
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:240
vtkNIFTIImageReader::NIFTIHeader
vtkNIFTIImageHeader * NIFTIHeader
A copy of the header from the file that was most recently read.
Definition: vtkNIFTIImageReader.h:257
vtkNIFTIImageReader::GetTimeSpacing
double GetTimeSpacing()
Definition: vtkNIFTIImageReader.h:100
vtkNIFTIImageHeader
Store NIfTI header information.
Definition: vtkNIFTIImageHeader.h:49
vtkNIFTIImageReader::GetQFormMatrix
vtkMatrix4x4 * GetQFormMatrix()
Get a matrix that gives the "qform" orientation and offset for the data.
Definition: vtkNIFTIImageReader.h:149
vtkNIFTIImageReader
Read NIfTI-1 and NIfTI-2 medical image files.
Definition: vtkNIFTIImageReader.h:50
vtkImageReader2::New
static vtkImageReader2 * New()
vtkNIFTIImageReader::GetRescaleSlope
double GetRescaleSlope()
Get the slope and intercept for rescaling the scalar values.
Definition: vtkNIFTIImageReader.h:109
vtkNIFTIImageReader::QFac
double QFac
Is -1 if VTK slice order is opposite to NIFTI slice order, +1 otherwise.
Definition: vtkNIFTIImageReader.h:234
vtkNIFTIImageReader::PlanarRGB
bool PlanarRGB
Use planar RGB instead of the default (packed).
Definition: vtkNIFTIImageReader.h:262
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
vtkImageReader2
Superclass of binary file readers.
Definition: vtkImageReader2.h:58
vtkNIFTIImageReader::TimeAsVector
bool TimeAsVector
Read the time dimension as if it was a vector dimension.
Definition: vtkNIFTIImageReader.h:221
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:86
vtkNIFTIImageReader::RescaleIntercept
double RescaleIntercept
Information for rescaling data to quantitative units.
Definition: vtkNIFTIImageReader.h:227
vtkNIFTIImageReader::GetRescaleIntercept
double GetRescaleIntercept()
Definition: vtkNIFTIImageReader.h:110
vtkNIFTIImageReader::SFormMatrix
vtkMatrix4x4 * SFormMatrix
Definition: vtkNIFTIImageReader.h:241
vtkNIFTIImageReader::GetQFac
double GetQFac()
QFac gives the slice order in the NIFTI file versus the VTK image.
Definition: vtkNIFTIImageReader.h:135
vtkImageReader2::CanReadFile
virtual int CanReadFile(const char *vtkNotUsed(fname))
Return non zero if the reader can read the given file name.
Definition: vtkImageReader2.h:285
vtkImageReader2.h
vtkNIFTIImageReader::GetFileExtensions
const char * GetFileExtensions() override
Valid extensions for this file type.
Definition: vtkNIFTIImageReader.h:69