SIVIC API  0.9.26
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
svkGEPFileReader.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2009 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 #ifndef SVK_GE_PFILE_READER_H
43 #define SVK_GE_PFILE_READER_H
44 
45 #include <vtkCallbackCommand.h>
46 #include <vtkInformation.h>
47 
48 #include <svkImageReader2.h>
49 #include <svkGEPFileMapper.h>
51 #include <svkGEPFileMapperUCSF.h>
57 #include <svkEPSIReorder.h>
58 
59 #include <map>
60 #include <vector>
61 #include <string>
62 
63 
64 namespace svk {
65 
66 
89 {
90 
91  public:
92 
94  static svkGEPFileReader* New();
95  virtual int CanReadFile( const char* fname );
98  void SetDeidentify( svkDcmHeader::PHIType phiType );
99  void SetDeidentify( svkDcmHeader::PHIType phiType, string deidentificationId );
100  void SetDeidentify( svkDcmHeader::PHIType phiType, string patientId,
101  string studyId );
102  void SetDeidentificationStudyUID( string deidStudyUID);
103  void SetDeidentificationSeriesUID( string deidSeriesUID);
104  void SetDeidentificationInstanceUID(string deidImageUID);
105  void SetDeidentificationLandmarkUID(string deidLandmarkUID);
106 
107  void SetTemperature( float temp );
108  void SetChop( bool chop );
109  void PrintHeader();
110  void PrintShortHeader();
111  void SetEPSIParams(
114  int first,
115  int numLobes,
116  int numSkip );
117  void Deidentify( );
118  void ModifyRawField( string rawField, string value);
119  void SetPSDLogic( string psdName );
120 
121  map <string, vector< string > >
122  GetPFMap();
123  static float LookupRawVersion(float rdbmRev, float rdbmRevSwapped);
124 
125 
126 
127  // Description:
128  // A descriptive name for this format
129  virtual const char* GetDescriptiveName() {
130  return "GE pfile";
131  }
132 
134  {
136  }
137 
139 
140 
141  protected:
142 
145 
146  virtual int FillOutputPortInformation(int port, vtkInformation* info);
147  virtual void ExecuteInformation();
148  virtual void ExecuteDataWithInformation( vtkDataObject *output, vtkInformation* outInfo );
150  void ReadGEPFile();
151  void ParsePFile();
152  void InitOffsetsMap();
153  virtual void SetProvenance();
154 
155  map <string, vector< string > >
157  virtual string GetFileSeriesDescription( string fileName );
158 
159 
160 
161  private:
162 
163  // Methods:
164  string GetOffsetsString();
165  virtual void InitDcmHeader();
166  void PrintOffsets();
167  void DumpHeader();
168  void DumpShortHeader();
169  void PrintKeyValuePairs();
170  string GetFieldAsString(string key);
171  int GEUncompressUID(unsigned char* short_uid, char* long_uid);
172  string UncompressUID(const char* compressedUID);
173  int GECompressUID(unsigned char* short_uid, char* long_uid);
174  string CompressUID(char* compressedUID);
175  float GetPFileVersion();
176  svkGEPFileMapper* GetPFileMapper();
177  static void UpdateProgressCallback(
178  vtkObject* subject,
179  unsigned long,
180  void* thisObject,
181  void* callData
182  );
183  void FillInMissingInfo();
184  void SetDataByteOrder();
185  void DeidentifyData();
186  int GetNumElementsInField( string key );
187  int GetNumBytesInField( string key );
188  void DeidentifyField( fstream* fs, string key, string deidString);
189  bool IsFieldChar( string key );
190  bool IsFieldUID( string key );
191  bool IsFieldInt2( string key );
192  bool IsFieldFloat4( string key );
193  bool IsFieldInt4( string key );
194  bool IsFieldLInt4( string key );
195  bool IsFieldLInt8( string key );
196  string GetSeriesUID(const char* fname);
197 
198  // Members:
199  ifstream* gepf;
200  float pfileVersion;
201  svkGEPFileMapper* mapper;
202 
203  map < string, void* >
204  inputArgs;
205 
206  vtkCallbackCommand* progressCallback;
207  vtkStringArray* tmpFileNames;
208 
209  svkDcmHeader::PHIType phiType;
210  string deidPatientId;
211  string deidStudyId;
212  string deidStudyUID;
213  string deidSeriesUID;
214  string deidImageUID;
215  string deidLandmarkUID;
216  string psdLogic;
217 
218 };
219 
220 
221 } //svk
222 
223 #endif //SVK_GE_PFILE_READER_H
224 
void SetEPSIParams(svkEPSIReorder::EPSIType type, svkEPSIReorder::EPSIAxis axis, int first, int numLobes, int numSkip)
Definition: svkGEPFileReader.cc:474
Definition: svkImageReader2.h:77
void SetDeidentify(svkDcmHeader::PHIType phiType)
Definition: svkGEPFileReader.cc:498
void Deidentify()
Definition: svkGEPFileReader.cc:3540
virtual const char * GetDescriptiveName()
Definition: svkGEPFileReader.h:129
Definition: svkImageReader2.h:60
virtual svkDcmHeader::DcmPixelDataFormat GetFileType()
Definition: svkGEPFileReader.cc:997
virtual string GetFileSeriesDescription(string fileName)
Definition: svkGEPFileReader.cc:3634
ReaderType
Definition: svkImageReader2.h:67
void SetDeidentificationInstanceUID(string deidImageUID)
Definition: svkGEPFileReader.cc:3521
void ReadGEPFile()
Definition: svkGEPFileReader.cc:706
map< string, vector< string > > GetPFMap()
Definition: svkGEPFileReader.cc:3187
void PrintHeader()
Definition: svkGEPFileReader.cc:543
svkGEPFileMapper * GetMapper()
Definition: svkGEPFileReader.cc:696
map< string, vector< string > > pfMap
Definition: svkGEPFileReader.h:156
EPSIType
Definition: svkEPSIReorder.h:70
void InitOffsetsMap()
Definition: svkGEPFileReader.cc:959
virtual void ExecuteInformation()
Definition: svkGEPFileReader.cc:232
DcmPixelDataFormat
Definition: svkDcmHeader.h:92
virtual int FillOutputPortInformation(int port, vtkInformation *info)
Definition: svkGEPFileReader.cc:854
virtual svkImageReader2::ReaderType GetReaderType()
Definition: svkGEPFileReader.h:133
PHIType
Definition: svkDcmHeader.h:115
void SetChop(bool chop)
Definition: svkGEPFileReader.cc:575
static float LookupRawVersion(float rdbmRev, float rdbmRevSwapped)
Definition: svkGEPFileReader.cc:1296
~svkGEPFileReader()
Definition: svkGEPFileReader.cc:104
virtual int CanReadFile(const char *fname)
Definition: svkGEPFileReader.cc:138
EPSIAxis
Definition: svkEPSIReorder.h:77
void SetDeidentificationLandmarkUID(string deidLandmarkUID)
Definition: svkGEPFileReader.cc:3529
static svkGEPFileReader * New()
Definition: svkGEPFileReader.h:88
void ModifyRawField(string rawField, string value)
Definition: svkGEPFileReader.cc:3470
void SetDeidentificationStudyUID(string deidStudyUID)
Definition: svkGEPFileReader.cc:3505
void ParsePFile()
Definition: svkGEPFileReader.cc:811
bool checkSeriesUID
Definition: svkGEPFileReader.h:138
virtual void SetProvenance()
Definition: svkGEPFileReader.cc:330
virtual void ExecuteDataWithInformation(vtkDataObject *output, vtkInformation *outInfo)
Definition: svkGEPFileReader.cc:287
vtkTypeMacro(svkGEPFileReader, svkImageReader2)
void PrintShortHeader()
Definition: svkGEPFileReader.cc:553
svkGEPFileReader()
Definition: svkGEPFileReader.cc:68
MapperBehavior
Definition: svkGEPFileMapper.h:76
Definition: svkGEPFileMapper.h:65
void SetTemperature(float temp)
Definition: svkGEPFileReader.cc:564
void SetMapperBehavior(svkGEPFileMapper::MapperBehavior type)
Definition: svkGEPFileReader.cc:459
void SetDeidentificationSeriesUID(string deidSeriesUID)
Definition: svkGEPFileReader.cc:3513
void SetPSDLogic(string psdName)
Definition: svkGEPFileReader.cc:616