Unable to read pixel data from RT Dose file.
Moderator: Moderator Team
-
- Posts: 12
- Joined: Fri, 2010-06-18, 06:14
Unable to read pixel data from RT Dose file.
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
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
-
- DCMTK Developer
- Posts: 2548
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: Unable to read pixel data from RT Dose file.
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 ...
-
- Posts: 12
- Joined: Fri, 2010-06-18, 06:14
Re: Unable to read pixel data from RT Dose file.
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?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 ...
-
- DCMTK Developer
- Posts: 2548
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: Unable to read pixel data from RT Dose file.
You should check the return value of dcmDataDict.isDictionaryLoaded() as all DCMTK command line tools do.
-
- Posts: 12
- Joined: Fri, 2010-06-18, 06:14
Re: Unable to read pixel data from RT Dose file.
Yes, data dictionary is getting loaded.J. Riesmeier wrote:You should check the return value of dcmDataDict.isDictionaryLoaded() as all DCMTK command line tools do.
-
- DCMTK Developer
- Posts: 2548
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: Unable to read pixel data from RT Dose file.
And what is the status code returned by the findAndGetUint16Array() call?
-
- Posts: 12
- Joined: Fri, 2010-06-18, 06:14
Re: Unable to read pixel data from RT Dose file.
These are values from OFCondtion:J. Riesmeier wrote:And what is the status code returned by the findAndGetUint16Array() call?
theCode: 0
theStatus: OF_ok
theText: Normal
-
- DCMTK Developer
- Posts: 2548
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: Unable to read pixel data from RT Dose file.
Then everything is ok. Btw, the PixelData element value starts with zeros (0)
-
- Posts: 12
- Joined: Fri, 2010-06-18, 06:14
Re: Unable to read pixel data from RT Dose file.
Oh, does this mean. If pixel data starts with 0, it wont display in visual studio debugger?J. Riesmeier wrote:Then everything is ok. Btw, the PixelData element value starts with zeros (0)
I, just ran a loop on pixelData16 and I can see pixel values. Thanks.
-
- Posts: 12
- Joined: Fri, 2010-06-18, 06:14
Re: Unable to read pixel data from RT Dose file.
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.abhishek_gupta wrote:Oh, does this mean. If pixel data starts with 0, it wont display in visual studio debugger?J. Riesmeier wrote:Then everything is ok. Btw, the PixelData element value starts with zeros (0)
I, just ran a loop on pixelData16 and I can see pixel values. Thanks.
-
- DCMTK Developer
- Posts: 2548
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: Unable to read pixel data from RT Dose file.
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 ...
-
- Posts: 12
- Joined: Fri, 2010-06-18, 06:14
Re: Unable to read pixel data from RT Dose file.
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.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 ...
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: Select all
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;
Regards,
Abhishek.
-
- DCMTK Developer
- Posts: 2548
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: Unable to read pixel data from RT Dose file.
Please use DiPixel::getRepresentation() in order to determine how the internal pixel data is stored. Do not typecast without checking the internal representation!
-
- DCMTK Developer
- Posts: 2548
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: Unable to read pixel data from RT Dose file.
Btw, you could now also use getDoseImage() from the new DRTDose class.
Who is online
Users browsing this forum: No registered users and 1 guest