ImagingDataCommons / highdicom

High-level DICOM abstractions for the Python programming language
https://highdicom.readthedocs.io
MIT License
168 stars 35 forks source link

Add factory method to construct UID from UUID #176

Closed hackermd closed 2 years ago

hackermd commented 2 years ago

Curious about why the UID suffixes generated by pydicom are insufficient

What do you mean?

CPBridge commented 2 years ago

What's lacking in the existing default constructor UID(), which uses pydicom to generate the suffix, such that this is useful?

hackermd commented 2 years ago

You cannot just pass a UUID string to the constructor of UID. The generate_uid() function will internally generate a UUID if prefix=None. However, if you already have a UUID and you want to use that (instead of a new, randomly generated one), you need to construct the UID yourself. That's what this factory method does.

CPBridge commented 2 years ago

I suppose... Not something that I'd ever thought of doing

hackermd commented 2 years ago

For example, when converting annotations that have been stored in a database into DICOM format, the existing data may be associated with identifiers in form of UUIDs. It may then be desirable to "re-use" these identifiers in the resulting DICOM objects.