[Insight-users] Bugs (maybe) in itkDicomImageIO.cxx and questions
Alberto Bert
abert@mauriziano.it
Wed, 30 Oct 2002 09:51:18 +0100
Hi,
I'm really interested in your work on reading DICOM images from separate
files. I need to do that and I don't wont to re-invent something already
done. Please keep me informed.
Alberto
On ott 22 at 02:38-0400, Mark Foskey wrote:
> There are definitely problems with this file. I am in the process of
> adding the key you mentioned as a step towards reading a directory full
> of slices into a single 3D image. A am also cleaning up some
> infelicities in the code, including the unfreed memory.
>
> Streams are automatically closed by their destructors, when they go out
> of scope.
>
> This has been on my plate for some time. Thanks for handing me a fork.
>
> Feng Ma wrote:
> >Hi,
> >
> > I worked a little bit with file itkDicomImageIO.cxx to read CT dicom
> >files. I found a few place that are possibly bugs.
> >
> > 1. In method CanReadFile(), inputStream is not closed. Nor is it closed
> >in CheckTagTable(). I am not experienced in C++. Does an open stream
> >need not to be closed?
> >
> > 2. In method ReadImageInformation(), array value, spac1value,
> >spac2value are not freed in the end of this method. inFile stream is not
> >closed.
> >
> >
> > Below are my questions.
> >
> > 1. Dicom header size. I printed out m_InputPosition, which is supposed
> >to be the dicom header size. I read one image and got the header size
> >2522 (which is a 512x512 2 bytes CT image, file size 526812). this
> >number is different from what I got from commecial merge library. The
> >mergelib number is 2524 which is closer to the guess
> >526812-512x512x2=2524. This happens in many files. Is the header size
> >reported by itkDicomImageIO class possibly wrong?
> >
> > 2. Unable to read image position tag (0x0020 0x0032). This tag is very
> >important to determine the z-value of the dicom image in a volume. When
> >I add a segment of code to read this tag, method GoToTag() simply can
> >not find it. I posted my code segment here. The last few lines in the
> >posted method CheckTagTable() is what I added. I did rewind the file
> >pointer before call GoToTag(). What's could be wrong?
> >
> >Btw, my ITK version is Oct 7 CVS version.
> >
> >Thank you very much.
> >
> >-Feng
> >
> >**** Run output ****
> >fma@ctreg1:/r2net/space_fma1/vhds/test 728 %
> >../../Devel/ITKDebug/bin/DicomImageViewer
> >/r2net/space_fma2/data/LV00000500/LV00000500_152.dcm
> >Loading File: /r2net/space_fma2/data/LV00000500/LV00000500_152.dcm
> >Can not locate position tag 0x0020 0x0032
> >Header Size: 2522
> >...Done Loading File
> >
> >**** Code segment of CheckTagTable() ****
> >
> >bool DicomImageIO::CheckTagTable(std::ifstream & inputStream,std::list
> ><Tag> &TableOfTags) const
> >{
> > long int i, j;
> > long int max;
> > Tag tagcurrent;
> > unsigned char c;
> > char chaine[4];
> >
> > i=0;
> > //0x7FE0 and 0x0010 is the last tag before data pixel
> > if(!DicomImageIO::GoToTheEndOfHeader(inputStream,i,tagcurrent))
> > {
> > return (false);
> > }
> > else
> > {
> > TableOfTags.push_back(tagcurrent);
> > max=i;
> > //start the reading of the Stream from the begining
> > inputStream.seekg(0);
> > i=0;
> > }
> >
> > ////0x0028 and 0x0010 >> tag before the number of rows
> > if(!DicomImageIO::GoToTag(inputStream,0x0028,0x0010,i,max,tagcurrent))
> > {
> > return false;
> > }
> > else
> > {
> > TableOfTags.push_back(tagcurrent);
> > }
> >
> > //0x0028 and 0x0011 >> tag before the number of columns
> > if(!DicomImageIO::GoToTag(inputStream,0x0028,0x0011,i,max,tagcurrent))
> > {
> > return false;
> > }
> > else
> > {
> > TableOfTags.push_back(tagcurrent);
> > }
> >
> > //0x0028 and 0x0030 >> tag before each the value of spacing
> > if(!DicomImageIO::GoToTag(inputStream,0x0028,0x0030,i,max,tagcurrent))
> > {
> > //if there is no information about the spacing, we set the value
> >compt to 0
> > tagcurrent.Balise1[1]=0x28;
> > tagcurrent.Balise1[0]=0x00;
> > tagcurrent.Balise2[1]=0x30;
> > tagcurrent.Balise2[0]=0x0;
> > tagcurrent.compt=0; //
> > TableOfTags.push_back(tagcurrent);
> > //start the reading of the Stream from the begining
> > inputStream.seekg(0);
> > i=0;
> > }
> > else
> > {
> > TableOfTags.push_back(tagcurrent);
> > }
> >
> > //0x0028 and 0x0100 >> tag before the number of bits allocated
> > if(!DicomImageIO::GoToTag(inputStream,0x0028,0x0100,i,max,tagcurrent))
> > {
> > return false;
> > }
> > else
> > {
> > TableOfTags.push_back(tagcurrent);
> > }
> >
> > //0x0028 and 0x0103 >> tag before the place of sample representation
> > if(!DicomImageIO::GoToTag(inputStream,0x0028,0x0103,i,max,tagcurrent))
> > {
> > return false;
> > }
> > else
> > {
> > TableOfTags.push_back(tagcurrent);
> > }
> >
> > i = 0;
> > inputStream.seekg(0);
> > ////0x0020 and 0x0032 >> tag before value of position
> > if(DicomImageIO::GoToTag( inputStream,0x0020,0x0032,
> > i,max,tagcurrent)){
> > std::cout << "Position tag located.\n";
> > }
> > else
> > std::cout << "Can not locate position tag 0x0020 0x0032\n";
> >
> > return(true);
> >}
> >
> >
> >
> >
> >
> >_________________________________________________________________
> >Get faster connections -- switch to MSN Internet Access!
> >http://resourcecenter.msn.com/access/plans/default.asp
> >
> >_______________________________________________
> >Insight-users mailing list
> >Insight-users@public.kitware.com
> >http://public.kitware.com/mailman/listinfo/insight-user
> >s
>
> --
> Mark Foskey (919) 843-5436 Computer-Aided Diagnosis and Display Lab
> mark_foskey@unc.edu Department of Radiology, CB 7515, UNC
> http://www.cs.unc.edu/~foskey Chapel Hill, NC 27599-7515
>
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users