generate new UID

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
gnchen
Posts: 14
Joined: Tue, 2006-04-11, 18:00

generate new UID

#1 Post by gnchen »

Hi!

I need to create a new series from a study. So, I need to generate new UID for that series. Is there any binary in the current release which can be used for this??

Gen

Michael Onken
DCMTK Developer
Posts: 2049
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

#2 Post by Michael Onken »

Hi Gen,

there is no ready-to-use binary in DCMTK, that allows generation of a UID. You can write your own like this:

Code: Select all

#include "dcmtk/config/osconfig.h"    /* make sure OS specific configuration is included first */

#include "dcmtk/dcmdata/dcuid.h"
#include "dcmtk/ofstd/ofstream.h"


int main(int /*argc*/, char * /*argv*/ [])
{
    char uid[100];
    cout << "Series Instance UID : " << dcmGenerateUniqueIdentifier(uid, SITE_SERIES_UID_ROOT) << endl;
    return( 0 );
}
Then you are using the OFFIS UID root to generate a new series UID. If you don't like this, you've got to change the UID root constant in DCMTK.

Regards,
Michael

gnchen
Posts: 14
Joined: Tue, 2006-04-11, 18:00

#3 Post by gnchen »

Thanks! Michael,

And where is the OFFIS UID root? If I don't change that, is it possible someone will generate the same UID as I did? How can I make sure it is unique?

Gen

Michael Onken
DCMTK Developer
Posts: 2049
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

#4 Post by Michael Onken »

You could get your own UID root from a national institution in your country, in Germany it's the "DIN". But you have to pay for this some money per year. You can use the OFFIS UID root, it's very improbable, that somebody generates the same UID then. The DCMTK appends to this UID root different system and time specific numbers. Best is, if you leave it as it is.

Regards,
Michael

gnchen
Posts: 14
Joined: Tue, 2006-04-11, 18:00

#5 Post by gnchen »

Thanks! Michael

Alexander Fedotov
Posts: 53
Joined: Thu, 2005-04-14, 15:07
Location: St. Petersburg, Russia

#6 Post by Alexander Fedotov »

[quote]

You could get your own UID root from a national institution in your country, in Germany it's the "DIN". But you have to pay for this some money per year.
[/quote]

I got UID root gratis from
Dave Harvey [dave@medicalconnections.co.uk]

Alexander.
Last edited by Alexander Fedotov on Mon, 2006-04-24, 15:38, edited 1 time in total.

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1444
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

#7 Post by Marco Eichelberg »

Even if you continue to use the OFFIS UID root, while there is no guarantee that nobody else in the world will ever generate the same UID as your tool does, the probability is VERY low. We have put much effort in making the UID generation algorithm as good as possible. The UIDs contain a timestamp and a 32-bit "hostid" which on Windows systems is constructed as a checksum over various system features such as the MAC address of the first ethernet adapter. Only if the hostid happens to collide on two systems (probability 2^-32) and these systems happen to generate UIDs in the same second within processes using the same process ID, a collision is possible. The other thing to note is, if you use a UID root different from the OFFIS UID root, make sure that it is not longer than the OFFIS UID root because otherwise the generation algorithm could create UIDs longer than 64 characters, which is illegal. If I remember correctly, the dcmGenerateUniqueIdentifier() would in this case simply "cut" the UID to 64 chars, but then you might end up with real collisions.

Post Reply

Who is online

Users browsing this forum: Google [Bot], Semrush [Bot] and 1 guest