Ignore corrupted tags when writing DICOM file

6 次查看(过去 30 天)
We have a pipeline which reads in DICOM files, applies an image mask, and writes them back out. Occasionally, DICOM files have erased or changed VR for which which are irrelevant to us - for example, (0040,9210) LUT Label. The DICOMs are read fine, but when saving back out with the header, this causes an error:
dicomwrite(int16(Image),TargetPath,METADATA,'CreateMode','Copy','WritePrivate',true,'MediaStorageSOPInstanceUID',METADATA.MediaStorageSOPInstanceUID,'SOPInstanceUID',METADATA.SOPInstanceUID);
Cannot write dicom ROIs for report. Attribute (0040,9210) has wrong data type.
Deleting this tag would solve the problem, but across different cases we see a variety of tags with apparently corrupted VR's. Is there a general way to ignore this error? Since dicomread has no problem injesting the data, dicomwrite should be able to write it 'as is'.
  2 个评论
Simon Chan
Simon Chan 2022-1-27
Did you modify the header before writing it back to the DICOM file?
Each attribute has its own Value Representation, such as Short String for (0040,9210). It would reports wrong data type if you modify it to some other data type and then use function dicomwrite.
I am able to reproduce a similar error if I change the DeviceSerialNumber from its Long String data type '123456' to a number 123456.
Error using dicom_add_attr>validate_data (line 122)
Attribute (0018,1000) has wrong data type.
Bogdan Dzyubak
Bogdan Dzyubak 2022-1-27
I have not modified the specific tag that is causing a problem. It is included inside an SQ structure tag which was likely added by someone in post processing. Since Matlab does not crash trying to dicomread this structure, it seems like it should be able to dicomwrite it as well.

请先登录,再进行评论。

回答(0 个)

类别

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

标签

产品


版本

R2014b

Community Treasure Hunt

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

Start Hunting!

Translated by