[Dcmlib] Never trust the programer :)

Jean-Pierre Roux Jean-Pierre.Roux at creatis.insa-lyon.fr
Fri Oct 21 18:12:05 CEST 2005


Mathieu Malaterre wrote:

> Benoit,
>
>     I just added an assert for kick and it is seg faulting. For instance:


Mathieu.

Be carefull with the VM : I added them manualy in our dicomV3.dic.
Nobody used them till now ...

And think of the bozos that produce supposed to be Dicom images.
We coded a lot of heuristics to allow gdcm Reader to go on when a 
duscrepancy is found (dicomV3.dic vs current Dicom Image -being read-)
ex : Pixel Spacing has a VM = 2;
We have images where a single value is found (assume the pixel is square)
We have images where 3 values are found (We know the middle one is 
always 0 ?!?, just ignore it)
If you check too much, you'll have more 'gdcm breaker images'.

VM should be usefull to enforce consistency, no allowing user to *write* 
illegal stuff.
Or inside a checker, that would warn user the image is not kosker.
But *not* hanging gdcm.
IMO...

JPRx

>
>   DataEntry *entry = GetDataEntry(0x0020,0x0032);
>    if( !entry )
>    {
>       gdcmWarningMacro( "Unfound Image Position Patient (0020,0032)");
>       entry = GetDataEntry(0x0020,0x0030);
>       if( !entry )
>       {
>          gdcmWarningMacro( "Unfound Image Position (RET) (0020,0030)");
>          return 0.0f;
>       }
>    }
>
>    if( entry->GetValueCount() == 3 )
>    {
>       gdcmAssertMacro( entry->IsValueCountValid() );
>       return (float)entry->GetValue(0);
>    }
>    return 0.0f;
>
> so if 0x0020,0x0032 is not found, you check 0x0020,0x0030, which is 
> then found. But if it is found THEN you compare entry->GetValueCount() 
> against 3, but how do you know that VM is the same for 0020,0032 and 
> 0020,0030 ?
>
> Anyway this could have been safe, unfortunately 0020,0030 was entered 
> as VM=1 in the dict.
>
> Question: Is this safe to let the programmer use GetValueCount ? Or 
> should we enforce IsValueCountValid ? Maybe an alternative would be to 
> run IsValueCountValid on the whole gdcmData just to see how respectful 
> the DICOM data are to 'our' dict...
>
> Mathieu
> _______________________________________________
> Dcmlib mailing list
> Dcmlib at creatis.insa-lyon.fr
> http://www.creatis.insa-lyon.fr/mailman/listinfo/dcmlib
>




More information about the Dcmlib mailing list