[ITK] reading private tags returns weird strings

Francois.GIRINON at ensam.eu Francois.GIRINON at ensam.eu
Wed Aug 10 11:51:22 EDT 2016


Le 10/08/2016 à 17:44, Dženan Zukić a écrit :
For posterity: the value Francois was looking for was a float, and the four bytes 00 80 93 43 indeed encode the float value 295.0

The code to convert to float:
float * fDecoded = (float *)&decoded[0];
std::cout << "float = " << (*fDecoded) << std::endl;

On Wed, Aug 10, 2016 at 10:43 AM, Dženan Zukić <dzenanz at gmail.com<mailto:dzenanz at gmail.com>> wrote:
Can you share (either with the list or just me) this DICOM image (optionally anonymized) and a runnable example which you use to read it?

On Wed, Aug 10, 2016 at 10:41 AM, <Francois.GIRINON at ensam.eu<mailto:Francois.GIRINON at ensam.eu>> wrote:
Le 10/08/2016 à 16:23, Dženan Zukić a écrit :
Does Matlab have special support for those private tags? They may have special encoding besides base64 applied by ITK DICOM dictionary.

On Wed, Aug 10, 2016 at 10:13 AM, <Francois.GIRINON at ensam.eu<mailto:Francois.GIRINON at ensam.eu>> wrote:
Le 10/08/2016 à 16:05, Dženan Zukić a écrit :
In fact, this decodes<http://www.opinionatedgeek.com/dotnet/tools/base64decode/> to 00 80 93 43 - four bytes given here in hexadecimal notation. The decoder you linked does not seem to work correctly. I don't know why you expect 295 there.

On Wed, Aug 10, 2016 at 9:58 AM, <Francois.GIRINON at ensam.eu<mailto:Francois.GIRINON at ensam.eu>> wrote:
Le 10/08/2016 à 14:35, Dženan Zukić a écrit :
Hi Francois,

is this base64 encoded? You should perhaps do base64 decode on the return string to get the binary value.

Regards,
Dženan

On Wed, Aug 10, 2016 at 7:15 AM, <Francois.GIRINON at ensam.eu<mailto:Francois.GIRINON at ensam.eu>> wrote:

Hi,

I'm trying to read private dicom tags using :

    ImageIOType::Pointer dicomIO = ImageIOType::New();
    ...
    dicomIO->SetLoadPrivateTags(true);
    std::string offsetFromBottomStr;

    std::string offsetFromBottom = "0863|1041";
    dicomIO->GetValueFromTag(offsetFromBottom, offsetFromBottomStr);

The value offsetFromBottomStr returned is AICTQw==
How does it come and how can I fix this ?

Thank you,
François.

_______________________________________________
Community mailing list
Community at itk.org<mailto:Community at itk.org>
http://public.kitware.com/mailman/listinfo/community



Thanks for your answer. You might be right, they say here<http://public.kitware.com/pipermail/community/2016-May/011426.html> private tags and encodes the with Base64 into strings.
Unfortunately, AICTQw== should correspond to 295 and according to https://www.base64decode.org/, AICTQw== is a C.
Besides, I don't understand how does itksysBase64_Decode works (I'm not sure I should use this method too).


In fact I have previously red the dicom using matlab and the value of the private tag 0863 1041 is 295.


I don't know, it doesn't seem really matlab specific, this tool<https://github.com/gerddie/ginkgocadx> also gets a dicom inspector module which displays 295.



OK !!! Thank you very much for your help !
So the final solution was:
    int dlen = gdcm::Base64::GetDecodeLength(offsetFromBottomStr.c_str(), offsetFromBottomStr.size() );

    std::string decoded;
    decoded.resize( dlen );
    gdcm::Base64::Decode( &decoded[0], decoded.size(), offsetFromBottomStr.c_str(), offsetFromBottomStr.size() );

    float * fDecoded = (float *)&decoded[0];
    std::cout << "float = " << (*fDecoded) << std::endl;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20160810/2a1591ee/attachment.html>


More information about the Community mailing list