32 #include "dcmtk/dcmdata/dcfilefo.h"
33 #include "dcmtk/dcmdata/dcdeftag.h"
34 #include "dcmtk/dcmdata/dcpixel.h"
35 #include "dcmtk/dcmdata/dcpxitem.h"
36 #include "dcmtk/dcmdata/dcpixseq.h"
37 #include "dcmtk/dcmrt/drtimage.h"
57 std::vector<double> dImagePositionPatient =
Read1Data(
theDataset, DCM_ImagePositionPatient,3);
68 fMinX = dImagePositionPatient[0];
69 fMaxX = dImagePositionPatient[0]+dColumns[0]*dPixelSpacing[0];
71 fMinY = dImagePositionPatient[1];
72 fMaxY = dImagePositionPatient[1]+dRows[0]*dPixelSpacing[1];
74 fMinZ = dImagePositionPatient[2]-dSliceThickness[0]/2.;
75 fMaxZ = dImagePositionPatient[2]+dSliceThickness[0]/2.;
89 std::vector<double> dImageOrientationPatient =
92 dImageOrientationPatient[2]);
94 dImageOrientationPatient[5]);
103 "OrientationRows must be (1,0,0) and OrientationColumns (0,1,0), please contact GAMOS authors");
109 if( dRescaleSlope.size() == 1 ) {
115 if( dRescaleIntercept.size() == 1 ) {
129 OFCondition
result = EC_Normal;
131 DcmElement* element = NULL;
132 result =
theDataset->findAndGetElement(DCM_PixelData, element);
133 if (result.bad() || element == NULL) {
135 "findAndGetElement(DCM_PixelData, ",
137 (
"Element PixelData not found: " +
G4String(result.text())).c_str());
139 DcmPixelData *dpix = NULL;
140 dpix = OFstatic_cast(DcmPixelData*, element);
144 DcmPixelSequence *dseq = NULL;
145 E_TransferSyntax xferSyntax = EXS_Unknown;
146 const DcmRepresentationParameter *rep = NULL;
148 dpix->getOriginalRepresentationKey(xferSyntax, rep);
150 result = dpix->getEncapsulatedRepresentation(xferSyntax, rep, dseq);
151 if ( result == EC_Normal )
156 "Compressed pixel data is not supported");
159 <<
" DicomVFileImage::ReadData: result == EC_Normal Reading compressed data " << std::endl;
160 DcmPixelItem* pixitem = NULL;
162 for(
int ii = 1; ii < 2; ii++ ) {
163 OFCondition cond = dseq->getItem(pixitem, ii);
164 if( !cond.good())
break;
165 G4cout << ii <<
" PIX LENGTH " << pixitem->getLength() <<
G4endl;
167 if (pixitem == NULL) {
171 "No DcmPixelItem in DcmPixelSequence");
173 Uint8* pixData = NULL;
176 Uint32 length = pixitem->getLength();
179 "pixitem->getLength()",
185 <<
" DicomVFileImage::ReadData: number of pixels " << length <<
G4endl;
187 result = pixitem->getUint8Array(pixData);
190 Uint8* pixData = NULL;
191 if(! (element->getUint8Array(pixData)).good() ) {
193 "getUint8Array pixData, ",
195 (
"PixelData not found: " +
G4String(result.text())).c_str());
197 for(
int ir = 0; ir <
fNoVoxelY; ir++ ) {
198 for(
int ic = 0; ic <
fNoVoxelX; ic++ ) {
203 Uint16* pixData = NULL;
204 if(! (element->getUint16Array(pixData)).good() ) {
206 "getUint16Array pixData, ",
208 (
"PixelData not found: " +
G4String(result.text())).c_str());
210 for(
int ir = 0; ir <
fNoVoxelY; ir++ ) {
211 for(
int ic = 0; ic <
fNoVoxelX; ic++ ) {
216 Uint32* pixData = NULL;
217 if(! (element->getUint32Array(pixData)).good() ) {
219 "getUint32Array pixData, ",
221 (
"PixelData not found: " +
G4String(result.text())).c_str());
223 for(
int ir = 0; ir <
fNoVoxelY; ir++ ) {
224 for(
int ic = 0; ic <
fNoVoxelX; ic++ ) {
245 G4cerr <<
"DicomVFileImage error adding two slice headers:\
246 !!! Different number of voxels: "
257 G4cerr <<
"DicomVFileImage error adding two slice headers:\
258 !!! Different extensions: "
271 G4cerr <<
"DicomVFileImage error adding two slice headers: !!!\
272 Slices have different orientations "
285 G4cerr <<
"DicomVFileImage error adding two slice headers: !!!\
286 Slices are not contiguous in Z "
312 std::ofstream out(fName.c_str());
315 <<
"### DicomVFileImage::Dumping Z Slice header to Text file " <<
G4endl;
T max(const T t1, const T t2)
brief Return the largest of the two arguments
G4int GetNoVoxelX() const
void SetMaxZ(const G4double &val)
virtual std::vector< G4double > Read1Data(DcmDataset *dset, DcmTagKey tagKey, G4int nData)
G4double fRescaleIntercept
CLHEP::Hep3Vector G4ThreeVector
DicomVFileImage operator+(const DicomVFileImage &rhs)
void SetMinZ(const G4double &val)
static DicomFileMgr * GetInstance()
void SetNoVoxelZ(const G4int &val)
G4int GetCompression() const
void Print(std::ostream &out)
G4double GetRadialTolerance() const
G4ThreeVector fOrientationRows
G4ThreeVector fOrientationColumns
std::vector< int > fHounsfieldV
G4ThreeVector GetOrientationRows() const
G4GLOB_DLL std::ostream G4cerr
G4double G4ParticleHPJENDLHEData::G4double result
void DumpHeaderToTextFile(std::ofstream &fout)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4ThreeVector GetOrientationColumns() const
DicomFileMgr * theFileMgr
G4int GetNoVoxelZ() const
G4GLOB_DLL std::ostream G4cout
void operator+=(const DicomVFileImage &rhs)
G4int GetNoVoxelY() const
static G4GeometryTolerance * GetInstance()
T min(const T t1, const T t2)
brief Return the smallest of the two arguments