vtk-dicom  0.8.14
vtkScancoCTReader.h
1 /*=========================================================================
2 
3  Program: DICOM for VTK
4 
5  Copyright (c) 2015 David Gobbi
6  All rights reserved.
7  See Copyright.txt or http://dgobbi.github.io/bsd3.txt for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
34 #ifndef vtkScancoCTReader_h
35 #define vtkScancoCTReader_h
36 
37 #include "vtkImageReader2.h"
38 #include "vtkDICOMModule.h" // For export macro
39 #include "vtkDICOMConfig.h" // For configuration details
40 
41 #include <iosfwd> // for std::istream
42 
43 //----------------------------------------------------------------------------
44 class VTKDICOM_EXPORT vtkScancoCTReader : public vtkImageReader2
45 {
46 public:
50 
52  void PrintSelf(ostream& os, vtkIndent indent) VTK_DICOM_OVERRIDE;
53 
55  const char* GetFileExtensions() VTK_DICOM_OVERRIDE {
57  return ".isq .rsq .rad .aim" ; }
58 
60  const char* GetDescriptiveName() VTK_DICOM_OVERRIDE {
61  return "SCANCO MicroCT"; }
63 
65  int CanReadFile(const char* filename) VTK_DICOM_OVERRIDE;
68 
70  const char *GetVersion() { return this->Version; }
72 
74  int GetPatientIndex() { return this->PatientIndex; }
75 
77  int GetScannerID() { return this->ScannerID; }
78 
80  const char *GetCreationDate() { return this->CreationDate; }
81 
83  const char *GetModificationDate() { return this->ModificationDate; }
84 
86  double GetSliceThickness() { return this->SliceThickness; }
87 
89  double GetSliceIncrement() { return this->SliceIncrement; }
90 
92  double GetStartPosition() { return this->StartPosition; }
93 
95  double GetEndPosition() { return this->EndPosition; }
96 
98  double GetZPosition() { return this->ZPosition; }
99 
101  vtkGetVector2Macro(DataRange, double);
102 
104  double GetMuScaling() { return this->MuScaling; }
105 
107  int GetNumberOfSamples() { return this->NumberOfSamples; }
108 
110  int GetNumberOfProjections() { return this->NumberOfProjections; }
111 
113  double GetScanDistance() { return this->ScanDistance; }
114 
116  int GetScannerType() { return this->ScannerType; }
117 
119  double GetSampleTime() { return this->SampleTime; }
120 
122  int GetMeasurementIndex() { return this->MeasurementIndex; }
123 
125  int GetSite() { return this->Site; }
126 
128  double GetReferenceLine() { return this->ReferenceLine; }
129 
131  int GetReconstructionAlg() { return this->ReconstructionAlg; }
132 
134  const char *GetPatientName() { return this->PatientName; }
135 
137  double GetEnergy() { return this->Energy; }
138 
140  double GetIntensity() { return this->Intensity; }
141 
143 
147  double GetRescaleSlope() { return this->RescaleSlope; }
148  double GetRescaleIntercept() { return this->RescaleIntercept; }
149 
151  int GetRescaleType() { return this->RescaleType; }
152 
154  const char *GetRescaleUnits() { return this->RescaleUnits; }
155 
157  double GetMuWater() { return this->MuWater; }
158 
160  const char *GetCalibrationData() { return this->CalibrationData; }
161 
163  vtkGetVector3Macro(ScanDimensionsPixels, int);
164 
166  vtkGetVector3Macro(ScanDimensionsPhysical, double);
167 
169  void *GetRawHeader() { return this->RawHeader; }
171 
172 protected:
174  ~vtkScancoCTReader() VTK_DICOM_OVERRIDE;
175 
177  int RequestInformation(
178  vtkInformation* request, vtkInformationVector** inputVector,
179  vtkInformationVector* outputVector) VTK_DICOM_OVERRIDE;
180 
182  int RequestData(
183  vtkInformation* request, vtkInformationVector** inputVector,
184  vtkInformationVector* outputVector) VTK_DICOM_OVERRIDE;
185 
187  void InitializeHeader();
188 
190  int ReadISQHeader(std::istream *file, unsigned long bytesRead);
191 
193  int ReadAIMHeader(std::istream *file, unsigned long bytesRead);
194 
196 
200  static int CheckVersion(const char header[16]);
201 
203  void DecodeDate(const void *data,
204  int& year, int& month, int& day,
205  int& hour, int& minute, int& second, int& millis);
206 
208  static int DecodeInt(const void *data);
209 
211  static float DecodeFloat(const void *data);
212 
214  static double StringToDouble(const char *cp, char **cpp=0);
215 
217  static int StringToInt(const char *cp, char **cpp=0);
218 
220  static double DecodeDouble(const void *data);
221 
223 
226  static void StripString(char *dest, const char *source, size_t l);
227 
228  // Header information
229  char Version[18];
230  char PatientName[42];
231  int PatientIndex;
232  int ScannerID;
233  char CreationDate[32];
234  char ModificationDate[32];
235  int ScanDimensionsPixels[3];
236  double ScanDimensionsPhysical[3];
237  double SliceThickness;
238  double SliceIncrement;
239  double StartPosition;
240  double EndPosition;
241  double ZPosition;
242  double DataRange[2];
243  double MuScaling;
244  int NumberOfSamples;
245  int NumberOfProjections;
246  double ScanDistance;
247  double SampleTime;
248  int ScannerType;
249  int MeasurementIndex;
250  int Site;
251  int ReconstructionAlg;
252  double ReferenceLine;
253  double Energy;
254  double Intensity;
255  int RescaleType;
256  char RescaleUnits[18];
257  char CalibrationData[66];
258  double RescaleSlope;
259  double RescaleIntercept;
260  double MuWater;
261  char *RawHeader;
262 
263  // The compression mode, if any.
264  int Compression;
265 
266 private:
267 #ifdef VTK_DICOM_DELETE
268  vtkScancoCTReader(const vtkScancoCTReader&) VTK_DICOM_DELETE;
269  void operator=(const vtkScancoCTReader&) VTK_DICOM_DELETE;
270 #else
271  vtkScancoCTReader(const vtkScancoCTReader&) = delete;
272  void operator=(const vtkScancoCTReader&) = delete;
273 #endif
274 };
275 
276 #endif // vtkScancoCTReader_h
Superclass of binary file readers.
Definition: vtkImageReader2.h:53
virtual int CanReadFile(const char *vtkNotUsed(fname))
Definition: vtkImageReader2.h:279
virtual const char * GetFileExtensions()
Definition: vtkImageReader2.h:289
Read SCANCO ISQ and AIM medical image files.
Definition: vtkScancoCTReader.h:45
int GetRescaleType()
Get the rescale type as an integer code.
Definition: vtkScancoCTReader.h:151
int GetScannerID()
Get the scanner ID from the header.
Definition: vtkScancoCTReader.h:77
double GetReferenceLine()
Get the reference line (in millimeters).
Definition: vtkScancoCTReader.h:128
double GetSliceIncrement()
Get the slice increment in millimeters.
Definition: vtkScancoCTReader.h:89
int GetScannerType()
Get the scanner type, as an integer code.
Definition: vtkScancoCTReader.h:116
int GetReconstructionAlg()
Get an integer value that identifies the reconstruction algorithm.
Definition: vtkScancoCTReader.h:131
const char * GetDescriptiveName() VTK_DICOM_OVERRIDE
Return a descriptive name that might be useful in a GUI.
Definition: vtkScancoCTReader.h:60
double GetScanDistance()
Get the scan distance (in millimeters).
Definition: vtkScancoCTReader.h:113
int GetSite()
Get an integer value that identifies the site on the body.
Definition: vtkScancoCTReader.h:125
int GetPatientIndex()
Get the patient index from the header.
Definition: vtkScancoCTReader.h:74
double GetSampleTime()
Get the sample time (in milliseconds).
Definition: vtkScancoCTReader.h:119
const char * GetPatientName()
Get a descriptive name for this scan.
Definition: vtkScancoCTReader.h:134
int GetNumberOfProjections()
Get the number of projections.
Definition: vtkScancoCTReader.h:110
double GetSliceThickness()
Get the slice thickness in millimeters.
Definition: vtkScancoCTReader.h:86
double GetZPosition()
Get the location of the edge of a locator scan.
Definition: vtkScancoCTReader.h:98
static vtkScancoCTReader * New()
Static method for construction.
double GetEndPosition()
Get the position of the final slice in millimeters.
Definition: vtkScancoCTReader.h:95
const char * GetCalibrationData()
Get the calibration data (energy, filtration, etc.)
Definition: vtkScancoCTReader.h:160
void * GetRawHeader()
Get the raw header information (512 bytes) from the file.
Definition: vtkScancoCTReader.h:169
void PrintSelf(ostream &os, vtkIndent indent) VTK_DICOM_OVERRIDE
Print information about this object.
double GetIntensity()
Get the X-ray intensity (in mA).
Definition: vtkScancoCTReader.h:140
int GetMeasurementIndex()
Get the index measurement.
Definition: vtkScancoCTReader.h:122
double GetRescaleSlope()
Get the slope and intercept for rescaling the scalar values.
Definition: vtkScancoCTReader.h:147
double GetMuScaling()
Get the scaling factor from linear attenuation [1/cm] to data values.
Definition: vtkScancoCTReader.h:104
double GetMuWater()
Get the linear attenuation of water, in units of [1/cm].
Definition: vtkScancoCTReader.h:157
const char * GetCreationDate()
Get the creation date as a string.
Definition: vtkScancoCTReader.h:80
const char * GetModificationDate()
Get the date when the data was last modified.
Definition: vtkScancoCTReader.h:83
double GetEnergy()
Get the X-ray energy (in kVp).
Definition: vtkScancoCTReader.h:137
int GetNumberOfSamples()
Get the number of samples.
Definition: vtkScancoCTReader.h:107
const char * GetRescaleUnits()
Get the units of the data after rescaling with slope and intercept.
Definition: vtkScancoCTReader.h:154
double GetStartPosition()
Get the position of the first slice in millimeters.
Definition: vtkScancoCTReader.h:92