Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DicomVFileImage Class Reference

#include <DicomVFileImage.hh>

Inheritance diagram for DicomVFileImage:
Collaboration diagram for DicomVFileImage:

Public Member Functions

 DicomVFileImage ()
 
 DicomVFileImage (DcmDataset *dset)
 
 ~DicomVFileImage ()
 
virtual void ReadData ()
 
void operator+= (const DicomVFileImage &rhs)
 
DicomVFileImage operator+ (const DicomVFileImage &rhs)
 
void DumpHeaderToTextFile (std::ofstream &fout)
 
G4int GetNoVoxelX () const
 
G4int GetNoVoxelY () const
 
G4int GetNoVoxelZ () const
 
G4int GetNoVoxels () const
 
G4double GetMinX () const
 
G4double GetMinY () const
 
G4double GetMinZ () const
 
G4double GetMaxX () const
 
G4double GetMaxY () const
 
G4double GetMaxZ () const
 
void SetNoVoxelX (const G4int &val)
 
void SetNoVoxelY (const G4int &val)
 
void SetNoVoxelZ (const G4int &val)
 
void SetMinX (const G4double &val)
 
void SetMaxX (const G4double &val)
 
void SetMinY (const G4double &val)
 
void SetMaxY (const G4double &val)
 
void SetMinZ (const G4double &val)
 
void SetMaxZ (const G4double &val)
 
const G4doubleGetLocation () const
 
void SetLocation (const G4double &val)
 
G4ThreeVector GetOrientationRows () const
 
G4ThreeVector GetOrientationColumns () const
 
- Public Member Functions inherited from DicomVFile
 DicomVFile ()
 
 DicomVFile (DcmDataset *dset)
 
 ~DicomVFile ()
 
void SetFileName (G4String fName)
 

Protected Attributes

G4double fLocation
 
G4double fBitAllocated
 
G4double fRescaleSlope
 
G4double fRescaleIntercept
 
G4int fNoVoxelX
 
G4int fNoVoxelY
 
G4int fNoVoxelZ
 
G4double fMinX
 
G4double fMinY
 
G4double fMinZ
 
G4double fMaxX
 
G4double fMaxY
 
G4double fMaxZ
 
G4double fVoxelDimX
 
G4double fVoxelDimY
 
G4double fVoxelDimZ
 
G4ThreeVector fOrientationRows
 
G4ThreeVector fOrientationColumns
 
std::vector< intfHounsfieldV
 
DicomFileMgrtheFileMgr
 
- Protected Attributes inherited from DicomVFile
DcmDataset * theDataset
 
G4String fFileName
 

Additional Inherited Members

- Protected Member Functions inherited from DicomVFile
virtual std::vector< G4doubleRead1Data (DcmDataset *dset, DcmTagKey tagKey, G4int nData)
 
virtual OFString Read1DataStr (DcmDataset *dset, DcmTagKey tagKey)
 

Detailed Description

Definition at line 33 of file DicomVFileImage.hh.

Constructor & Destructor Documentation

DicomVFileImage::DicomVFileImage ( )

Definition at line 42 of file DicomVFileImage.cc.

43 {
45 }
DicomFileMgr * theFileMgr
static DicomFileMgr * GetInstance()
Definition: DicomFileMgr.cc:41

Here is the call graph for this function:

DicomVFileImage::DicomVFileImage ( DcmDataset *  dset)

Definition at line 48 of file DicomVFileImage.cc.

48  : DicomVFile(dset)
49 {
51 }
DicomFileMgr * theFileMgr
static DicomFileMgr * GetInstance()
Definition: DicomFileMgr.cc:41

Here is the call graph for this function:

DicomVFileImage::~DicomVFileImage ( )
inline

Definition at line 38 of file DicomVFileImage.hh.

38 {};

Member Function Documentation

void DicomVFileImage::DumpHeaderToTextFile ( std::ofstream &  fout)

Definition at line 306 of file DicomVFileImage.cc.

307 {
308  if( DicomFileMgr::verbose >= warningVerb ) G4cout << fLocation << " DumpHeaderToTextFile "
309  << fFileName << " " << fHounsfieldV.size() << G4endl;
310 
311  G4String fName = fFileName.substr(0,fFileName.length()-3) + "g4dcm";
312  std::ofstream out(fName.c_str());
313 
315  << "### DicomVFileImage::Dumping Z Slice header to Text file " << G4endl;
316 
317  G4int fCompress = theFileMgr->GetCompression();
318  fout << fNoVoxelX/fCompress << " " << fNoVoxelY/fCompress << " " << fNoVoxelZ << std::endl;
319  fout << fMinX << " " << fMaxX << std::endl;
320  fout << fMinY << " " << fMaxY << std::endl;
321  fout << fMinZ << " " << fMaxZ << std::endl;
322 
323 }
G4String fName
Definition: G4AttUtils.hh:55
G4int GetCompression() const
Definition: DicomFileMgr.hh:91
int G4int
Definition: G4Types.hh:78
G4String fFileName
Definition: DicomVFile.hh:55
G4GLOB_DLL std::ostream G4cout
std::vector< int > fHounsfieldV
static int verbose
DicomFileMgr * theFileMgr
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

Here is the caller graph for this function:

const G4double& DicomVFileImage::GetLocation ( ) const
inline

Definition at line 73 of file DicomVFileImage.hh.

73 { return fLocation; }

Here is the caller graph for this function:

G4double DicomVFileImage::GetMaxX ( ) const
inline

Definition at line 58 of file DicomVFileImage.hh.

58 { return fMaxX; };

Here is the caller graph for this function:

G4double DicomVFileImage::GetMaxY ( ) const
inline

Definition at line 59 of file DicomVFileImage.hh.

59 { return fMaxY; };

Here is the caller graph for this function:

G4double DicomVFileImage::GetMaxZ ( ) const
inline

Definition at line 60 of file DicomVFileImage.hh.

60 { return fMaxZ; };

Here is the caller graph for this function:

G4double DicomVFileImage::GetMinX ( ) const
inline

Definition at line 55 of file DicomVFileImage.hh.

55 { return fMinX; };

Here is the caller graph for this function:

G4double DicomVFileImage::GetMinY ( ) const
inline

Definition at line 56 of file DicomVFileImage.hh.

56 { return fMinY; };

Here is the caller graph for this function:

G4double DicomVFileImage::GetMinZ ( ) const
inline

Definition at line 57 of file DicomVFileImage.hh.

57 { return fMinZ; };

Here is the caller graph for this function:

G4int DicomVFileImage::GetNoVoxels ( ) const
inline

Definition at line 53 of file DicomVFileImage.hh.

G4int DicomVFileImage::GetNoVoxelX ( ) const
inline

Definition at line 50 of file DicomVFileImage.hh.

50 { return fNoVoxelX; };

Here is the caller graph for this function:

G4int DicomVFileImage::GetNoVoxelY ( ) const
inline

Definition at line 51 of file DicomVFileImage.hh.

51 { return fNoVoxelY; };

Here is the caller graph for this function:

G4int DicomVFileImage::GetNoVoxelZ ( ) const
inline

Definition at line 52 of file DicomVFileImage.hh.

52 { return fNoVoxelZ; };

Here is the caller graph for this function:

G4ThreeVector DicomVFileImage::GetOrientationColumns ( ) const
inline

Definition at line 78 of file DicomVFileImage.hh.

78 { return fOrientationColumns; }
G4ThreeVector fOrientationColumns

Here is the caller graph for this function:

G4ThreeVector DicomVFileImage::GetOrientationRows ( ) const
inline

Definition at line 77 of file DicomVFileImage.hh.

77 { return fOrientationRows; }
G4ThreeVector fOrientationRows

Here is the caller graph for this function:

DicomVFileImage DicomVFileImage::operator+ ( const DicomVFileImage rhs)

Definition at line 240 of file DicomVFileImage.cc.

241 {
242  //----- Check that both slices has the same dimensions
243  if( fNoVoxelX != rhs.GetNoVoxelX()
244  || fNoVoxelY != rhs.GetNoVoxelY() ) {
245  G4cerr << "DicomVFileImage error adding two slice headers:\
246  !!! Different number of voxels: "
247  << " X= " << fNoVoxelX << " =? " << rhs.GetNoVoxelX()
248  << " Y= " << fNoVoxelY << " =? " << rhs.GetNoVoxelY()
249  << " Z= " << fNoVoxelZ << " =? " << rhs.GetNoVoxelZ()
250  << G4endl;
251  G4Exception("DicomVFileImage::DicomVFileImage",
252  "",FatalErrorInArgument,"");
253  }
254  //----- Check that both slices has the same extensions
255  if( fMinX != rhs.GetMinX() || fMaxX != rhs.GetMaxX()
256  || fMinY != rhs.GetMinY() || fMaxY != rhs.GetMaxY() ) {
257  G4cerr << "DicomVFileImage error adding two slice headers:\
258  !!! Different extensions: "
259  << " Xmin= " << fMinX << " =? " << rhs.GetMinX()
260  << " Xmax= " << fMaxX << " =? " << rhs.GetMaxX()
261  << " Ymin= " << fMinY << " =? " << rhs.GetMinY()
262  << " Ymax= " << fMaxY << " =? " << rhs.GetMaxY()
263  << G4endl;
264  G4Exception("DicomVFileImage::operator+","",
266  }
267 
268  //----- Check that both slices has the same orientations
269  if( fOrientationRows != rhs.GetOrientationRows() ||
271  G4cerr << "DicomVFileImage error adding two slice headers: !!!\
272  Slices have different orientations "
273  << " Orientation Rows = " << fOrientationRows << " & " << rhs.GetOrientationRows()
274  << " Orientation Columns " << fOrientationColumns << " & "
275  << rhs.GetOrientationColumns() << G4endl;
276  G4Exception("DicomVFileImage::operator+","",
278  }
279 
280  //----- Check that the slices are contiguous in Z
281  if( std::fabs( fMinZ - rhs.GetMaxZ() ) >
283  std::fabs( fMaxZ - rhs.GetMinZ() ) >
285  G4cerr << "DicomVFileImage error adding two slice headers: !!!\
286  Slices are not contiguous in Z "
287  << " Zmin= " << fMinZ << " & " << rhs.GetMinZ()
288  << " Zmax= " << fMaxZ << " & " << rhs.GetMaxZ()
289  << G4endl;
290  G4Exception("DicomVFileImage::operator+","",
291  JustWarning,"");
292  }
293 
294  //----- Build slice header copying first one
295  DicomVFileImage temp( *this );
296 
297  //----- Add data from second slice header
298  temp.SetMinZ( std::min( fMinZ, rhs.GetMinZ() ) );
299  temp.SetMaxZ( std::max( fMaxZ, rhs.GetMaxZ() ) );
300  temp.SetNoVoxelZ( fNoVoxelZ + rhs.GetNoVoxelZ() );
301 
302  return temp;
303 }
G4double GetMinX() const
G4double GetMinZ() const
G4ThreeVector GetOrientationRows() const
G4int GetNoVoxelY() const
G4int GetNoVoxelZ() const
G4double GetRadialTolerance() const
G4double GetMaxZ() const
G4double GetMaxX() const
G4double GetMinY() const
G4ThreeVector fOrientationRows
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
T max(const T t1, const T t2)
brief Return the largest of the two arguments
G4ThreeVector fOrientationColumns
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
G4double GetMaxY() const
G4ThreeVector GetOrientationColumns() const
#define G4endl
Definition: G4ios.hh:61
G4int GetNoVoxelX() const
static G4GeometryTolerance * GetInstance()
G4GLOB_DLL std::ostream G4cerr

Here is the call graph for this function:

void DicomVFileImage::operator+= ( const DicomVFileImage rhs)

Definition at line 234 of file DicomVFileImage.cc.

235 {
236  *this = *this + rhs;
237 }
void DicomVFileImage::ReadData ( )
virtual

Implements DicomVFile.

Definition at line 55 of file DicomVFileImage.cc.

56 {
57  std::vector<double> dImagePositionPatient = Read1Data(theDataset, DCM_ImagePositionPatient,3);
58  fLocation = dImagePositionPatient[2];
59  std::vector<double> dSliceThickness = Read1Data(theDataset, DCM_SliceThickness, 1);
60  std::vector<double> dPixelSpacing = Read1Data(theDataset, DCM_PixelSpacing, 2);
61 
62  std::vector<double> dRows = Read1Data(theDataset, DCM_Rows, 1);
63  std::vector<double> dColumns = Read1Data(theDataset, DCM_Columns, 1);
64  fNoVoxelY = dRows[0];
65  fNoVoxelX = dColumns[0];
66  fNoVoxelZ = 1;
67 
68  fMinX = dImagePositionPatient[0]; // center of upper corner of pixel?
69  fMaxX = dImagePositionPatient[0]+dColumns[0]*dPixelSpacing[0];
70 
71  fMinY = dImagePositionPatient[1];
72  fMaxY = dImagePositionPatient[1]+dRows[0]*dPixelSpacing[1];
73 
74  fMinZ = dImagePositionPatient[2]-dSliceThickness[0]/2.;
75  fMaxZ = dImagePositionPatient[2]+dSliceThickness[0]/2.;
76  fVoxelDimX = dPixelSpacing[0];
77  fVoxelDimY = dPixelSpacing[1];
78  fVoxelDimZ = dSliceThickness[0];
79 
80  if( DicomFileMgr::verbose >= debugVerb ) G4cout << " DicomVFileImage::ReadData: fNoVoxel "
81  << fNoVoxelX << " " << fNoVoxelY << " " << fNoVoxelZ << G4endl;
82  if( DicomFileMgr::verbose >= debugVerb ) G4cout << " DicomVFileImage::ReadData: fMin "
83  << fMinX << " " << fMinY << " " << fMinZ << G4endl;
84  if( DicomFileMgr::verbose >= debugVerb ) G4cout << " DicomVFileImage::ReadData: fMax "
85  << fMaxX << " " << fMaxY << " " << fMaxZ << G4endl;
86  if( DicomFileMgr::verbose >= debugVerb ) G4cout << " DicomVFileImage::ReadData: fVoxelDim "
87  << fVoxelDimX << " " << fVoxelDimY << " " << fVoxelDimZ << G4endl;
88 
89  std::vector<double> dImageOrientationPatient =
90  Read1Data(theDataset, DCM_ImageOrientationPatient,6);
91  fOrientationRows = G4ThreeVector(dImageOrientationPatient[0],dImageOrientationPatient[1],
92  dImageOrientationPatient[2]);
93  fOrientationColumns = G4ThreeVector(dImageOrientationPatient[3],dImageOrientationPatient[4],
94  dImageOrientationPatient[5]);
95 
96  if( fOrientationRows != G4ThreeVector(1,0,0)
97  || fOrientationColumns != G4ThreeVector(0,1,0) ) {
98  G4cerr << " OrientationRows " << fOrientationRows << " OrientationColumns "
100  G4Exception("DicomVFileImage::ReadData",
101  "DFCT0002",
102  JustWarning,
103  "OrientationRows must be (1,0,0) and OrientationColumns (0,1,0), please contact GAMOS authors");
104  }
105  fBitAllocated = Read1Data(theDataset, DCM_BitsAllocated, 1)[0];
106  if( DicomFileMgr::verbose >= 4 ) G4cout << " BIT ALLOCATED " << fBitAllocated << G4endl;
107 
108  std::vector<double> dRescaleSlope = Read1Data(theDataset, DCM_RescaleSlope, 1);
109  if( dRescaleSlope.size() == 1 ) {
110  fRescaleSlope = dRescaleSlope[0];
111  } else {
112  fRescaleSlope = 1;
113  }
114  std::vector<double> dRescaleIntercept = Read1Data(theDataset, DCM_RescaleIntercept, 1);
115  if( dRescaleIntercept.size() == 1 ) {
116  fRescaleIntercept = dRescaleIntercept[0];
117  } else {
118  fRescaleIntercept = 1;
119  }
120 
121  ReadPixelData();
122 }
G4double fRescaleIntercept
CLHEP::Hep3Vector G4ThreeVector
G4double fRescaleSlope
virtual std::vector< G4double > Read1Data(DcmDataset *dset, DcmTagKey tagKey, G4int nData)
Definition: DicomVFile.cc:40
G4double fBitAllocated
G4GLOB_DLL std::ostream G4cout
DcmDataset * theDataset
Definition: DicomVFile.hh:52
static int verbose
G4ThreeVector fOrientationRows
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4ThreeVector fOrientationColumns
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr

Here is the call graph for this function:

Here is the caller graph for this function:

void DicomVFileImage::SetLocation ( const G4double val)
inline

Definition at line 75 of file DicomVFileImage.hh.

75 { fLocation = val; }
void DicomVFileImage::SetMaxX ( const G4double val)
inline

Definition at line 67 of file DicomVFileImage.hh.

67 { fMaxX = val; };
void DicomVFileImage::SetMaxY ( const G4double val)
inline

Definition at line 69 of file DicomVFileImage.hh.

69 { fMaxY = val; };
void DicomVFileImage::SetMaxZ ( const G4double val)
inline

Definition at line 71 of file DicomVFileImage.hh.

71 { fMaxZ = val; };

Here is the caller graph for this function:

void DicomVFileImage::SetMinX ( const G4double val)
inline

Definition at line 66 of file DicomVFileImage.hh.

66 { fMinX = val; };
void DicomVFileImage::SetMinY ( const G4double val)
inline

Definition at line 68 of file DicomVFileImage.hh.

68 { fMinY = val; };
void DicomVFileImage::SetMinZ ( const G4double val)
inline

Definition at line 70 of file DicomVFileImage.hh.

70 { fMinZ = val; };

Here is the caller graph for this function:

void DicomVFileImage::SetNoVoxelX ( const G4int val)
inline

Definition at line 62 of file DicomVFileImage.hh.

62 { fNoVoxelX = val; }
void DicomVFileImage::SetNoVoxelY ( const G4int val)
inline

Definition at line 63 of file DicomVFileImage.hh.

63 { fNoVoxelY = val; }
void DicomVFileImage::SetNoVoxelZ ( const G4int val)
inline

Definition at line 64 of file DicomVFileImage.hh.

64 { fNoVoxelZ = val; }

Here is the caller graph for this function:

Member Data Documentation

G4double DicomVFileImage::fBitAllocated
protected

Definition at line 88 of file DicomVFileImage.hh.

std::vector<int> DicomVFileImage::fHounsfieldV
protected

Definition at line 100 of file DicomVFileImage.hh.

G4double DicomVFileImage::fLocation
protected

Definition at line 87 of file DicomVFileImage.hh.

G4double DicomVFileImage::fMaxX
protected

Definition at line 94 of file DicomVFileImage.hh.

G4double DicomVFileImage::fMaxY
protected

Definition at line 94 of file DicomVFileImage.hh.

G4double DicomVFileImage::fMaxZ
protected

Definition at line 94 of file DicomVFileImage.hh.

G4double DicomVFileImage::fMinX
protected

Definition at line 93 of file DicomVFileImage.hh.

G4double DicomVFileImage::fMinY
protected

Definition at line 93 of file DicomVFileImage.hh.

G4double DicomVFileImage::fMinZ
protected

Definition at line 93 of file DicomVFileImage.hh.

G4int DicomVFileImage::fNoVoxelX
protected

Definition at line 92 of file DicomVFileImage.hh.

G4int DicomVFileImage::fNoVoxelY
protected

Definition at line 92 of file DicomVFileImage.hh.

G4int DicomVFileImage::fNoVoxelZ
protected

Definition at line 92 of file DicomVFileImage.hh.

G4ThreeVector DicomVFileImage::fOrientationColumns
protected

Definition at line 98 of file DicomVFileImage.hh.

G4ThreeVector DicomVFileImage::fOrientationRows
protected

Definition at line 97 of file DicomVFileImage.hh.

G4double DicomVFileImage::fRescaleIntercept
protected

Definition at line 90 of file DicomVFileImage.hh.

G4double DicomVFileImage::fRescaleSlope
protected

Definition at line 89 of file DicomVFileImage.hh.

G4double DicomVFileImage::fVoxelDimX
protected

Definition at line 95 of file DicomVFileImage.hh.

G4double DicomVFileImage::fVoxelDimY
protected

Definition at line 95 of file DicomVFileImage.hh.

G4double DicomVFileImage::fVoxelDimZ
protected

Definition at line 95 of file DicomVFileImage.hh.

DicomFileMgr* DicomVFileImage::theFileMgr
protected

Definition at line 102 of file DicomVFileImage.hh.


The documentation for this class was generated from the following files: