[Insight-developers] GDCM IO and metadata copying

Mathieu Malaterre mathieu.malaterre at kitware.com
Mon Nov 8 10:36:11 EST 2004


Peter,

	You are perfectly right, the SQ DICOM tag was not handled properly. 
I'll commit your patch ASAP.

Thanks
Mathieu
Ps: what's 'synamic_cast' ;)

Peter Cech wrote:
> Hi,
> 
> when GDCM IO is copying metadata from image, it does not distinguish
> between simple tags and sequence of tags. As a consequence, it segfaults
> when reading DICOM file with sequence tag. You can grab such a file from
> http://www.vision.ee.ethz.ch/~pcech/bugreports/ITK-20041108/
> 
> Attached patch contains a workaround. It will skip all tag sequences.  
> I suspect that the proper fix would require more than just copy all tags
> from sequence, so I better leave it to someone with better knowledge of
> DICOM format.
> 
> Regards,
> 
> Peter Cech
> 
> 
> ------------------------------------------------------------------------
> 
> --- Insight/Code/IO/itkGDCMImageIO.cxx	2004-11-03 10:57:29.000000000 +0100
> +++ Insight-modified/Code/IO/itkGDCMImageIO.cxx	2004-11-06 10:45:26.040344296 +0100
> @@ -293,10 +293,14 @@
>      // Do not copy field from private (unknown) dictionary.
>      // In the longer term we might want to (but we need the Private dictionary
>      // from manufacturer)
> +    if (tag->second->GetVR().find("SQ") == 0) {
> +      // skip sequence, otherwise following cast will crash
> +      continue;  
> +    }
>  #if GDCM_MAJOR_VERSION == 0 && GDCM_MINOR_VERSION <= 5
> -    std::string temp = ((gdcmValEntry*)(tag->second))->GetValue();
> +    std::string temp = synamic_cast<gdcmValEntry*>(tag->second)->GetValue();
>  #else
> -    std::string temp = ((gdcm::ValEntry*)(tag->second))->GetValue();
> +    std::string temp = dynamic_cast<gdcm::ValEntry*>(tag->second)->GetValue();
>  #endif
>      if( tag->second->GetName() != "unkn" 
>       && temp.find( "gdcm::NotLoaded" ) != 0
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Insight-developers mailing list
> Insight-developers at itk.org
> http://www.itk.org/mailman/listinfo/insight-developers





More information about the Insight-developers mailing list