Modify DICOM elements without modifying PixelData
8 views (last 30 days)
Show older comments
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 Comments
Yoichi Watanabe
on 29 Jun 2019
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.
Answers (2)
John
on 29 Jul 2014
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 :-).
John
on 30 Jul 2014
You could use the Grass roots dicom tools (GDCM). It is a well documented collection of tools.
0 Comments
See Also
Categories
Find more on DICOM Format in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!