DICOM @ OFFIS

Discussion Forum for OFFIS DICOM Tools - For registration, send email with desired user name to the OFFIS DICOM team
It is currently Sat, 2017-09-23, 22:35

All times are UTC + 1 hour




Post new topic Reply to topic  [ 14 posts ] 
Author Message
PostPosted: Wed, 2012-09-19, 09:20 
Offline

Joined: Fri, 2010-06-18, 06:14
Posts: 12
Dear Group members,

I am unable to read pixel data from RT Dose dicom file. I am using DCMTK 3.6.0

Here's the code that, I am using:
*********************************
DcmFileFormat dfile;
dfile.loadFile("rtdose.dcm");
dfile.loadAllDataIntoMemory();
dset = dfile.getDataset();
DcmDataset *d = dfile.getDataset();

const Uint16* pixelData16 = NULL;
unsigned long count = 0;
d->findAndGetUint16Array(DCM_PixelData, pixelData16);
***********************************

Same code works well for non-rt dicoms but for RT Dose files, pixelData16 is returned as empty string.

Here are the RT dose file details from dcmdump:
******************************************************

# Dicom-File-Format

# Dicom-Meta-Information-Header
# Used TransferSyntax: LittleEndianExplicit
(0002,0000) UL 162 # 4, 1 MetaElementGroupLength
(0002,0001) OB 00\01 # 2, 1 FileMetaInformationVersion
(0002,0002) UI =RTDoseStorage # 30, 1 MediaStorageSOPClassUID
(0002,0003) UI [1.2.246.352.71.7.320687012.47206.20090603085223] # 48, 1 MediaStorageSOPInstanceUID
(0002,0010) UI =LittleEndianImplicit # 18, 1 TransferSyntaxUID
(0002,0012) UI [1.2.246.352.70.2.1.7] # 20, 1 ImplementationClassUID
.....
.....
.....
(0028,0002) US 1 # 2, 1 SamplesPerPixel
(0028,0004) CS [MONOCHROME2] # 12, 1 PhotometricInterpretation
(0028,0008) IS [98] # 2, 1 NumberOfFrames
(0028,0009) AT (3004,000c) # 4, 1 FrameIncrementPointer
(0028,0010) US 129 # 2, 1 Rows
(0028,0011) US 194 # 2, 1 Columns
(0028,0030) DS [2.5\2.5] # 8, 2 PixelSpacing
(0028,0100) US 32 # 2, 1 BitsAllocated
(0028,0101) US 32 # 2, 1 BitsStored
(0028,0102) US 31 # 2, 1 HighBit
(0028,0103) US 0 # 2, 1 PixelRepresentation
(3004,0002) CS [GY] # 2, 1 DoseUnits
(3004,0004) CS [PHYSICAL] # 8, 1 DoseType
(3004,000a) CS [PLAN] # 4, 1 DoseSummationType
(3004,000c) DS [0.0\3\6\9\12\15\18\21\24\27\30\33\36\39\42\45\48\51\54\57\60\63\66... # 356,98 GridFrameOffsetVector
(3004,000e) DS [1.4e-5] # 6, 1 DoseGridScaling
.....
.....
.....
(7fe0,0010) OW 0000\0000\0000\0000\0000\0000\0000\0000\0000\0000\0000\0000\0000... # 9810192, 1 PixelData


Top
 Profile  
 
PostPosted: Wed, 2012-09-19, 10:15 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1847
Location: Oldenburg, Germany
Are you sure that the data dictionary is loaded in your application? I'm asking because the dataset is stored with Little Endian Implicit VR ...


Top
 Profile  
 
PostPosted: Wed, 2012-09-19, 12:11 
Offline

Joined: Fri, 2010-06-18, 06:14
Posts: 12
J. Riesmeier wrote:
Are you sure that the data dictionary is loaded in your application? I'm asking because the dataset is stored with Little Endian Implicit VR ...


I think data dictionary is getting loaded because the same code is working for a CT image. But, I can recheck. Can you guide me, what needs to be checked?


Top
 Profile  
 
PostPosted: Wed, 2012-09-19, 12:18 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1847
Location: Oldenburg, Germany
You should check the return value of dcmDataDict.isDictionaryLoaded() as all DCMTK command line tools do.


Top
 Profile  
 
PostPosted: Wed, 2012-09-19, 12:26 
Offline

Joined: Fri, 2010-06-18, 06:14
Posts: 12
J. Riesmeier wrote:
You should check the return value of dcmDataDict.isDictionaryLoaded() as all DCMTK command line tools do.

Yes, data dictionary is getting loaded.


Top
 Profile  
 
PostPosted: Wed, 2012-09-19, 12:27 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1847
Location: Oldenburg, Germany
And what is the status code returned by the findAndGetUint16Array() call?


Top
 Profile  
 
PostPosted: Wed, 2012-09-19, 12:30 
Offline

Joined: Fri, 2010-06-18, 06:14
Posts: 12
J. Riesmeier wrote:
And what is the status code returned by the findAndGetUint16Array() call?

These are values from OFCondtion:
theCode: 0
theStatus: OF_ok
theText: Normal


Top
 Profile  
 
PostPosted: Wed, 2012-09-19, 12:36 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1847
Location: Oldenburg, Germany
Then everything is ok. Btw, the PixelData element value starts with zeros (0) ;-)


Top
 Profile  
 
PostPosted: Wed, 2012-09-19, 13:08 
Offline

Joined: Fri, 2010-06-18, 06:14
Posts: 12
J. Riesmeier wrote:
Then everything is ok. Btw, the PixelData element value starts with zeros (0) ;-)

Oh, does this mean. If pixel data starts with 0, it wont display in visual studio debugger?
I, just ran a loop on pixelData16 and I can see pixel values. Thanks.


Top
 Profile  
 
PostPosted: Wed, 2012-09-19, 19:46 
Offline

Joined: Fri, 2010-06-18, 06:14
Posts: 12
abhishek_gupta wrote:
J. Riesmeier wrote:
Then everything is ok. Btw, the PixelData element value starts with zeros (0) ;-)

Oh, does this mean. If pixel data starts with 0, it wont display in visual studio debugger?
I, just ran a loop on pixelData16 and I can see pixel values. Thanks.


Hello Riesmeier, how do I determine max dose pixel value? Do, I have to iterate over pixel array and find max pixel value. If yes, then what is the correct way to iterate pixel data? Since length of pixel array does not match product of rows and columns.


Top
 Profile  
 
PostPosted: Thu, 2012-09-20, 07:40 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1847
Location: Oldenburg, Germany
You could e.g. the DicomImage class for this purpose. With regard to the length of the PixelData field: 1 pixel consists of 4 bytes in your case, and you have 98 frames ...


Top
 Profile  
 
PostPosted: Thu, 2012-10-04, 11:38 
Offline

Joined: Fri, 2010-06-18, 06:14
Posts: 12
J. Riesmeier wrote:
You could e.g. the DicomImage class for this purpose. With regard to the length of the PixelData field: 1 pixel consists of 4 bytes in your case, and you have 98 frames ...


Today, I have reached a point where I needed pixel data from multi frame RT DOSE. As suggested, I am using DicomImage->getInterData() APT to extract DiPixel* and DiPixel*->getData() API to access pixel data for first frame(Frame# 0). Now, since bits allocated is equal to 32. What should the typecast be? I have tried UINT32 and UINT16.

Also I have read frame#0 using python's DICOM library which returns all pixel values to be zero(0). But when I dumped pixel values from DiPixel*->getData() to a file. I found that some values are not zero.

Here's my code:
Code:
DicomImage * dicomImage = new DicomImage(dataset->file_format,
            dataset->file_format.getDataset()->getOriginalXfer()  ,  CIF_UsePartialAccessToPixelData, 0,1 /* fcount */);
FILE* fp = fopen("c++.dat", "wb");
const DiPixel* diPixel = dicomImage->getInterData();
cout << "writing"<<endl;
         UINT32 * pData=0;
         pData = (UINT32 *)diPixel->getData();
         
         int width=columns;
         int height=rows;

         fprintf(fp,"Frame:%d\n Pixel number:%d\n",dicomImage->getFirstFrame(),diPixel->getCount());
         
         for(int y=0;y<height;y++)
            for(int x=0;x<width;x++)   
            {
               if(((y*width)+x)%5==0)
                  fprintf(fp,"\n");
               fprintf(fp,"%i: %li\n ",y*width+x,pData[y*width+x]);
            }
         fclose(fp);
         cout<<"finished"<<endl;


Please suggest where I am doing mistake?

Regards,
Abhishek.


Top
 Profile  
 
PostPosted: Thu, 2012-10-04, 18:12 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1847
Location: Oldenburg, Germany
Please use DiPixel::getRepresentation() in order to determine how the internal pixel data is stored. Do not typecast without checking the internal representation!


Top
 Profile  
 
PostPosted: Tue, 2012-10-09, 17:37 
Offline
DCMTK Developer

Joined: Tue, 2011-05-03, 14:38
Posts: 1847
Location: Oldenburg, Germany
Btw, you could now also use getDoseImage() from the new DRTDose class.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group