Loading Mutiple DICOM images

조회 수: 5 (최근 30일)
srilekha katkuri
srilekha katkuri 2015년 12월 5일
댓글: Walter Roberson 2015년 12월 5일
hello,
i have 53 DICOM images named 000000.dcm - 000053.dcm. i tried to load images and montage view but i am getting only 53rd image.
mri=zeros(256,256,54);
for i=0:53
if i<=9
a=dicomread(['00000' num2str(i) '.dcm']);
else
a=dicomread(['0000' num2str(i) '.dcm']);
end
a(:,:,i+1)=uint8(a);
end
%%Generate Montage
figure
montage(a(:,:,i+1), 'DisplayRange', [0 255]);
i am getting a warning message as Warning: Suspicious fragmentary file, might not be DICOM. Warning: Not enough data imported. Attempted to read 225731429 bytes at position 8. Only read 132756.

답변 (1개)

Walter Roberson
Walter Roberson 2015년 12월 5일
Note: you do not need the 'if':
a = dicomread('000000.dcm');
size0 = size(a);
a(end,end,54) = 0; %for efficiency
for i = 1 : 53
thisfile = sprintf('%06d.dcm', i);
thisdata = dicomread( thisfile );
if ~isequal(size(thisdata), size0)
warning( sprintf('skipped file %s, wrong data size', thisfile ) );
else
a(:,:,i+1) = thisdata;
end
end
This will tell you which files it skipped, and it will leave that slice as all 0.
  댓글 수: 2
srilekha katkuri
srilekha katkuri 2015년 12월 5일
even with this script am getting the same error and same output. its only displaying 000053 image when i try to view files in montage view.
Walter Roberson
Walter Roberson 2015년 12월 5일
a = dicomread('000000.dcm');
size0 = size(a);
a(end,end,:,54) = 0; %for efficiency
for i = 1 : 53
thisfile = sprintf('%06d.dcm', i);
thisdata = dicomread( thisfile );
if ~isequal(size(thisdata), size0)
warning( sprintf('skipped file %s, wrong data size', thisfile ) );
else
a(:,:,:,i+1) = thisdata;
end
end
montage requires the individual images to be in the 4th dimension.
I expect this to still tell you that one of your images is corrupt, but I am expecting that it will tell you which of your images is corrupt, which you would then investigate. Which file is it telling you was skipped?

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

카테고리

Help CenterFile Exchange에서 DICOM Format에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by