Pixel data not being read properly in DicomImage::getInterData()

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
benpark
Posts: 4
Joined: Mon, 2019-04-01, 07:58
Location: Canada

Pixel data not being read properly in DicomImage::getInterData()

#1 Post by benpark »

Hello,

I have an MR image with the following tags:

Code: Select all

...
(0028,0100)  BitsAllocated: 16
(0028,0101)  BitsStored: 16
(0028,0102)  HighBit: 15
(0028,0103)  PixelRepresentation: 0
(0028,0106)  SmallestImagePixelValue: 40
(0028,0107)  LargestImagePixelValue: 4079
...
(0040,9211)  RealWorldValueLastValueMapped: 4095
(0040,9216)  RealWorldValueFirstValueMapped: 0
...
For this particular file, when I try to access raw pixel data using DicomImage::getInterData(), DiPixel::getRepresentation() returns EPR_Sint16 instead of EPR_Uint16. (First problem)

Even if I force conversion to (EPR_Uint16*)DiMonoPixelTemplate::getData(), it seems DiMonoPixelTemplate::getData() does not read the proper amount of bits.
Considering (0028, 0107) LargestImagePixelValue, I was assuming original data would have 12 unsigned bits stored and 4 bits padded to 0. But getData() returns minimum value of 0 and maximum value of 65535. (Second problem)

If I read using getOutputData(), everything works fine. But I have to use getInterData() to avoid rendering, since I use it for calculating SI.

Not sure if it is related, but the following values were set under DiMonoPixel::Modality at the time of access.

Code: Select all

...
Representation: EPR_Sint16 (3)
MinValue: -3080.6178...
MaxValue: 3117.4457...
Bits: 13
UsedBits: 13
...
I have attached the DICOM file below:
https://drive.google.com/file/d/1cSMHk_ ... sp=sharing

Would this be a problem with the file itself or getInterData()? Any input would be very helpful.
Thanks for your time!!

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Pixel data not being read properly in DicomImage::getInterData()

#2 Post by J. Riesmeier »

By default, the Modality LUT transformation is applied to the stored pixel data, which is specified by the following element values:

Code: Select all

(0028,1052) DS [-3142]                                  #   6, 1 RescaleIntercept
(0028,1053) DS [1.534554]                               #   8, 1 RescaleSlope
This is also the reason why the minimum value is negative.

Bottom line: the result of calling getInterData() is correct.

benpark
Posts: 4
Joined: Mon, 2019-04-01, 07:58
Location: Canada

Re: Pixel data not being read properly in DicomImage::getInterData()

#3 Post by benpark »

Hi J. Riesmeier,

It is much more clear now. I had originally thought getInterData() would return raw data without applying Rescale Intercept/Slope.
If I remove (0028,1052) Rescale Intercept, (0028,1053) Rescale Slope, (0028,1054) Rescale Type, SI values are closer to what we would expect.
Thanks for the quick reply!

Regards,
Ben

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Pixel data not being read properly in DicomImage::getInterData()

#4 Post by J. Riesmeier »

You could, of course, also pass the flag CIF_IgnoreModalityTransformation to the constructor of the DicomImage class.

benpark
Posts: 4
Joined: Mon, 2019-04-01, 07:58
Location: Canada

Re: Pixel data not being read properly in DicomImage::getInterData()

#5 Post by benpark »

Thanks for the flag :)
Also another question regarding Modality LUT application: does DicomImage apply Rescale Slope/Intercept to Enhanced CT/MR objects in v3.6.4?
We are currently using v3.6.0 and so far we had to apply it manually after getInterData(). We are looking to upgrade and wondering if this behaviour has changed in recent versions.

Regards,
Ben

J. Riesmeier
DCMTK Developer
Posts: 2501
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Pixel data not being read properly in DicomImage::getInterData()

#6 Post by J. Riesmeier »

Yes, DCMTK 3.6.4 supports retrieving the value of Rescale Slope/Intercept from the Shared Functional Groups Sequence (if this was the question): http://git.dcmtk.org/?p=dcmtk.git;a=commit;h=636f1d70

benpark
Posts: 4
Joined: Mon, 2019-04-01, 07:58
Location: Canada

Re: Pixel data not being read properly in DicomImage::getInterData()

#7 Post by benpark »

Thanks, that was indeed my question.

Regards,
Ben

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 1 guest