This is the appropriate behavior for the DICOMWRITE function. The UID in SOPInstanceUID stands for "unique identifier". When DICOMWRITE is used to input new image data to a DICOM file, the new file should contain a different UID than the original file, even when other metadata is copied.
There is a workaround which requires modifying an MATLAB file in the Image Processing Toolbox. The steps are as follows:
1. Change the MATLAB working directory to $MATLABROOT\toolbox\images\images\private, where $MATLABROOT is the MATLAB root directory.
2. At the MATLAB command line, enter the following:
edit dicom_prep_SOPCommon
3. Comment out the following line:
metadata.(dicom_name_lookup('0008', '0018')) = dicomuid;
This workaround prevents a new UID from being generated for the created DICOMATLAB file.
Best Answer