Raw to Dicom conversion
古いコメントを表示
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
2017 年 10 月 25 日
Hi Hamza, could you please share the exact error messages you are receiving when trying to run this code?
Hamza Naeem
2017 年 10 月 26 日
編集済み: Walter Roberson
2017 年 10 月 26 日
Walter Roberson
2017 年 10 月 26 日
Try passing the appropriate ObjectType parameter to the dicomwrite() call.
Hamza Naeem
2017 年 10 月 26 日
Walter Roberson
2017 年 10 月 26 日
dicomwrite(File,['pCT' int2str(j) '.dcm'], metadata, 'CreateMode' , 'copy', 'ObjectType', 'CT Image Storage')
Hamza Naeem
2017 年 10 月 26 日
編集済み: Walter Roberson
2017 年 10 月 26 日
Walter Roberson
2017 年 10 月 26 日
As you are creating a new DICOM object, you will need to set a number of attributes in the metadata. See http://dicomlookup.com/lookup.asp?sw=Ttable&q=C.12-1 and http://dicom.nema.org/dicom/2013/output/chtml/part04/sect_B.5.html and https://dicom.innolitics.com/ciods/rt-plan/sop-common/00080016 and http://dicomiseasy.blogspot.ca/2011/12/chapter-4-dicom-objects-in-chapter-3.html
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 件)
カテゴリ
ヘルプ センター および File Exchange で Read and Write Image Data from Files についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!