Hello
I have written a code to convert .raw medical images to .dcm format. But I am having some error while trying to add some metadata information.
Following is my code:
fid3 = fopen( 'F:\patient\same patientCT.raw','r');
pCT = fread(fid3, [512*512*160,1], 'int16');
pCT_p = reshape(pCT, [512 512 160]);
fclose(fid3);
new_pCT1=permute(pCT_p,[2 1 3]);
for j =1:size(new_pCT1,3)
File=int16(new_pCT1(:,:,j)+1000);
m = -54.7500 -(j-1)*1.25;
metadata.ImagePositionPatient=[-325 ; -325; m];
metadata.SliceLocation=m;
metadata.InStackPositionNumber=j;
metadata.InstanceNumber=j;
dicomwrite(File,['CT_' int2str(j) '.dcm'], metadata, 'CreateMode', 'copy');
end
Please help me to resolve this issue. Thankyou

댓글 수: 7

Amy
Amy 2017년 10월 25일
Hi Hamza, could you please share the exact error messages you are receiving when trying to run this code?
Hamza Naeem
Hamza Naeem 2017년 10월 26일
편집: Walter Roberson 2017년 10월 26일
Following are the errors:
Error using dicom_copy_IOD>getIOD (line 138)
Missing required attribute (0008,0016) "SOPClassUID"
Error in dicom_copy_IOD (line 26)
IOD_UID = getIOD(metadata, options, dictionary);
Error in dicomwrite>write_message (line 277)
[attrs, status] = dicom_copy_IOD(X, map, ...
Error in dicomwrite (line 208)
[status, options] = write_message(X, filename, map, metadata, options);
Error in Untitled (line 18)
dicomwrite(File,['pCT' int2str(j) '.dcm'], metadata, 'CreateMode' , 'copy');
Walter Roberson
Walter Roberson 2017년 10월 26일
Try passing the appropriate ObjectType parameter to the dicomwrite() call.
Hamza Naeem
Hamza Naeem 2017년 10월 26일
Can you please give some example how to do?
dicomwrite(File,['pCT' int2str(j) '.dcm'], metadata, 'CreateMode' , 'copy', 'ObjectType', 'CT Image Storage')
Hamza Naeem
Hamza Naeem 2017년 10월 26일
편집: Walter Roberson 2017년 10월 26일
Still not working, and now I am having this kind of error:
Warning: The 'SOPClassUID' and 'ObjectType' parameters are ignored when 'CreateMode' is 'copy'.
> In dicomwrite>checkOptionConsistency (line 947)
In dicomwrite (line 193)
In Untitled (line 19)
Error using dicom_copy_IOD>getIOD (line 138)
Missing required attribute (0008,0016) "SOPClassUID"
Error in dicom_copy_IOD (line 26)
IOD_UID = getIOD(metadata, options, dictionary);
Error in dicomwrite>write_message (line 277)
[attrs, status] = dicom_copy_IOD(X, map, ...
Error in dicomwrite (line 208)
[status, options] = write_message(X, filename, map, metadata, options);
Error in Untitled (line 19)
dicomwrite(File,['pCT' int2str(j) '.dcm'], metadata, 'CreateMode' , 'copy', 'ObjectType', 'CT Image Storage')
Walter Roberson
Walter Roberson 2017년 10월 26일
For example for plain CT image storage you might perhaps use SOPClassUID of 1.2.840.10008.5.1.4.1.1.2
... In short, if you are going to create your own metadata then you have a lot to create. It is usually far far easier to take another existing DICOM image of the exact same type that you want to create, and copy its metadata (setting different patient information and dates and a unique instance identifier).

댓글을 달려면 로그인하십시오.

답변 (0개)

태그

질문:

2017년 10월 23일

댓글:

2017년 10월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by