SIVIC API  0.9.26
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
svkFdfVolumeReader.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2009-2014 The Regents of the University of California.
3  * All Rights Reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * • Redistributions of source code must retain the above copyright notice,
8  * this list of conditions and the following disclaimer.
9  * • Redistributions in binary form must reproduce the above copyright notice,
10  * this list of conditions and the following disclaimer in the documentation
11  * and/or other materials provided with the distribution.
12  * • None of the names of any campus of the University of California, the name
13  * "The Regents of the University of California," or the names of any of its
14  * contributors may be used to endorse or promote products derived from this
15  * software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
26  * OF SUCH DAMAGE.
27  */
28 
29 
30 
31 /*
32  * $URL$
33  * $Rev$
34  * $Author$
35  * $Date$
36  *
37  * Authors:
38  * Jason C. Crane, Ph.D.
39  * Beck Olson
40  */
41 
42 
43 #ifndef SVK_FDF_VOLUME_READER_H
44 #define SVK_FDF_VOLUME_READER_H
45 
46 #include <vtkInformation.h>
47 #include <vtkFloatArray.h>
48 #include <vtkStringArray.h>
49 
50 #include <svkVarianReader.h>
51 
52 #include <map>
53 #include <string>
54 #include <vector>
55 
56 
57 namespace svk {
58 
59 
72 {
73 
74  public:
75 
76  static svkFdfVolumeReader* New();
78 
79  // Description:
80  // A descriptive name for this format
81  virtual const char* GetDescriptiveName() {
82  return "Varian FDF File";
83  }
84 
86  {
88  }
89 
90  // Methods:
91  virtual int CanReadFile(const char* fname);
92 
93 
94  protected:
95 
98 
99  virtual int FillOutputPortInformation(int port, vtkInformation* info);
100  virtual void ExecuteInformation();
101  virtual void ExecuteDataWithInformation(vtkDataObject *output, vtkInformation* outInfo);
103  void ScaleTo16Bit( bool scaleTo16Bit, bool scaleToSignedShort, bool scaleToPositiveRange );
104 
105 
106  private:
107 
108  // Methods:
109  virtual void InitDcmHeader();
110  void InitPatientModule();
111  void InitGeneralStudyModule();
112  void InitGeneralSeriesModule();
113  void InitGeneralEquipmentModule();
114  void InitImagePixelModule();
115  void InitMultiFrameFunctionalGroupsModule();
116  void InitMultiFrameDimensionModule();
117  void InitAcquisitionContextModule();
118  void InitSharedFunctionalGroupMacros();
119  void InitPerFrameFunctionalGroupMacros();
120  //void InitFrameContentMacro();
121  //void InitPlanePositionMacro();
122  void InitPixelMeasuresMacro();
123  void InitPlaneOrientationMacro();
124  void InitMRReceiveCoilMacro();
125  void ReadFdfFiles();
126  string VarianToDicomDate(string* volumeDate);
127  string GetDcmPatientPositionString();
128  void GetTLCAndSliceSpacing(double* toplc, double* sliceSpacing);
129  void GetPixelSize( double* pixelSize);
130  void ParseFdf();
131  int GetFdfKeyValuePair( vtkStringArray* keySet = NULL);
132  void SetKeysToSearch(vtkStringArray* fltArray, int fileIndex);
133  int GetDataBufferSize();
134  int GetHeaderValueAsInt(string keyString, int valueIndex = 0);
135  float GetHeaderValueAsFloat(string keyString, int valueIndex = 0);
136  string GetHeaderValueAsString(string keyString, int valueIndex = 0);
137  bool IsKeyInHeader(string keyString);
138  void ParseAndSetStringElements(string key, string valueArrayString);
139  void ConvertCmToMm();
140  void ConvertUserToMagnetFrame();
141  string GetStringFromFloat(float floatValue);
142  void AddDimensionTo2DData();
143  void PrintKeyValuePairs();
144  void MapFloatValuesTo16Bit(
145  vtkFloatArray* fltArray,
146  vtkDataArray* dataArray
147  );
148 
149  // Members:
150  void* pixelData;
151  ifstream* fdfFile;
152  map <string, vector<string> >
153  fdfMap;
154  long fileSize;
155  vtkStringArray* tmpFileNames;
156  bool scaleTo16Bit;
157  bool scaleToSignedShort;
158  bool scaleToPositiveRange;
159 
160 
161 };
162 
163 
164 } //svk
165 
166 
167 #endif //SVK_FDF_VOLUME_READER_H
168 
vtkTypeMacro(svkFdfVolumeReader, svkVarianReader)
svkFdfVolumeReader()
Definition: svkFdfVolumeReader.cc:64
Definition: svkFdfVolumeReader.h:71
svkDcmHeader::DcmPixelDataFormat GetFileType()
Definition: svkFdfVolumeReader.cc:381
Definition: svkImageReader2.h:76
ReaderType
Definition: svkImageReader2.h:67
virtual int FillOutputPortInformation(int port, vtkInformation *info)
Definition: svkFdfVolumeReader.cc:1373
Definition: svkVarianReader.h:58
static svkFdfVolumeReader * New()
DcmPixelDataFormat
Definition: svkDcmHeader.h:92
virtual svkImageReader2::ReaderType GetReaderType()
Definition: svkFdfVolumeReader.h:85
void ScaleTo16Bit(bool scaleTo16Bit, bool scaleToSignedShort, bool scaleToPositiveRange)
Definition: svkFdfVolumeReader.cc:115
virtual void ExecuteDataWithInformation(vtkDataObject *output, vtkInformation *outInfo)
Definition: svkFdfVolumeReader.cc:218
virtual void ExecuteInformation()
Definition: svkFdfVolumeReader.cc:307
virtual const char * GetDescriptiveName()
Definition: svkFdfVolumeReader.h:81
vtkDataArray * dataArray
Definition: svkImageReader2.h:154
~svkFdfVolumeReader()
Definition: svkFdfVolumeReader.cc:90
virtual int CanReadFile(const char *fname)
Definition: svkFdfVolumeReader.cc:132