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

Mathieu Malaterre mathieu.malaterre at gmail.com
Tue Jun 10 03:28:05 EDT 2008


FYIing insight-users

On Tue, Jun 10, 2008 at 12:44 AM, Sachin Jambawalikar
<sachinjam at gmail.com> wrote:
> Hi Mathieu,
>
> Thanks again i was using a 2 month old cvs version.
> I just  updated my itk to latest cvs (which has your patch for Image
> position patient and IOP ) things seem to work fine.
>
> Also  gdcm::Util::CreateUniqueUID() seem to be working fine now
> without requiring any time delay (seems to be using   micorsoft visual
> studio's uuids.h).
>
> Thanks again for all your help
>
> Regards
> --Sachin
>
> On Mon, Jun 9, 2008 at 4:39 PM, Mathieu Malaterre
> <mathieu.malaterre at gmail.com> wrote:
>> 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
>>
>



-- 
Mathieu


More information about the Insight-users mailing list