Converting Mat file to Dicom file

Hi , I have a mat file including 320 slices of CT image and I am trying to convert them to dicom file using the codes below:
load Reconimg.mat;
size(img) % e.g. if size dimensions = 125x125x320
for image_num = 1:320
dicomwrite(img(1:512,1:512,image_num));
sprintf('Reconimg%s.dcm',num2str(image_num));
end
but I get the following error
Error using dicomwrite (line 178)
At least two input arguments required.
could u please advise
Thanks

답변 (2개)

Jorge Mario Guerra González
Jorge Mario Guerra González 2017년 1월 23일
편집: Jorge Mario Guerra González 2017년 1월 23일

0 개 추천

for image_num = 1:320
dicomwrite(img(1:512,1:512,image_num),FILENAME);
sprintf('Reconimg%s.dcm',num2str(image_num));
end
you forgot to put the filename argument.
use
help dicomwrite
for more information

댓글 수: 5

Hany
Hany 2017년 1월 24일
Thanks Jorge,
I choose the fimenamr Reconimg and it tells me that it has to be string! Could u please advise
filename=strcat('reconimg',str2num(image_num),'.dcm');
dicomwrite(img(1:512,1:512,image_num),filename);
Dont forget to the name into the quotation marks...this things ' ...'
That should work if you put it into the loop
Hany
Hany 2017년 1월 24일
thanks Now I get this error
Error using str2num (line 33) Requires string or character array input.
sorry I didn't write it well it's
filename=strcat('reconimg',num2str(image_num),'.dcm');
dicomwrite(img(1:512,1:512,image_num),filename);
the whole code should be
for image_num = 1:320
filename=strcat('reconimg',num2str(image_num),'.dcm');
dicomwrite(img(1:512,1:512,image_num),filename);
sprintf('Reconimg%s.dcm',num2str(image_num)); %you can delete this if you want
end
Hany
Hany 2017년 1월 25일
Thanks , so turned out the mat file should be the int16 in order for the dicomwrite to work , so here is how it works:
for image_num = 1:320 filename=strcat('Reconimg',num2str(image_num),'.dcm'); B=int16(Reconimg(:,:,image_num)); %dicomwrite(Reconimg(1:512,1:512,image_num),filename); dicomwrite(B,filename); sprintf('Reconimg%s.dcm',num2str(image_num)); %you can delete this if you want end

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

Hany
Hany 2017년 1월 25일

0 개 추천

Thanks , so turned out the mat file should be the int16 in order for the dicomwrite to work , so here is how it works:
for image_num = 1:320 filename=strcat('Reconimg',num2str(image_num),'.dcm'); B=int16(Reconimg(:,:,image_num)); %dicomwrite(Reconimg(1:512,1:512,image_num),filename); dicomwrite(B,filename); sprintf('Reconimg%s.dcm',num2str(image_num)); %you can delete this if you want end

댓글 수: 1

Santiago Romaniolli
Santiago Romaniolli 2018년 7월 24일
Hi Hany, where do you define the variable Reconimg? Because I am having trouble with these sentence: B=int16(Reconimg(:,:,image_num)); Undefined function or variable 'Reconimg'.

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

카테고리

도움말 센터File Exchange에서 Convert Image Type에 대해 자세히 알아보기

태그

질문:

2017년 1월 23일

댓글:

2018년 7월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by