[Insight-users] How to read a dicom series and write it as a new series??

Mathieu Malaterre mathieu.malaterre at gmail.com
Mon Jun 9 16:39:43 EDT 2008


Hi Sachin,

On Mon, Jun 9, 2008 at 9:00 PM, Sachin Jambawalikar <sachinjam at gmail.com> wrote:
> Hi Mathieu,
>
> Thanks for your reply.
> I looked into the dicom tags to see why the dicom viewers  didnot read
> some of the dicom files (for example only 153 of 160 generated files)
> generated
> keeping the gdcmIO->KeepOriginalUIDOn(). This is because some files
> get the same SOPInstance UID.
> I use  the following code to generate new instance UID's
>
>  ReaderType::DictionaryArrayType outputArray;
>
>
>  ReaderType::DictionaryRawPointer dict = new ReaderType::DictionaryType;
>
> for (int i=0;i<numfiles;i++)
> {
> std::string sopInstanceUID =
> gdcm::Util::CreateUniqueUID(gdcmIO->GetUIDPrefix());
>  itk::EncapsulateMetaData<std::string>(*dict,"0008|0018", sopInstanceUID);
>   itk::EncapsulateMetaData<std::string>(*dict,"0002|0003", sopInstanceUID);
>
> ....
>
> outputArray.pushback();
> }
>
>
> The problem is  the for loop is faster than the time resolution gdcm
> uses to generate new uid and as a result some of the SOPinstance uids
> are repeated.
> When I used the C++ clock() function in the loop to wait for 30
> milliseconds correct (unique) UID's were generated and everything
> worked fine.

Just to clarfiy things, this used to be a bug in the previous
implementation of gdcm::Util::CreateUniqueUID. I fixed this issue two
weeks ago, by replacing my crude UUID implementation with one from a
third party libary. On *nix system this is libuuid, and on windows
this is UUIDCreate.
Check you system for the presence of uuid.h and libuuid.so, if so
cmake should discover them, and use them. On a debian system you
should do:

  sudo apt-get install uuid-dev

HTH,
-- 
Mathieu


More information about the Insight-users mailing list