[Insight-users] [GDCM] Can't read easily value of a DataElement

Chr. Rossmanith cr at neuro.ma.uni-heidelberg.de
Fri Mar 23 05:07:49 EDT 2012


In gdcm-2.0.19/Examples/Cxx you find ReadAndPrintAttributes.cxx which 
might help you.

Christina Rossmanith
--
Dept. of Neurology
University Medical Center Mannheim


Am 23.03.2012 09:14, schrieb Daanen:
>
> Hi,
>
> I recently upgrade from itk 3.16 to itk 4.1.
>
> I thus have to update my code source to use the new gdcm core (2.0.x)
>
> Previously, I wrote a method (for internal use) which returns the 
> value of a given Tag as string.
>
> This method now uses a gdcm::DataElement as parameter.
>
> But I can't get the value of the DataElement as a string in all the case.
>
> My code is the following
>
> staticbool GetValue(std::string &p_Str, const gdcm::DataElement &p_Elem)
>
> {
>
>       p_Str.clear();
>
> if (p_Elem.GetByteValue() == NULL) return false;
>
>       p_Str = 
> std::string(p_Elem.GetByteValue()->GetBuffer(),p_Elem.GetByteValue()->GetLength());
>
> return !p_Str.empty();
>
> }
>
> But for a given tag (SamplesPerPixel, which VR = US and Value is 1), 
> p_Str is not "1" but " ". This seems to indicate that
>
> p_Str = 
> std::string(p_Elem.GetByteValue()->GetBuffer(),p_Elem.GetByteValue()->GetLength());
>
> is not the correct way to get the value of a US element in a string !
>
> Is there a way to do want I want in a safe manner (not dependent to VR) ?
>
> Thanks for help
>
> Vincent
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120323/68de2688/attachment.htm>


More information about the Insight-users mailing list