Modify DICOM elements without modifying PixelData

5 次查看(过去 30 天)
I am writing a program that reads in DICOM images, modifies elements of the header so they will be regrouped in our PACS, and writes that back out as a new file. The problem I am encountering is that the writing of the new file causes the pixel data to be recompressed, resulting in a difference from the original. Here's a simple example:
metadata = dicominfo('MyDICOM.dcm');
X = dicomread(metadata);
% Maybe modify some header elements here
dicomwrite(X, 'MyDICOM_new.dcm', metadata, 'createmode', 'copy', 'WritePrivate', true);
X2 = dicomread('MyDICOM_new.dcm');
imshowpair(X, X2, 'diff');
I was expecting the two images to be identical, but they are different (I believe they are JPEG compression differences).
I also tried the dicomanon() function, but it also seems to recompress the image data. In my code I played with changing the new file format to be uncompressed by using a different TransferSyntax, but my multi-frame images exploded in size.
How can I modify DICOM header elements without causing the pixel data to change?
Thank you.
  2 个评论
Yoichi Watanabe
Yoichi Watanabe 2019-6-29
Scott,
you posted your question a long time. Have you found an answer to your question? If so, I want to know the solution. I am having the same issue. I am trying to anonymize Dicom CT data written in 12 bits. thanks.
Scott
Scott 2019-7-2
I never did find a solution within MATLAB. It seems MATLAB decodes the image data when it reads the DICOM file, and then insists on re-encoding it when writing. A solution I explored was using external tools, such as the DCMTK dcmodify tool from OFFIS DCMTK.

请先登录,再进行评论。

回答(2 个)

John
John 2014-7-29
Hi Scott,
MATLAB's Image Processing Toolbox has a superbly decked out DICOM handling component.
I do not have any DICOMs on hand but have had this issue before and found out that using 'dicomwrite' with the 'CompressionMode' name-value pair setting with one of the lossless compression settings worked. The documentation for 2014a has this name-value pair, I am not sure about the earlier releases though.
These days though, with GBs costing pennies, consider using no compression at all :-).
  1 个评论
Scott
Scott 2014-7-30
Thank, John. I appreciate your response. I have tried writing the new DICOM file in an uncompressed format and yes, that does eliminate the introduction of differences between the original and the new. However, it comes at the cost of a much larger size than the original. My desire is to simply modify some of the DICOM header elements without the need to change the PixelData. It's already in a compressed format, I'm not changing it, I just want MATLAB to reinject it intact.
I hear what you are saying about storage costs being low, but I'm also dealing with an antiquated PACS that's on its way out. I'd rather not throw gigabyte images at it in bulk.

请先登录,再进行评论。


John
John 2014-7-30
You could use the Grass roots dicom tools (GDCM). It is a well documented collection of tools.

类别

Help CenterFile Exchange 中查找有关 DICOM Format 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by