vtk-dicom  0.8.14
vtkNIFTIReader.h
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkNIFTIReader.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 vtkNIFTIReader_h
36 #define vtkNIFTIReader_h
37 
38 #include "vtkImageReader2.h"
39 #include "vtkDICOMModule.h" // For export macro
40 #include "vtkDICOMConfig.h" // For configuration details
41 
42 // Declare VTK classes within VTK's optional namespace
43 #if defined(VTK_ABI_NAMESPACE_BEGIN)
44 VTK_ABI_NAMESPACE_BEGIN
45 #endif
46 
47 class vtkMatrix4x4;
48 
49 #if defined(VTK_ABI_NAMESPACE_BEGIN)
50 VTK_ABI_NAMESPACE_END
51 #endif
52 
53 class vtkNIFTIHeader;
54 
55 struct nifti_1_header;
56 
57 //----------------------------------------------------------------------------
58 class VTKDICOM_EXPORT vtkNIFTIReader : public vtkImageReader2
59 {
60 public:
62  static vtkNIFTIReader *New();
64 
66  void PrintSelf(ostream& os, vtkIndent indent) VTK_DICOM_OVERRIDE;
67 
69  const char* GetFileExtensions() VTK_DICOM_OVERRIDE {
71  return ".nii .nii.gz .img .img.gz .hdr .hdr.gz"; }
72 
74  const char* GetDescriptiveName() VTK_DICOM_OVERRIDE {
75  return "NIfTI"; }
76 
78  int CanReadFile(const char* filename) VTK_DICOM_OVERRIDE;
80 
82 
89  vtkGetMacro(TimeAsVector, int);
90  vtkSetMacro(TimeAsVector, int);
91  vtkBooleanMacro(TimeAsVector, int);
93 
95  int GetTimeDimension() { return this->Dim[4]; }
97  double GetTimeSpacing() { return this->PixDim[4]; }
99 
101 
108  double GetRescaleSlope() { return this->RescaleSlope; }
109  double GetRescaleIntercept() { return this->RescaleIntercept; }
111 
113 
120  vtkGetMacro(PlanarRGB, bool);
121  vtkSetMacro(PlanarRGB, bool);
122  vtkBooleanMacro(PlanarRGB, bool);
124 
126 
136  double GetQFac() { return this->QFac; }
138 
140 
152  vtkMatrix4x4 *GetQFormMatrix() { return this->QFormMatrix; }
153 
155 
168  vtkMatrix4x4 *GetSFormMatrix() { return this->SFormMatrix; }
170 
172  vtkNIFTIHeader *GetNIFTIHeader();
175 
176 protected:
177  vtkNIFTIReader();
178  ~vtkNIFTIReader() VTK_DICOM_OVERRIDE;
179 
181  int RequestInformation(
182  vtkInformation* request, vtkInformationVector** inputVector,
183  vtkInformationVector* outputVector) VTK_DICOM_OVERRIDE;
184 
186  int RequestData(
187  vtkInformation* request, vtkInformationVector** inputVector,
188  vtkInformationVector* outputVector) VTK_DICOM_OVERRIDE;
189 
191 
195  static bool CheckExtension(const char *fname, const char *ext);
196 
198 
205  static char *ReplaceExtension(
206  const char *fname, const char *ext1, const char *ext2);
207 
209  static int CheckNIFTIVersion(const nifti_1_header *hdr);
210 
212  static bool CheckAnalyzeHeader(const nifti_1_header *hdr);
213 
215  int TimeAsVector;
216 
218  double RescaleIntercept;
219  double RescaleSlope;
220 
222  double QFac;
223 
225  vtkMatrix4x4 *QFormMatrix;
226  vtkMatrix4x4 *SFormMatrix;
227 
229  int Dim[8];
230 
232  double PixDim[8];
233 
235  vtkNIFTIHeader *NIFTIHeader;
236 
238  bool PlanarRGB;
239 
240 private:
241 #ifdef VTK_DICOM_DELETE
242  vtkNIFTIReader(const vtkNIFTIReader&) VTK_DICOM_DELETE;
243  void operator=(const vtkNIFTIReader&) VTK_DICOM_DELETE;
244 #else
245  vtkNIFTIReader(const vtkNIFTIReader&) = delete;
246  void operator=(const vtkNIFTIReader&) = delete;
247 #endif
248 };
249 
250 #endif // vtkNIFTIReader_h
Superclass of binary file readers.
Definition: vtkImageReader2.h:53
virtual const char * GetFileExtensions()
Definition: vtkImageReader2.h:289
Store NIfTI header information.
Definition: vtkNIFTIHeader.h:48
Read NIfTI-1 and NIfTI-2 medical image files.
Definition: vtkNIFTIReader.h:59
void PrintSelf(ostream &os, vtkIndent indent) VTK_DICOM_OVERRIDE
Print information about this object.
static vtkNIFTIReader * New()
Static method for construction.
double GetRescaleSlope()
Get the slope and intercept for rescaling the scalar values.
Definition: vtkNIFTIReader.h:108
const char * GetDescriptiveName() VTK_DICOM_OVERRIDE
Return a descriptive name that might be useful in a GUI.
Definition: vtkNIFTIReader.h:74
double GetQFac()
QFac gives the slice order in the NIFTI file versus the VTK image.
Definition: vtkNIFTIReader.h:136
vtkMatrix4x4 * GetQFormMatrix()
Get a matrix that gives the "qform" orientation and offset for the data.
Definition: vtkNIFTIReader.h:152
int CanReadFile(const char *filename) VTK_DICOM_OVERRIDE
Return true if this reader can read the given file.
vtkMatrix4x4 * GetSFormMatrix()
Get a matrix that gives the "sform" orientation and offset for the data.
Definition: vtkNIFTIReader.h:168