Modify DICOM elements without modifying PixelData

11 visualizzazioni (ultimi 30 giorni)
Scott
Scott il 29 Lug 2014
Commentato: Scott il 2 Lug 2019
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 Commenti
Yoichi Watanabe
Yoichi Watanabe il 29 Giu 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.
Scott
Scott il 2 Lug 2019
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.

Accedi per commentare.

Risposte (2)

John
John il 29 Lug 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 :-).
  1 Commento
Scott
Scott il 30 Lug 2014
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.

Accedi per commentare.


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

Categorie

Scopri di più su DICOM Format in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by