vtkDICOMImageReader.h 5.13 KB
Newer Older
Matt Turek's avatar
Matt Turek committed
1 2 3 4 5
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkDICOMImageReader.h

6
  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
Matt Turek's avatar
Matt Turek committed
7 8 9
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

10 11
     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
Matt Turek's avatar
Matt Turek committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
// .NAME vtkDICOMImageReader - Reads DICOM images
// .SECTION Description
// .SECTION See Also
// vtkBMPReader vtkPNMReader vtkTIFFReader

#ifndef __vtkDICOMImageReader_h
#define __vtkDICOMImageReader_h

#include "vtkImageReader2.h"

//BTX
26
class vtkDICOMImageReaderVector;
Matt Turek's avatar
Matt Turek committed
27 28
class DICOMParser;
class DICOMAppHelper;
Matt Turek's avatar
Matt Turek committed
29 30 31 32 33
//ETX

class VTK_IO_EXPORT vtkDICOMImageReader : public vtkImageReader2
{
 public:
Matt Turek's avatar
Matt Turek committed
34 35
  // Description:
  // Static method for construction.
Matt Turek's avatar
Matt Turek committed
36 37
  static vtkDICOMImageReader *New();
  vtkTypeRevisionMacro(vtkDICOMImageReader,vtkImageReader2);
Matt Turek's avatar
Matt Turek committed
38 39 40

  // Description:
  // Prints the ivars.
41 42
  void PrintSelf(ostream& os, vtkIndent indent);

Matt Turek's avatar
Matt Turek committed
43 44 45
  // Description:
  // Set the filename for the file to read. If this method is used,
  // the reader will only read a single file.
Matt Turek's avatar
Matt Turek committed
46
  void SetFileName(const char* fn)
47
  {
48 49 50 51
    if (this->DirectoryName)
      {
      delete [] this->DirectoryName;
      }
Matt Turek's avatar
Matt Turek committed
52 53 54 55
    if (this->FileName)
      {
      delete [] this->FileName;
      }
Matt Turek's avatar
Matt Turek committed
56
    this->DirectoryName = NULL;
Matt Turek's avatar
Matt Turek committed
57
    this->FileName = NULL;
Matt Turek's avatar
Matt Turek committed
58
    this->vtkImageReader2::SetFileName(fn);
59
  }
Matt Turek's avatar
Matt Turek committed
60 61 62

  // Description:
  // Set the directory name for the reader to look in for DICOM
63 64
  // files. If this method is used, the reader will try to find
  // all the DICOM files in a directory. It will select the subset
Matt Turek's avatar
Matt Turek committed
65 66 67 68 69
  // corresponding to the first series UID it stumbles across and
  // it will try to build an ordered volume from them based on
  // the slice number. The volume building will be upgraded to
  // something more sophisticated in the future.
  void SetDirectoryName(const char* dn);
70

Matt Turek's avatar
Matt Turek committed
71 72 73
  // Description:
  // Returns the directory name.
  vtkGetStringMacro(DirectoryName);
Matt Turek's avatar
Matt Turek committed
74

75 76
  // Description:
  // Returns the pixel spacing.
Ken Martin's avatar
Ken Martin committed
77
  double* GetPixelSpacing();
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
  // Description:
  // Returns the image width.
  int GetWidth();

  // Description:
  // Returns the image height.
  int GetHeight();

  // Description:
  // Get the (DICOM) x,y,z coordinates of the first pixel in the
  // image (upper left hand corner) of the last image processed by the
  // DICOMParser
  float* GetImagePositionPatient();

  // Description:
  // Get the number of bits allocated for each pixel in the file.
  int GetBitsAllocated();

  // Description:
  // Get the pixel representation of the last image processed by the
  // DICOMParser. A zero is a unsigned quantity.  A one indicates a
  // signed quantity
  int GetPixelRepresentation();

  // Description:
  // Get the number of components of the image data for the last
  // image processed.
  int GetNumberOfComponents();

  // Description:
  // Get the transfer syntax UID for the last image processed.
  const char* GetTransferSyntaxUID();

112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
  // Description:
  // Get the rescale slope for the pixel data.
  float GetRescaleSlope();

  // Description:
  // Get the rescale offset for the pixel data.
  float GetRescaleOffset();

  // Description:
  // Get the patient name for the last image processed.
  const char* GetPatientName();

  // Description:
  // Get the study uid for the last image processed.
  const char* GetStudyUID();

128 129 130
  // Description:
  // Get the Study ID for the last image processed.
  const char* GetStudyID();
131

132 133 134 135
  // Description:
  // Get the gantry angle for the last image processed.
  float GetGantryAngle();

Matt Turek's avatar
Matt Turek committed
136
  //
137
  // Can I read the file?
Matt Turek's avatar
Matt Turek committed
138
  //
139
  virtual int CanReadFile(const char* fname);
Matt Turek's avatar
Matt Turek committed
140

141
protected:
Matt Turek's avatar
Matt Turek committed
142
  //
143
  // Setup the volume size
144
  //
145
  void SetupOutputInformation(int num_slices);
Matt Turek's avatar
Matt Turek committed
146

Matt Turek's avatar
Matt Turek committed
147 148
  //
  // What file extensions are supported?
149
  //
150
  virtual const char* GetFileExtensions()
151
  {
Matt Turek's avatar
Matt Turek committed
152
    return ".dcm";
153
  }
Matt Turek's avatar
Matt Turek committed
154

155
  // Description:
Matt Turek's avatar
Matt Turek committed
156 157
  // Return a descriptive name for the file format that might be useful in a GUI.
  virtual const char* GetDescriptiveName()
158
  {
Matt Turek's avatar
Matt Turek committed
159
    return "DICOM";
160
  }
161

Matt Turek's avatar
Matt Turek committed
162 163 164
  virtual void ExecuteInformation();
  virtual void ExecuteData(vtkDataObject *out);

Matt Turek's avatar
Matt Turek committed
165
  //
166
  // Constructor
Matt Turek's avatar
Matt Turek committed
167
  //
Matt Turek's avatar
Matt Turek committed
168 169
  vtkDICOMImageReader();

Matt Turek's avatar
Matt Turek committed
170 171
  //
  // Destructor
172
  //
Matt Turek's avatar
Matt Turek committed
173 174 175 176 177
  virtual ~vtkDICOMImageReader();

  //
  // Instance of the parser used to parse the file.
  //
Matt Turek's avatar
Matt Turek committed
178
  DICOMParser* Parser;
Matt Turek's avatar
Matt Turek committed
179 180 181 182

  //
  // Instance of the callbacks that get the data from the file.
  //
Matt Turek's avatar
Matt Turek committed
183
  DICOMAppHelper* AppHelper;
184

Matt Turek's avatar
Matt Turek committed
185
  //
186
  // vtkDICOMImageReaderVector wants to be a PIMPL and it will be, but not quite yet.
Matt Turek's avatar
Matt Turek committed
187
  //
188
  vtkDICOMImageReaderVector* DICOMFileNames;
Matt Turek's avatar
Matt Turek committed
189 190
  char* DirectoryName;

191 192 193 194
  char* PatientName;
  char* StudyUID;
  char* StudyID;
  char* TransferSyntaxUID;
195

196
  // DICOMFileNames accessor methods for subclasses:
197 198
  int GetNumberOfDICOMFileNames();
  const char* GetDICOMFileName(int index);
Matt Turek's avatar
Matt Turek committed
199 200 201 202
private:
  vtkDICOMImageReader(const vtkDICOMImageReader&);  // Not implemented.
  void operator=(const vtkDICOMImageReader&);  // Not implemented.

Matt Turek's avatar
Matt Turek committed
203 204 205
};

#endif