[Dcmlib] failed to read some DICOM files : bug fixed
Mathieu Malaterre
mathieu.malaterre at kitware.com
Tue May 17 21:57:41 CEST 2005
JP,
Pour le commun des mortels, pourquoi exactement on n'arrivais pas a
lire cette image. Je croyais que les DICOM v3 sans entetes ne posaient
pas trop de problemes...
En gros je voudrais savoir pourquoi gdcm ne la considerais pas comme
une ACR/NEMA...
Merci
Mathieu
Jean-Pierre ROUX wrote:
> Hi,
>
>
>
> Hi, Dennis.
>
> I'm cannot commit my fix right now (not on the right compute; I've to
> wait tomorrow morning)
> You can update the source code of "gdcmDocument.cxx" with the following
> lines.
> (you wont have any pb to find the first line " --- End of DicomV3 ---"
>
>
>
> } // ------------------------------- End of DicomV3 ----------------
>
> // Alas, this is not a DicomV3 file and whatever happens there is no file
> // preamble. We can reset the file position indicator to where the data
> // is (i.e. the beginning of the file).
>
> gdcmWarningMacro( "Not a Kosher DICOM Version3 file (no preamble)");
>
> Fp->seekg(0, std::ios::beg);
>
>
> // Let's check 'No Preamble Dicom File' :
> // Should start with group 0x0002
> // Should be Explicit Value Representation
>
>
> s16 = *((uint16_t *)(deb));
> SwapCode = 0;
> switch ( s16 )
> {
> case 0x0002 :
> SwapCode = 1234;
> entCur = deb + 4;
> break;
> case 0x0200 :
> SwapCode = 4321;
> entCur = deb + 6;
> }
>
>
> if ( SwapCode != 0 )
> {
> if( memcmp(entCur, "UL", (size_t)2) == 0 ||
> memcmp(entCur, "OB", (size_t)2) == 0 ||
> memcmp(entCur, "UI", (size_t)2) == 0 ||
> memcmp(entCur, "SH", (size_t)2) == 0 ||
> memcmp(entCur, "AE", (size_t)2) == 0 ||
> memcmp(entCur, "OB", (size_t)2) == 0 )
> {
> Filetype = ExplicitVR;
> gdcmWarningMacro( "Group 0002:Explicit Value Representation");
> return true;
> }
> }
> // ------------------------------- End of 'No Preamble' DicomV3
> -------------
>
> // Our next best chance would be to be considering a 'clean' ACR/NEMA file.
> and so on.
>
> HTH
>
> Jean-Pierre Roux
>
>
> I tried to use GDCM to read some DICOM files, but i can't read it
> because gdcm::File::IsReadable is false.
> However I tried to read it with the other tools such as IrfanView,
> it can be read correctly.
> >From my debugging, I found something is suspicious :
> In gdcmDocument there is a judge statement in function
> Document::FindDocEntryLength( DocEntry *entry ):
>
>
> *if ( Filetype == ExplicitVR && !entry->IsImplicitVR() )
>
>
> *For this DICOM file, Filetype is ACR, entry->IsImplicitVR() is
> true, VR is "UI". so this "if" is false, and then goes to ReadInt32().
> ReadInt32() will return a big number that is not correct. Actually
> it should read ReadInt16.
> >From my point of view, if ( Filetype == ExplicitVR &&
> !entry->IsImplicitVR() ) is too strict. As i read from
> Dicom2004_Part5, ps3.5-7.1.2
> , I think if entry is ExplicitVR and VR is UI, Value Length Field is
> a 16-bit unsigned integer.
> I'm not sure if i'm correct because I don't know what is the
> standard format for ACR.
>
>
> any hints will be helpful,
>
>
> Thx,
>
>
> Dennis
>
> _______________________________________________
> Dcmlib mailing list
> Dcmlib at creatis.insa-lyon.fr
> http://www.creatis.insa-lyon.fr/mailman/listinfo/dcmlib
>
>
> Jean-Pierre ROUX
> CREATIS - CNRS UMR 5515, INSERM U 630
> Laboratoire de Radiologie Experimentale
> Hopital Cardiologique
> 28 Avenue du Doyen LEPINE
> B.P. Lyon-Montchat
> 69394 Lyon Cedex 03
>
>
> Tel : (+33) 04 72 35 74 12
> Fax : (+33) 04 72 68 49 16
> URL : http://www.creatis.univ-lyon1.fr
> e-mail : jpr at creatis.univ-lyon1.fr
>
More information about the Dcmlib
mailing list