[Insight-users] DICOM Tags From One Slice

Luis Ibanez luis.ibanez at kitware.com
Wed Aug 30 13:08:21 EDT 2006


Hi 肖 潇

If the iterator becomes null after the first increment
in the loop, that means that the Dictionary is empty.

Please check how you are getting the dictionary from
the input image. E.g. make sure that you are calling
first the Update() of the series reader.

Please use the source code provided in

     Insight/Examples/IO/
         DicomImageReadPrintTags.cxx


The examples in this directory are the ones presented
in the ITK Software Guide.


  Regards,


     Luis


------------------
肖 潇 wrote:
> Thanks very much for your help.
> 
> I am sorry that I didn't explain the situation clearly.
> 
> I didn't do while loop twice, only one /while/ here.
> 
> it was in the very same while loop
> 
> after the first ++itr; the itr began to point to null.
> 
> even I do nothing except change ++itr into itr++ can also cause this 
> problem.
> 
> 
> 
>     ------------------------------------------------------------------------
>     From:  /Luis Ibanez <luis.ibanez at kitware.com>/
>     To:  /肖 潇 <rosemarylrm at hotmail.com>/
>     CC:  /insight-users at itk.org/
>     Subject:  /Re: [Insight-users] DICOM Tags From One Slice/
>     Date:  /Mon, 28 Aug 2006 12:09:45 -0400/
>      >
>      >
>      >Hi 肖 潇
>      >
>      >If you are reusing an iterator for a second loop,
>      >you *must* reinitialize the iterator to be at the
>      >"begin()" of the container.
>      >
>      >
>      >Your code should look like:
>      >
>      >
>      >   // First loop
>      >   DictionaryType::ConstIterator itr = dictionary.Begin();
>      >   DictionaryType::ConstIterator end = dictionary.End();
>      >
>      >   while( itr != end )
>      >    {
>      >    // do stuff with "itr"
>      >    ++itr;
>      >    }
>      >
>      >
>      >   itr = dictionary.Begin(); // THIS IS WHAT YOU ARE MISSING
>      >
>      >
>      >   // Second loop
>      >   while( itr != end )
>      >    {
>      >    // do stuff with "itr"
>      >    ++itr;
>      >    }
>      >
>      >
>      >
>      >   Regards,
>      >
>      >
>      >
>      >      Luis
>      >
>      >
>      >====================
>      > 肖 潇 wrote:
>      > > Hi,
>      > >
>      > > I have a problem while editing my code with VC6.0 in WindowsXP.
>      > >
>      > > I was following the example which is in ItkSoftwareGuide-2.6.0.pdf,
>      > > Chapter 7.12.5 Printing DICOM Tags From One Slice.(Page 305)
>      > >
>      > > When it run into the while loop for the first time, everything was
>      > > perfect. However,after ++itr; run into the while for the second
>     loop,
>      > > the cursor run to this line: /MetaDataStringType::Pointer
>     entryvalue
>      > > =dynamic_cast<MetaDataStringType *>( entry.GetPointer() ) ; /
>      > >
>      > > then it was caught by the
>      > >
>      > > /catch (...) {
>      > >         CHKExceptionProcess::GetHKExc()->Execute
>      > > ("CHKReader_Dicom::ReadFile() Error ! ");
>      > >         return -1;
>      > >  }/
>      > >
>      > > in order to find out what was wrong, I changed the code as follows,
>      > >
>      > > /....../
>      > >
>      > > /itr++;/
>      > >
>      > > ///while( itr != end )//{
>      > > itk::MetaDataObjectBase::Pointer entry = itr->second;
>      > > MetaDataStringType::Pointer entryvalue =
>      > > dynamic_cast<MetaDataStringType *>( entry.GetPointer() ) ;/
>      > >
>      > > /....../
>      > >
>      > > ///++itr;/
>      > >
>      > > ///}/
>      > >
>      > > Again, when it run to dynamic_cast, the exception  came out as
>     the same.
>      > >
>      > > I wonder to know how to fix in this case. Is it the smart point
>     or the
>      > > const_iterator which I am in wrong use? or the operator++, or the
>      > > dynamic_cast cause this problem?
>      > >
>      > > I have included the needed headfiles, perhaps is not this reason.
>      > >
>      > > Longing for some kind people to reply.
>      > >
>      > >
>      > >
>      > >
>     ------------------------------------------------------------------------
>      > > 免费下载 MSN Explorer <http://g.msn.com/8HMACNCN/2740??PS=47575>
>      > >
>      > >
>      > >
>     ------------------------------------------------------------------------
>      > >
>      > > _______________________________________________
>      > > Insight-users mailing list
>      > > Insight-users at itk.org
>      > > http://www.itk.org/mailman/listinfo/insight-users
>      >
>      >
> 
> 
> ------------------------------------------------------------------------
> 免费下载 MSN Explorer <http://g.msn.com/8HMBCNCN/2746??PS=47575> Get 2 
> months FREE*.




More information about the Insight-users mailing list