I am trying to create a new DICOM file (instance) from an existing one, where I change the pixel data.
I know that I need to change some of the UIDs while replacing pixel data. Currently I am generating SOPInstanceUID
, MediaStorageSOPInstanceUID
and ReferencedSOPInstanceUID
wherever applicable.
Are there some other UIDs that needs to be changed to get a valid DICOM file? It will be helpful if you can point me where to look for this in the standard.
Following is a quote from specifications discussing about uniqueness of UIDs:
Unique Identifiers (UIDs) provide the capability to uniquely identify a wide variety of items. They guarantee uniqueness across multiple countries, sites, vendors and equipment. Different classes of objects, instance of objects and information entities can be distinguished from one another across the DICOM universe of discourse irrespective of any semantic context.
PS 3.5 2017a - Data Structures and Encoding - 9 Unique Identifiers (UIDs)
If you are changing pixel data (changing compression (transfer syntax) to lossy or overwriting all together), you must change SOP Instance UID (0008,0018)
.
About Media Storage SOP Instance UID (0002,0003)
, as you notice, it belongs to group 2 i.e. File Meta Information header. These tags only present when you serialize the instance to hard disk. This should have same value as that of SOP Instance UID (0008,0018)
. So, if you change one, you should also change other. Please refer to this answer and following part in specifications:
C.12.1.1.1 SOP Class UID, SOP Instance UID
The SOP Class UID and SOP Instance UID Attributes are defined for all DICOM IODs. However, they are only encoded in Composite IODs with the Type equal to 1. See Section C.1.2.3. When encoded they shall be equal to their respective Attributes in the DIMSE Services and the File Meta Information header (see PS3.10 Media Storage).
PS3.3 2021a - Information Object Definitions - C.12.1.1.1
The Referenced SOP Instance UID (0008,1155)
is reference to other instance. It depends whether you need to change this or not based on your case; generally should not be needed. Please refer to this answer for more details about Referenced SOP Instance UID.
The Transfer Syntax UID (0002,0010)
needs to be changed according to the new Transfer Syntax you applied. While overwriting the pixel data, if you are changing it, change the UID accordingly.
The SOP Class UID (0008,0016)
and Media Storage SOP Class UID (0002,0002)
define your SOP Class. By just changing pixel data, you are not changing it. So you do not need to change this UID.
The Implementation Class UID (0002,0012)
is associated with creator. No need to change.
Decision about Study Instance UID (0020,000D)
and Series Instance UID (0020,000E)
depends on your use case. It depends on how you want user to handle your newly created instance. Say, while creating report for Study, many implementations do not change Study IUID but do create new Series (i.e. new Series IUID).
Please refer to following answers for more details:
https://stackoverflow.com/a/46316162/5779732
https://stackoverflow.com/a/53775161/5779732