VTK  9.5.20251113
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
33VTK_ABI_NAMESPACE_BEGIN
35class vtkMatrix4x4;
36VTK_ABI_NAMESPACE_END
37
38struct nifti_1_header;
39
40VTK_ABI_NAMESPACE_BEGIN
41
42//----------------------------------------------------------------------------
43class VTKIOIMAGE_EXPORT vtkNIFTIImageReader : public vtkImageReader2
44{
45public:
47
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
72 int CanReadFile(VTK_FILEPATH const char* filename) override;
73
75
82 vtkGetMacro(TimeAsVector, bool);
83 vtkSetMacro(TimeAsVector, bool);
84 vtkBooleanMacro(TimeAsVector, bool);
86
90 int GetTimeDimension() { return this->Dim[4]; }
91 double GetTimeSpacing() { return this->PixDim[4]; }
92
100 double GetRescaleSlope() { return this->RescaleSlope; }
101 double GetRescaleIntercept() { return this->RescaleIntercept; }
102
104
111 vtkGetMacro(PlanarRGB, bool);
112 vtkSetMacro(PlanarRGB, bool);
113 vtkBooleanMacro(PlanarRGB, bool);
115
126 double GetQFac() { return this->QFac; }
127
140 vtkMatrix4x4* GetQFormMatrix() { return this->QFormMatrix; }
141
156 vtkMatrix4x4* GetSFormMatrix() { return this->SFormMatrix; }
157
162
163protected:
166
171 vtkInformationVector* outputVector) override;
172
177 vtkInformationVector* outputVector) override;
178
184 static bool CheckExtension(const char* filename, const char* ext);
185
194 static char* ReplaceExtension(const char* filename, const char* ext1, const char* ext2);
195
199 static int CheckNIFTIVersion(const nifti_1_header* hdr);
200
204 static bool CheckAnalyzeHeader(const nifti_1_header* hdr);
205
210
212
218
222 double QFac;
223
225
231
235 int Dim[8];
236
240 double PixDim[8];
241
246
251
252private:
254 void operator=(const vtkNIFTIImageReader&) = delete;
255};
256
257VTK_ABI_NAMESPACE_END
258#endif // vtkNIFTIImageReader_h
Superclass of binary file readers.
a simple class to control print indentation
Definition vtkIndent.h:108
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
represent and manipulate 4x4 transformation matrices
Store NIfTI header information.
Read NIfTI-1 and NIfTI-2 medical image files.
vtkMatrix4x4 * GetSFormMatrix()
Get a matrix that gives the "sform" orientation and offset for the data.
const char * GetDescriptiveName() override
Return a descriptive name that might be useful in a GUI.
double GetQFac()
QFac gives the slice order in the NIFTI file versus the VTK image.
vtkMatrix4x4 * GetQFormMatrix()
Get a matrix that gives the "qform" orientation and offset for the data.
static int CheckNIFTIVersion(const nifti_1_header *hdr)
Check the version of the header.
double QFac
Is -1 if VTK slice order is opposite to NIFTI slice order, +1 otherwise.
static vtkNIFTIImageReader * New()
Static method for construction.
double GetRescaleSlope()
Get the slope and intercept for rescaling the scalar values.
void PrintSelf(ostream &os, vtkIndent indent) override
Print information about this object.
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Read the voxel data.
bool PlanarRGB
Use planar RGB instead of the default (packed).
int CanReadFile(const char *filename) override
Return true if this reader can read the given file.
static char * ReplaceExtension(const char *filename, const char *ext1, const char *ext2)
Make a new filename by replacing extension "ext1" with "ext2".
static bool CheckExtension(const char *filename, const char *ext)
Do a case-insensitive check for the given extension.
int RequestInformation(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Read the header information.
double RescaleIntercept
Information for rescaling data to quantitative units.
vtkMatrix4x4 * QFormMatrix
The orientation matrices for the NIFTI file.
static bool CheckAnalyzeHeader(const nifti_1_header *hdr)
Return true if an Analyze 7.5 header was found.
vtkNIFTIImageHeader * GetNIFTIHeader()
Get the raw header information from the NIfTI file.
~vtkNIFTIImageReader() override
vtkMatrix4x4 * SFormMatrix
The orientation matrices for the NIFTI file.
double RescaleSlope
Information for rescaling data to quantitative units.
bool TimeAsVector
Read the time dimension as if it was a vector dimension.
int GetTimeDimension()
Get the time dimension that was stored in the NIFTI header.
const char * GetFileExtensions() override
Valid extensions for this file type.
vtkNIFTIImageHeader * NIFTIHeader
A copy of the header from the file that was most recently read.
Data structure defining the fields in the nifti1 header. This binary header should be found at the be...
#define VTK_FILEPATH