Dicom write error RImage

5 ビュー (過去 30 日間)
Javier Sanchez Ruiperez
Javier Sanchez Ruiperez 2020 年 10 月 7 日
コメント済み: jorge bojorquez 2020 年 11 月 25 日
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');
I have read that the solution is Convert each structure to uint16 before passing the metadata to dicomwrite but i don't know how to do it.
  1 件のコメント
jorge bojorquez
jorge bojorquez 2020 年 11 月 25 日
1) You need to identify the error:
Error using dicom_add_attr>validate_data (line 122): Attribute (5000,3000) has wrong data type.
In the case, it is attribute (5000, 3000).
2) Look for this attribute (Dicom tag) in your structure: Atribute (5000,3000) = hdr.CurveData_0
Just google "Dicom 5000,3000" because It seems that matlab does not show the dicom tags (e.g. 5000,3000)
For this case, it is expecting a uint16 and it is a double:
3) So, you need to change this attribute to uint16.
hdr.CurveData_0 = uint16(hdr.CurveData_0)
4) Now, you should not have a problem writing your file:
dicomwrite(img,'file.dcm',hdr,'CreateMode','copy');
If you have a problem with another attribute (tag), just repeat the process.

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

回答 (1 件)

Kiran Felix Robert
Kiran Felix Robert 2020 年 11 月 5 日
Hi Javier,
DICOMWRITE does a minimal level of metadata content verification when the CreateMode parameter is given a value of "copy". It makes sure that the datatype of the input matches the expected. So, the Field Corresponding to the attribute needs to be of the appropriate data type.
Suppose the field which causes a data type mismatch is the Gantry ID Field, the Following code can be used to solve it. (The Gantry ID Field requires a data type of ‘LO or long text or char),
info = dicominfo(image);
Im = dicomread(info);
info.GantryID = char(info.GantryID'); % Changing the data type
dicomwrite(Im, newname, info, 'CreateMode', 'copy')
Kiran Felix Robert

カテゴリ

Help Center および File ExchangeDICOM Format についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by