<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial,helvetica,sans-serif;font-size:10pt">&gt;<div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;">&gt; I used the example DicomImageReadChangeHeaderWrite.cxx to change the dicom file,when I wrote it as followed:<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  std::string entryId( "0002|0003" );<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  std::string value( "1.2.86.755.4.2.2.24.1.3.201");<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; itk::EncapsulateMetaData&lt;std::string&gt;( dictionary, entryId, value );<br>&gt;and the result is "(0002|0003) Media Storage SOP Instance UID = 1.2.826.0.1.3680043.2.1143.68351427<br>&gt;608.2009050811121070158". Why? How can I change it ?Could anyone help me ?thanks.<br> <br>The underlying
 GDCM library bundled with ITK overwrites this element with a UID it generates. You have to walk the code and you will find in Utilities/gdcm/gdcmFileHelper.cxx-&gt;CheckMandatoryElements():<br><br>&nbsp; :<br>std::string sop =&nbsp; Util::CreateUniqueUID();<br>&nbsp; :<br>CopyMandatoryEntry(0x0002,0x0003,sop);<br>CheckMandatoryEntry(0x0008,0x0018,sop);<br>&nbsp; :<br><br>This overwrites your value.<br><br> If it was made CheckMandatoryEntry(0x0002,0x0003,sop), that would solve your issue.<br><br>Also, the code as is allows the two SOP Instance UIDs to be different when they should be the same.<br><br>Todd Jensen<br></div></div></div></body></html>