Dicomwrite error with metadata validation

I am trying to alter an image and then write it back to .dcm format with its original header metadata. This is an RT image radiograph file (meaning it has structure contour data included in the header attributes (50xx,3000)). Using dicomwrite, I get the error: "Error using dicom_add_attr>validate_data (line 122) Attribute (5000,3000) has wrong data type."
I have done nothing to the header data besides read it directly from the original dicom file. I need to write this image back to dicom with its header intact. Are there any options to ignore discrepancies in Matlab's validation?
Here is a test that produces the error: >>img = dicomread('RI.Field 1.dcm'); >>hdr = dicominfo('RI.Field 1.dcm'); >>dicomwrite(img,'file.dcm',hdr,'CreateMode','copy');
[release 2018a]

 採用された回答

John Mullins
John Mullins 2018 年 7 月 19 日

0 投票

The dicominfo function was creating the structure data as type double in the Matlab workspace. Convert each structure to uint16 before passing the metadata to dicomwrite.

5 件のコメント

Javier Sanchez Ruiperez
Javier Sanchez Ruiperez 2020 年 10 月 1 日
Hi!
I have the same problem but i don't know how to convert structure to uint. Could you help me? I am trying to modify a DICOM tag.
Thank you
John Mullins
John Mullins 2020 年 10 月 1 日
uint16(X)
Javier Sanchez Ruiperez
Javier Sanchez Ruiperez 2020 年 10 月 1 日
Thanks for your help! I have try it but it doesn't work, i don't know why....
This is my code:
[NombreArchivo1,RutaArchivo1,FilterIndex] = uigetfile('*.dcm','Selecciona las imágenes a analizar','Multiselect','off');
info1 = dicominfo ((NombreArchivo1));
read1 = dicomread(NombreArchivo1);
ReferencedRTPlanSequence = uint16(info1.ReferencedRTPlanSequence.Item_1.ReferencedSOPInstanceUID);
NReferencedRTPlanSequence =uint16('1.2.246.352.71.5.987333972159.266828.20200624091240');
info1.ReferencedRTPlanSequence.Item_1.ReferencedSOPInstanceUID = NReferencedRTPlanSequence;
dicomwrite(read1,strcat('C:\Users\Usuario\Desktop\'),info1, 'CreateMode','Copy');
end
Javier Sanchez Ruiperez
Javier Sanchez Ruiperez 2020 年 10 月 1 日
Thanks for your help.
Javier Sanchez Ruiperez
Javier Sanchez Ruiperez 2020 年 10 月 10 日
HI! Could you help me please? I have always the same error and i don't know how to solve it

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by