/usr/include/vtkNIFTIReader.h is in libvtk-dicom-dev 0.7.4-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | /*=========================================================================
Program: Visualization Toolkit
Module: vtkNIFTIReader.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkNIFTIReader - Read NIfTI-1 and NIfTI-2 medical image files
// .SECTION Description
// This class reads NIFTI files, either in .nii format or as separate
// .img and .hdr files. If two files are used, then they can be passed
// by using SetFileNames() instead of SetFileName(). Files ending in .gz
// are decompressed on-the-fly while they are being read. Files with
// complex numbers or vector dimensions will be read as multi-component
// images. If a NIFTI file has a time dimension, then by default only the
// first image in the time series will be read, but the TimeAsVector
// flag can be set to read the time steps as vector components. Files in
// Analyze 7.5 format are also supported by this reader.
// .SECTION Thanks
// This class was contributed to VTK by the Calgary Image Processing and
// Analysis Centre (CIPAC).
// .SECTION See Also
// vtkNIFTIWriter, vtkNIFTIHeader
#ifndef vtkNIFTIReader_h
#define vtkNIFTIReader_h
#include <vtkImageReader2.h>
#include "vtkDICOMModule.h" // For export macro
class vtkNIFTIHeader;
class vtkMatrix4x4;
struct nifti_1_header;
//----------------------------------------------------------------------------
class VTKDICOM_EXPORT vtkNIFTIReader : public vtkImageReader2
{
public:
// Description:
// Static method for construction.
static vtkNIFTIReader *New();
vtkTypeMacro(vtkNIFTIReader, vtkImageReader2);
// Description:
// Print information about this object.
virtual void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Valid extensions for this file type.
virtual const char* GetFileExtensions() {
return ".nii .nii.gz .img .img.gz .hdr .hdr.gz"; }
// Description:
// Return a descriptive name that might be useful in a GUI.
virtual const char* GetDescriptiveName() {
return "NIfTI"; }
// Description:
// Return true if this reader can read the given file.
int CanReadFile(const char* filename);
// Description:
// Read the time dimension as scalar components (default: Off).
// If this is on, then each time point will be stored as a component in
// the image data. If the file has both a time dimension and a vector
// dimension, then the number of components will be the product of these
// two dimensions, i.e. the components will store a sequence of vectors.
vtkGetMacro(TimeAsVector, int);
vtkSetMacro(TimeAsVector, int);
vtkBooleanMacro(TimeAsVector, int);
// Description:
// Get the time dimension that was stored in the NIFTI header.
int GetTimeDimension() { return this->Dim[4]; }
double GetTimeSpacing() { return this->PixDim[4]; }
// Description:
// Get the slope and intercept for rescaling the scalar values.
// These values allow calibration of the data to real values.
// Use the equation v = u*RescaleSlope + RescaleIntercept.
// This directly returns the values stored in the scl_slope and
// scl_inter fields in the NIFTI header.
double GetRescaleSlope() { return this->RescaleSlope; }
double GetRescaleIntercept() { return this->RescaleIntercept; }
// Description:
// Read planar RGB (separate R, G, and B planes), rather than packed RGB.
// The NIFTI format should always use packed RGB. The Analyze format,
// however, was used to store both planar RGB and packed RGB depending
// on the software, without any indication in the header about which
// convention was being used. Use this if you have a planar RGB file.
vtkGetMacro(PlanarRGB, bool);
vtkSetMacro(PlanarRGB, bool);
vtkBooleanMacro(PlanarRGB, bool);
// Description:
// QFac gives the slice order in the NIFTI file versus the VTK image.
// If QFac is -1, then the VTK slice index J is related to the NIFTI
// slice index j by the equation J = (num_slices - j - 1). VTK requires
// the slices to be ordered so that the voxel indices (I,J,K) provide a
// right-handed coordinate system, whereas NIFTI does not. Instead,
// NIFTI stores a factor called "qfac" in the header to signal when the
// (i,j,k) indices form a left-handed coordinate system. QFac will only
// ever have values of +1 or -1.
double GetQFac() { return this->QFac; }
// Description:
// Get a matrix that gives the "qform" orientation and offset for the data.
// If no qform matrix was stored in the file, the return value is NULL.
// This matrix will transform VTK data coordinates into the NIFTI oriented
// data coordinates, where +X points right, +Y points anterior (toward the
// front), and +Z points superior (toward the head). The qform matrix will
// always have a positive determinant. The offset that is stored in the
// matrix gives the position of the first pixel in the first slice of the
// VTK image data. Note that if QFac is -1, then the first slice in the
// VTK image data is the last slice in the NIFTI file, and the Z offset
// will automatically be adjusted to compensate for this.
vtkMatrix4x4 *GetQFormMatrix() { return this->QFormMatrix; }
// Description:
// Get a matrix that gives the "sform" orientation and offset for the data.
// If no sform matrix was stored in the file, the return value is NULL.
// Like the qform matrix, this matrix will transform VTK data coordinates
// into a NIFTI coordinate system. Unlike the qform matrix, the sform
// matrix can contain scaling information and can even (rarely) have
// a negative determinant, i.e. a flip. This matrix is modified slightly
// as compared to the sform matrix stored in the NIFTI header: the pixdim
// pixel spacing is factored out. Also, if QFac is -1, then the VTK slices
// are in reverse order as compared to the NIFTI slices, hence as compared
// to the sform matrix stored in the header, the third column of this matrix
// is multiplied by -1 and the Z offset is shifted to compensate for the
// fact that the last slice has become the first.
vtkMatrix4x4 *GetSFormMatrix() { return this->SFormMatrix; }
// Description:
// Get the raw header information from the NIfTI file.
vtkNIFTIHeader *GetNIFTIHeader();
protected:
vtkNIFTIReader();
~vtkNIFTIReader();
// Description:
// Read the header information.
virtual int RequestInformation(
vtkInformation* request, vtkInformationVector** inputVector,
vtkInformationVector* outputVector);
// Description:
// Read the voxel data.
virtual int RequestData(
vtkInformation* request, vtkInformationVector** inputVector,
vtkInformationVector* outputVector);
// Description:
// Doe a case-insensitive check for the given extension.
// The check will succeed if the filename ends in ".gz", and if the
// extension matches after removing the ".gz".
static bool CheckExtension(const char *fname, const char *ext);
// Description:
// Make a new filename by replacing extension "ext1" with "ext2".
// The extensions must include a period, must be three characters
// long, and must be lower case. This method also verifies that
// the file exists, and adds or subtracts a ".gz" as necessary
// If the file exists, a new string is returned that must be
// deleted by the caller. Otherwise, the return value is NULL.
static char *ReplaceExtension(
const char *fname, const char *ext1, const char *ext2);
// Description:
// Check the version of the header.
static int CheckNIFTIVersion(const nifti_1_header *hdr);
// Description:
// Check for Analyze 7.5 header.
static bool CheckAnalyzeHeader(const nifti_1_header *hdr);
// Description:
// Read the time dimension as if it was a vector dimension.
int TimeAsVector;
// Description:
// Information for rescaling data to quantitative units.
double RescaleIntercept;
double RescaleSlope;
// Description:
// Set to -1 when VTK slice order is opposite to NIFTI slice order.
double QFac;
// Description:
// The orientation matrices for the NIFTI file.
vtkMatrix4x4 *QFormMatrix;
vtkMatrix4x4 *SFormMatrix;
// Description:
// The dimensions of the NIFTI file.
int Dim[8];
// Description:
// The spacings in the NIFTI file.
double PixDim[8];
// Description:
// A copy of the header from the file that was most recently read.
vtkNIFTIHeader *NIFTIHeader;
// Description:
// Use planar RGB instead of the default (packed).
bool PlanarRGB;
private:
vtkNIFTIReader(const vtkNIFTIReader&); // Not implemented.
void operator=(const vtkNIFTIReader&); // Not implemented.
};
#endif // vtkNIFTIReader_h
|